Fix API change in ITypeActivator
This commit is contained in:
parent
dc6843acf7
commit
89b53aab25
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
|
|
@ -29,7 +28,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
|
||||
try
|
||||
{
|
||||
var controller = _activator.CreateInstance(actionDescriptor.ControllerDescriptor.ControllerTypeInfo.AsType());
|
||||
var controller = _activator.CreateInstance(_serviceProvider, actionDescriptor.ControllerDescriptor.ControllerTypeInfo.AsType());
|
||||
|
||||
// TODO: How do we feed the controller with context (need DI improvements)
|
||||
InitializeController(controller, actionContext);
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
public class GenericModelBinder : IModelBinder
|
||||
{
|
||||
private readonly ITypeActivator _activator;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public GenericModelBinder(ITypeActivator activator)
|
||||
public GenericModelBinder(IServiceProvider serviceProvider, ITypeActivator activator)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_activator = activator;
|
||||
}
|
||||
|
||||
|
|
@ -21,7 +23,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
Type binderType = ResolveBinderType(bindingContext.ModelType);
|
||||
if (binderType != null)
|
||||
{
|
||||
var binder = (IModelBinder)_activator.CreateInstance(binderType);
|
||||
var binder = (IModelBinder)_activator.CreateInstance(_serviceProvider, binderType);
|
||||
return binder.BindModel(bindingContext);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue