Web.Generics.Web.Mvc.Infrastructure.GenericControllerFactory.GetControllerType C# (CSharp) Method

GetControllerType() protected method

protected GetControllerType ( System.Web.Routing.RequestContext requestContext, string controllerName ) : Type
requestContext System.Web.Routing.RequestContext
controllerName string
return System.Type
		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;
		}