Ejemplo n.º 1
0
        public static IAppBuilder UseDryIocWithTransientControllers(this IAppBuilder app, Container container, HttpConfiguration config)
        {
            var controllerTypeResolver = config.Services.GetHttpControllerTypeResolver();
            var controllerTypes        = controllerTypeResolver.GetControllerTypes(config.Services.GetAssembliesResolver());


            container.RegisterMany(
                controllerTypes,
                Reuse.Transient,
                ifAlreadyRegistered: IfAlreadyRegistered.Replace,
                nonPublicServiceTypes: true,
                setup: Setup.With(trackDisposableTransient: true)
                );


            container.SetFilterProvider(config.Services);
            DryIocWebApi.InsertRegisterRequestMessageHandler(config);

            config.DependencyResolver = new DryIocDependencyResolver(container);
            return(app);
        }
Ejemplo n.º 2
0
        internal static void WithWebApi()
        {
            var webApiContainer = GetContainer().WithWebApi(GlobalConfiguration.Configuration, throwIfUnresolved: type => DryIocWebApi.IsController(type));

            container = new Lazy <IContainer>(() => webApiContainer);
        }