protected override Type GetControllerType(RequestContext requestContext, string controllerName)
{
Type controllerType = base.GetControllerType(requestContext, controllerName);
if (controllerType == null)
{
// specific controller does not exist... try the generic one
var entityType = domainAssembly.GetType(domainAssembly.GetTypes()[0].Namespace + "." + controllerName);
if (entityType == null)
{
return null;
}
var genericViewModelType = typeof(GenericViewModel<>).MakeGenericType(entityType);
controllerType = typeof(GenericController<,>).MakeGenericType(entityType, genericViewModelType);
}
return controllerType;
}