在ninject
我有這樣的代碼:C#Ninject到結構圖轉換器
var resourceManagers = new ResourceManager[1];
resourceManagers[0] = Validation.ResourceManager;
kernel.Bind<ILocalizedStringProvider>().To<ResourceStringProvider>()
.WithConstructorArgument("resourceManager", resourceManagers);
kernel.Rebind<ModelValidatorProvider>().To<LocalizedModelValidatorProvider>();
我想將其轉換爲StructureMap
我不喜歡這樣的:
IContainer container = new Container();
var ioC = new IoC();
ioC.Initialize(container);
container.Configure(x =>
{
var resourceManagers = new ResourceManager[1];
resourceManagers[0] = ModelValidation.ResourceManager;
x.For<ILocalizedStringProvider>().Use<ResourceStringProvider>.Ctor<string>(@"resourceManager").Is(resourceManagers);
x.For<ModelValidatorProvider>().Add<LocalizedModelValidatorProvider>();
});
DependencyResolver.SetResolver(new StructureMapDependencyResolver(container));
GlobalConfiguration.Configuration.DependencyResolver = new StructureMapDependencyResolver(container);
,但我得到例外:
硒真實性的代碼說明項目文件的線路抑制狀態 錯誤CS0119「CreatePluginFamilyExpression.Use()」 是一種方法,它是無效的在給定上下文
如何使用StructureMap
做到這一點?