Exemplo n.º 1
0
        private static CodeZeroBootstrapper AddCodeZeroBootstrapper <TStartupModule>(IServiceCollection services, Action <CodeZeroBootstrapperOptions> optionsAction)
            where TStartupModule : CodeZeroModule
        {
            var codeZeroBootstrapper = CodeZeroBootstrapper.Create <TStartupModule>(optionsAction);

            services.AddSingleton(codeZeroBootstrapper);
            return(codeZeroBootstrapper);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Use this extension method if you don't initialize CodeZero in other way.
        /// Otherwise, use <see cref="UseCodeZero(IAppBuilder)"/>.
        /// </summary>
        /// <typeparam name="TStartupModule">The type of the startup module.</typeparam>
        public static void UseCodeZero <TStartupModule>(this IAppBuilder app, [CanBeNull] Action <CodeZeroBootstrapper> configureAction, [CanBeNull] Action <CodeZeroOwinOptions> optionsAction = null)
            where TStartupModule : CodeZeroModule
        {
            app.UseCodeZero(optionsAction);

            if (!app.Properties.ContainsKey("_CodeZeroBootstrapper.Instance"))
            {
                var codeZeroBootstrapper = CodeZeroBootstrapper.Create <TStartupModule>();
                app.Properties["_CodeZeroBootstrapper.Instance"] = codeZeroBootstrapper;
                configureAction?.Invoke(codeZeroBootstrapper);
                codeZeroBootstrapper.Initialize();
            }
        }