假设我有一个IUnityContainer
的实例,如何将这个StructureMap Registry
转换为Unity?
public class MvcRegistry : Registry
{
public MvcRegistry()
{
For<BundleCollection>().Use(BundleTable.Bundles);
For<RouteCollection>.Use(RouteTable.Routes);
}
}
例如,...
public static class UnityContainerExtensions
{
public static IUnityContainer RegisterMvcComponents(this IUnityContainer container)
{
// similar to this:
container.RegisterType(typeof(BundleCollection), BundleTable.Bundles)
return container;
}
}
...这是不对的,但是您理解了我的意思...
答案 0 :(得分:1)
container.RegisterInstance<BundleCollection>(BundleTable.Bundles)