lundi 8 août 2016

Get the result/request object types from a controller in MVC using reflection

I got all the methods that returns an ActionResult from a dll by reflection using this code:

MyAssembly.GetTypes()
                .SelectMany(t => t.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public))
                .Where(d => d.ReturnType.Name == "ActionResult" && d.IsPublic);

Now, I would like to have the request object and the result object of each controller.

Generally, the structure of a controller in my project is this:

[ServiceControllerResult(typeof(MyControllerResult))]
public ActionResult MyController(MyControllerRequest request)
{
    var response = new ServiceResponse<MyControllerResult>();
    // do something
    return ServiceResult(response);
}

Now, how I can get the MyControllerResult and MyControllerRequest objects from a dll (or from a directory where are stored my referenced ddl) ?

Thanks





Aucun commentaire:

Enregistrer un commentaire