Esempio n. 1
0
        public static void Start()
        {
            DependencyInjectionStarter.container.RegisterWebApiControllers(GlobalConfiguration.Configuration);

            GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(DependencyInjectionStarter.container);

            DependencyInjectionStarter.container.RegisterManyForOpenGeneric(typeof(ICommandHandler <>), typeof(RegisterUserCommandHandler).Assembly);

            DependencyInjectionStarter.Initialize();

            DependencyInjectionStarter.container.Verify();
        }
Esempio n. 2
0
        /// <summary>
        /// Use the KickStart extension to configure Microsoft.Extensions.DependencyInjection.
        /// </summary>
        /// <param name="configurationBuilder">The configuration builder.</param>
        /// <param name="configure">The <see langword="delegate"/> to configure DependencyInjection options.</param>
        /// <returns>
        /// A fluent <see langword="interface"/> to configure KickStart.
        /// </returns>
        public static IConfigurationBuilder UseDependencyInjection(this IConfigurationBuilder configurationBuilder, Action <IDependencyInjectionBuilder> configure)
        {
            var options = new DependencyInjectionOptions();
            var starter = new DependencyInjectionStarter(options);

            if (configure != null)
            {
                var builder = new DependencyInjectionBuilder(options);
                configure(builder);
            }

            configurationBuilder.ExcludeAssemblyFor <DependencyInjectionStarter>();
            configurationBuilder.ExcludeAssemblyFor <IServiceCollection>();
            configurationBuilder.Use(starter);

            return(configurationBuilder);
        }