I have this controller
public class AccountController : BaseController
{
[HttpPost]
[AllowAnonymous]
public async Task<ActionResult> Authenticate(LoginUser model)
{
}
}
And here is my input model
public class LoginUser
{
public string UserName { get; set; }
public string Password { get; set; }
public string CaptchaCode { get; set; }
}
I want to use reflection to extract data .The example of data that I need this output
**Account:Authenticate:UserName ,Password ,CaptchaCode**
I find a code as you can see here :
Assembly asm = Assembly.GetAssembly(typeof(Club.Web.MvcApplication));
var controlleractionlist = asm.GetTypes()
.Where(type => typeof(System.Web.Mvc.Controller).IsAssignableFrom(type))
.SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public))
.Where(m => !m.GetCustomAttributes(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), true).Any())
.Select(x => new { Controller = x.DeclaringType.Name, input = String.Join(",", x.GetParameters().Select(a => a.Name+"|"+a.ParameterType).ToArray()), Action = x.Name, ReturnType = x.ReturnType.Name, Attributes = String.Join(",", x.GetCustomAttributes().Select(a => a.GetType().Name.Replace("Attribute", ""))) })
.OrderBy(x => x.Controller).ThenBy(x => x.Action).ToList();
But it returns
**Account:Authenticate:LoginUser**
But I need the item of my class
Aucun commentaire:
Enregistrer un commentaire