Fix for issue #57
Replaced ActivatorUtilties with ITypeActivator in WebFX.
This commit is contained in:
parent
a5cb050b97
commit
51e5a5bf19
|
|
@ -10,11 +10,13 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
public class DefaultControllerFactory : IControllerFactory
|
||||
{
|
||||
private readonly ITypeActivator _activator;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public DefaultControllerFactory(IServiceProvider serviceProvider)
|
||||
public DefaultControllerFactory(IServiceProvider serviceProvider, ITypeActivator activator)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_activator = activator;
|
||||
}
|
||||
|
||||
public object CreateController(ActionContext actionContext, ModelStateDictionary modelState)
|
||||
|
|
@ -27,7 +29,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
try
|
||||
{
|
||||
var controller = ActivatorUtilities.CreateInstance(_serviceProvider, actionDescriptor.ControllerDescriptor.ControllerTypeInfo.AsType());
|
||||
var controller = _activator.CreateInstance(actionDescriptor.ControllerDescriptor.ControllerTypeInfo.AsType());
|
||||
|
||||
// TODO: How do we feed the controller with context (need DI improvements)
|
||||
InitializeController(controller, actionContext, modelState);
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
{
|
||||
public class GenericModelBinder : IModelBinder
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ITypeActivator _activator;
|
||||
|
||||
public GenericModelBinder(IServiceProvider serviceProvider)
|
||||
public GenericModelBinder(ITypeActivator activator)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_activator = activator;
|
||||
}
|
||||
|
||||
public bool BindModel(ModelBindingContext bindingContext)
|
||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
Type binderType = ResolveBinderType(bindingContext.ModelType);
|
||||
if (binderType != null)
|
||||
{
|
||||
var binder = ActivatorUtilities.CreateInstance<IModelBinder>(_serviceProvider);
|
||||
var binder = _activator.CreateInstance<IModelBinder>();
|
||||
return binder.BindModel(bindingContext);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
var describe = new ServiceDescriber(configuration);
|
||||
|
||||
yield return describe.Transient<ITypeActivator, TypeActivator>();
|
||||
|
||||
yield return describe.Transient<IControllerFactory, DefaultControllerFactory>();
|
||||
yield return describe.Transient<IControllerDescriptorFactory, DefaultControllerDescriptorFactory>();
|
||||
yield return describe.Transient<IActionSelector, DefaultActionSelector>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue