[Route("api/[controller]")]
public class loopdisc : Controller
{
private readonly IActionDescriptorCollectionProvider _provider;
public loopdisc(IActionDescriptorCollectionProvider provider)
{
_provider = provider;
}
[HttpPost("mainstart")]
public Task<IActionResult> getresult()
{
var dataDic = typeof(BaseContext).GetProperties(BindingFlags.Public | BindingFlags.Instance);
var names = new List<string>();
names.AddRange(dataDic.Where(x => x.PropertyType.GenericTypeArguments.Any())
.Select(x => x.PropertyType.GenericTypeArguments.First().Name));
var ls = _provider.ActionDescriptors.Items.Select(e => e is ControllerActionDescriptor mau
? (
mau.ControllerTypeInfo.DeclaredMethods
.First(x => x.Name.Equals(mau.ActionName)).GetMethodBody()
?.LocalVariables.Select(jim =>
jim.LocalType.GenericTypeArguments.Any() &&
names.Contains(jim.LocalType.GenericTypeArguments[0].Name)
? jim.LocalType.GenericTypeArguments[0].Name
: string.Empty
)
,
$"{mau.ControllerName}/{mau.ActionName}".ToLowerInvariant())
: default)
.ToList();
var copy = ls.Where(x => x.Item1.Any(min => !string.IsNullOrEmpty(min)))
.Select(x => new { sets = x.Item1.ToHashSet(), router = x.Item2 });
return Task.FromResult<IActionResult>(Ok(copy));
}
}
gist 地址 -> https://gist.github.com/KomiSans/7cbcb6c3bf885a08002313e9ff1fee22
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.