【发布时间】:2014-03-10 09:10:23
【问题描述】:
我继承了一个在设置了完全信任的主机上运行的项目,因为这是温莎城堡 IoC 所必需的。但是,新主机将仅在 Medium Trust 中运行(大多数共享主机提供商也是如此),因此我需要将 Windsor 替换为另一个 IoC。
作为 IoC 的新手,我不确定哪个框架最适合在中等信任和服务定位器模型下使用。
现有注册码示例如下:
IWindsorContainer container = new WindsorContainer();
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
container.RegisterControllers(typeof(HomeController).Assembly);
container.Register(
Component.For(typeof(IEntityDuplicateChecker))
.ImplementedBy(typeof(EntityDuplicateChecker))
.Named("entityDuplicateChecker"));
container.Register(
AllTypes
.FromAssemblyNamed("Salient.Website.Data")
.Pick()
.WithService.FirstNonGenericCoreInterface("Salient.Website.Core"));
container.Register(
AllTypes
.FromThisAssembly()
.Pick()
.WithService.FirstNonGenericCoreInterface("Salient.Website.ApplicationServices"));
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
如果我有一些关于哪些框架适合的指导,在中等信任的共享主机下工作,并希望有一个翻译上述内容的示例以开始使用,这将节省我对每个框架的大量反复试验。
【问题讨论】:
-
看到了这个相关的question。不确定这是否会对您有所帮助?
标签: asp.net castle-windsor ioc-container medium-trust