В чем разница между ResourceControllerFactory и DefaultControllerFactory в ASP.NET MVC?
Контекст: Я хочу подключить контейнер IOC к фабрике контроллеров - я ранее переопределил DefaultControllerFactory
, чтобы сделать это, но я вижу, что ResourceControllerFactory
используется впроект, с которым я сейчас работаю.
Обеспечивает ли один улучшенную поддержку API REST?
Код для каждого:
DefaultControllerFactory
public class DefaultControllerFactory : IControllerFactory
{
// Fields
private IBuildManager _buildManager;
private ControllerBuilder _controllerBuilder;
private ControllerTypeCache _instanceControllerTypeCache;
private static ControllerTypeCache _staticControllerTypeCache;
// Methods
static DefaultControllerFactory();
public DefaultControllerFactory();
internal static InvalidOperationException CreateAmbiguousControllerException(RouteBase route, string controllerName, ICollection<Type> matchingTypes);
public virtual IController CreateController(RequestContext requestContext, string controllerName);
protected internal virtual IController GetControllerInstance(RequestContext requestContext, Type controllerType);
protected internal virtual Type GetControllerType(RequestContext requestContext, string controllerName);
private Type GetControllerTypeWithinNamespaces(RouteBase route, string controllerName, HashSet<string> namespaces);
public virtual void ReleaseController(IController controller);
// Properties
internal IBuildManager BuildManager { get; set; }
internal ControllerBuilder ControllerBuilder { get; set; }
internal ControllerTypeCache ControllerTypeCache { get; set; }
}
ResourceControllerFactory
public class ResourceControllerFactory : IControllerFactory
{
// Fields
private IControllerFactory inner;
private const string restActionToken = "$REST$";
// Methods
public ResourceControllerFactory();
public ResourceControllerFactory(IControllerFactory inner);
public IController CreateController(RequestContext requestContext, string controllerName);
public void ReleaseController(IController controller);
// Nested Types
private class ResourceControllerActionInvoker : ControllerActionInvoker
{
// Methods
public ResourceControllerActionInvoker();
protected override ActionDescriptor FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, string actionName);
// Nested Types
private class ResourceErrorActionDescriptor : ActionDescriptor
{
// Fields
private ControllerDescriptor controllerDescriptor;
private string message;
private HttpStatusCode statusCode;
// Methods
public ResourceErrorActionDescriptor(ControllerDescriptor controllerDescriptor, HttpStatusCode statusCode, string message);
public override object Execute(ControllerContext controllerContext, IDictionary<string, object> parameters);
public override ParameterDescriptor[] GetParameters();
// Properties
public override string ActionName { get; }
public override ControllerDescriptor ControllerDescriptor { get; }
}
}
}
Expand Methods