Пример #1
0
        /// <summary>
        /// Uses the cloud.
        /// </summary>
        /// <returns>The cloud.</returns>
        /// <param name="app">App.</param>
        public static IApplicationBuilder UseCloud(this IApplicationBuilder app)
        {
            var cloud = new Cloud();

            app.UseCloud(cloud);
            cloud.Start();
            return(app);
        }
Пример #2
0
        /// <summary>
        /// Start the cloud with args.
        /// </summary>
        /// <returns>The start.</returns>
        /// <param name="cloud">Cloud.</param>
        /// <param name="args">Arguments.</param>
        public static Cloud Start(this Cloud cloud, string[] args)
        {
            var webHostBuilder = WebHost.CreateDefaultBuilder(args).ConfigureAppConfiguration((hostingContext, config) =>
            {
                if (args != null)
                {
                    config.AddCommandLine(args);
                }
            });

            return(cloud.Start(webHostBuilder));
        }
Пример #3
0
        /// <summary>
        /// Builds the web host.
        /// </summary>
        /// <returns>The web host.</returns>
        /// <param name="webHostBuilder">Web host builder.</param>
        /// <param name="configCloud">Config cloud.</param>
        /// <param name="configApp">Config app.</param>
        /// <param name="configCloudApp">Config cloud app.</param>
        public static IWebHostBuilder BuildWebHost(IWebHostBuilder webHostBuilder, Action <Cloud> configCloud = null, Action <IApplicationBuilder> configApp = null, Action <IApplicationBuilder, Cloud> configCloudApp = null)
        {
            var cloud = new Cloud();

            configCloud?.Invoke(cloud);
            webHostBuilder = webHostBuilder.ConfigureServices(services =>
            {
                services.AddRouting();
            }).ConfigureAppConfiguration((hostingContext, config) =>
            {
                var env            = hostingContext.HostingEnvironment;
                HostingEnvironment = env;
                config.AddEnvironmentVariables();
            }).Configure(app =>
            {
                if (toggleLog)
                {
                    app.UseLog();
                }
                if (ProxyTrusted && UsedHttpsRedirect)
                {
                    app.UseHttpsRedirect();
                }
                app.UseCloud(cloud);
                app.UseDefaultHomepage();
                cloud.Start();
                configApp?.Invoke(app);
                configCloudApp?.Invoke(app, cloud);
            }).ConfigureLogging((context, builder) =>
            {
                builder.AddFilter("Microsoft", LogLevel.Warning)
                .AddFilter("System", LogLevel.Warning)
                .AddFilter("NToastNotify", LogLevel.Warning)
                .AddConsole();
            }).UseKestrel();

            if (cloud.IsDevelopment)
            {
                webHostBuilder = webHostBuilder.UseLocalHost();
            }
            return(webHostBuilder);
        }