Esempio n. 1
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json");

            Configuration = builder.Build();
        }
Esempio n. 2
0
 public TemplateService(
     ILogger <TemplateService> logger,
     IRazorViewEngine viewEngine,
     IServiceProvider serviceProvider,
     ITempDataProvider tempDataProvider,
     Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment
     )
Esempio n. 3
0
 public ReportController(IOptions <AppSettings> settings, Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache,
                         Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment)
 {
     _cache = memoryCache;
     _hostingEnvironment = hostingEnvironment;
     _connection         = settings.Value.PersistanceConnectionString;
 }
 public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
         // to do - wire in our HTTP endpoints
         app.Use(async(ctx, next) =>
         {
             if (Path.GetExtension(ctx.Request.Path) == ".ts" || Path.GetExtension(ctx.Request.Path) == ".tsx")
             {
                 await ctx.Response.WriteAsync(File.ReadAllText(ctx.Request.Path.Value.Substring(1)));
             }
             else
             {
                 await next();
             }
         });
     }
     app.UseSignalR(routes =>
     {
         routes.MapHub <DataNotificationHub>("/hubs/notifications");
     });
     app.UseStaticFiles();
     app.UseMvc();
 }
Esempio n. 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider provider)
        {
            app.UseForwardedHeaders();
            app.UseHsts();
            GlobalConfiguration.Configuration.UseActivator(new HangfireActivator(app.ApplicationServices));

            app.UseMiddleware <ExceptionMiddleware>();
            app.UseHttpsRedirection();
            app.UseCors("AllowCors");

            app.UseHangfireServer();

            app.UseHangfireDashboard(Configuration.GetValue <string>("Hangfire:Path"),
                                     new DashboardOptions
            {
                Authorization = new[]
                {
                    provider.GetService <IDashboardAuthorizationFilter>()
                }
            });

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            RegisterAsyncServices(provider.GetService <IServiceScopeFactory>());
        }
 /// <summary>
 /// Constructor for netstandard
 /// </summary>
 public EnvironmentSettings(Microsoft.AspNetCore.Hosting.IHostingEnvironment env)
 {
     EnvironmentName     = env?.EnvironmentName;
     ContentRootPath     = env?.ContentRootPath;
     WebRootPath         = env?.WebRootPath;
     ApplicationBasePath = System.AppContext.BaseDirectory;
 }
        public void GlobalSetup()
        {
            var mockServices = new Mock <IServiceProvider>();

            mockServices
            .Setup(s => s.GetService(typeof(IHtmlMinificationManager)))
            .Returns(new HtmlMinificationManager(new NullLogger(),
                                                 Options.Create(new HtmlMinificationOptions
            {
                CssMinifierFactory = new KristensenCssMinifierFactory(),
                JsMinifierFactory  = new CrockfordJsMinifierFactory()
            })
                                                 ))
            ;
            mockServices
            .Setup(s => s.GetService(typeof(IHttpCompressionManager)))
            .Returns(new HttpCompressionManager(Options.Create(new HttpCompressionOptions())))
            ;

            var mockEnvironment = new Mock <HostingEnvironment>();

            mockEnvironment
            .Setup(m => m.EnvironmentName)
            .Returns(Environments.Production)
            ;

            _services    = mockServices.Object;
            _environment = mockEnvironment.Object;
        }
 public HostingEnvironmentAdapter(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment)
 {
     EnvironmentName         = hostingEnvironment.EnvironmentName;
     ApplicationName         = hostingEnvironment.ApplicationName;
     ContentRootPath         = hostingEnvironment.ContentRootPath;
     ContentRootFileProvider = hostingEnvironment.ContentRootFileProvider;
 }
Esempio n. 9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostEnvironment env, ILoggerFactory loggerFactory)
        {
            Logger log = new LoggerConfiguration()
                         .WriteTo.LiteDB($"Logs/log_{DateTime.Now.Date:yyyy-dd-M}.db")
                         .CreateLogger();

            loggerFactory.AddSerilog(log, true);
            loggerFactory.AddFile("Logs/Flubu-{Date}.txt");
            app.UseDeveloperExceptionPage();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            app.UseStaticFiles();
#if !NETCOREAPP3_1
            app.UseSwagger(c =>
            {
                c.PreSerializeFilters.Add((swagger, httpReq) => swagger.Host = httpReq.Host.Value);
            });
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1 Docs");
            });
#endif
        }
Esempio n. 10
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logging)
        {
            #region NLOG

            NLog.LogManager.LoadConfiguration("nlog.config");
            logging.AddNLog();

            #endregion

            app.UseDeveloperExceptionPage();

            app.UseWhen(
                c => c.Request.Path.Value.ToLower().EndsWith("appsettings.json") || c.Request.Path.Value.ToLower().EndsWith(".map"),
                _ => _.Run((context => context.Response.WriteAsync("503"))));

            app.UseLogDashboard();

            app.UseWhen(
                c =>
            {
                var path = c.Request.Path.Value.ToLower();
                return(path.EndsWith(".api") || path.EndsWith(".rollback") || path.EndsWith(".upload") || path.EndsWith(".delete") || path.EndsWith(".pathlist") || path.EndsWith(".reupload"));
            },
                _ => _.UseMiddleware <ApiMiddleware>());

            app.UseStaticFiles();

            app.UseJsEngine();

            app.UseMvc(routes =>
            {
                routes.MapRoute("Admin", "Admin/{*url}", defaults: new { controller = "Home", action = "Admin" });
                routes.MapRoute("Spa", "{*url}", defaults: new { controller = "Home", action = "Index" });
            });
        }
Esempio n. 11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}
            //else
            //{
            //    app.UseExceptionHandler("/Error");
            //    app.UseHsts();
            //}

            app.UseCors(config =>
                        config.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().AllowCredentials());


            app.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseHttpsRedirection();

            app.UseSignalR(routes =>
            {
                routes.MapHub <PingHub>("/pingHub");
                routes.MapHub <StatusOverviewHub>("/overviewHub");
            });

            //  app.UseWebSockets();

            app.UseMvc();
        }
Esempio n. 12
0
        public BtcTransmuterOptions(IConfiguration configuration, IHostingEnvironment hostingEnvironment, ILogger logger)
        {
            DatabaseConnectionString = configuration.GetValue <string>("Database");
            DataProtectionDir        = configuration.GetValue <string>("DataProtectionDir");
            DatabaseType             = configuration.GetValue <DatabaseType>("DatabaseType", DatabaseType.Sqlite);
            ExtensionsDir            = configuration.GetValue <string>("ExtensionsDir",
                                                                       Path.Combine(hostingEnvironment.ContentRootPath, "Extensions"));

            if (DatabaseType == DatabaseType.Sqlite)
            {
                var dbFilePath = DatabaseConnectionString.Substring(DatabaseConnectionString.IndexOf("Data Source=") + "Data Source=".Length);
                dbFilePath = dbFilePath.Substring(0, dbFilePath.IndexOf(";"));

                if (!string.IsNullOrEmpty(Path.GetDirectoryName(dbFilePath)))
                {
                    if (DataProtectionDir == null)
                    {
                        DataProtectionDir = Path.GetDirectoryName(dbFilePath);
                    }
                    Directory.CreateDirectory(Path.GetDirectoryName(dbFilePath));
                }
            }

            logger.LogWarning($"Connecting to {DatabaseType} db with: {DatabaseConnectionString}");
            logger.LogWarning($"Extensions Dir: {ExtensionsDir}, Data Protection Dir: {DataProtectionDir}");
        }
Esempio n. 13
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            // add http for Schema at default url /graphql
            app.UseGraphQL <ProductSchema>();

            // use graphql-playground at default url /ui/playground
            app.UseGraphQLPlayground(new GraphQLPlaygroundOptions());
        }
        public ReportDesignerAPIController(Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache, Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment)
        {
            _cache = memoryCache;
            _hostingEnvironment = hostingEnvironment;
            ExternalServer externalServer = new ExternalServer(_hostingEnvironment);

            ReportDesignerHelper.ReportingServer = externalServer;
        }
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     app.UseDeveloperExceptionPage();
     app.UseStaticFiles();
     app.UseMvc();
     app.UseCors("LocalSpa");
     app.UseSignalR(route => route.MapHub <ApplicationHub>("/application"));
 }
Esempio n. 16
0
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     app.UseServiceModel(builder =>
     {
         builder.AddService <EchoService>();
         builder.AddServiceEndpoint <EchoService, IEchoService>(new BasicHttpBinding(), "/BasicWcfService/basichttp.svc");
     });
 }
Esempio n. 17
0
 public UpdateCenterController(IGitHubClient client, ITaskFactory taskFactory, IFlubuSession flubuSession, IHostEnvironment hostEnvironment, IHostApplicationLifetime applicationLifetime)
 {
     _client              = client;
     _taskFactory         = taskFactory;
     _flubuSession        = flubuSession;
     _hostEnvironment     = hostEnvironment;
     _applicationLifetime = applicationLifetime;
 }
Esempio n. 18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseMiddleware <MetricsPushingMiddleware>();
            app.UseMiddleware <ExceptionHandlingMiddleware>();
            app.UseMiddleware <RateLimitingMiddleware>();

            app.UseMvc();
        }
Esempio n. 19
0
 public FileContentService(
     string textContentDirectoryPath,
     HostingEnvironment hostingEnvironment
     )
 {
     _textContentDirectoryPath = textContentDirectoryPath;
     _hostingEnvironment       = hostingEnvironment;
 }
Esempio n. 20
0
File: Startup.cs Progetto: saltz/Din
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .AddEncryptedProvider();

            builder.AddEnvironmentVariables();
            Configuration = builder.Build();
        }
Esempio n. 21
0
 public ReportMovimentacaoController(Microsoft.Extensions.Caching.Memory.IMemoryCache memoryCache,
                                     Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment, IReportRepository repository, IConfiguration configuration)
 {
     _cache = memoryCache;
     _hostingEnvironment = hostingEnvironment;
     _repository         = repository;
     _config             = configuration;
 }
Esempio n. 22
0
        protected StartupAbstract(IHostingEnvironment env)
        {
            Env = env;
            var cfgHelper = new ConfigurationHelper();

            //加载主机配置项
            HostOptions = cfgHelper.Get <HostOptions>("Host", env.EnvironmentName, true);
        }
Esempio n. 23
0
 public ValuesController(ILogger <ValuesController> logger, Microsoft.AspNetCore.Hosting.IHostingEnvironment e)
 {
     this._logger = logger;
     this._logger.LogInformation("ValuesController ===========");
     this._logger.LogDebug($"debug: ApplicationName: {e.ApplicationName}  e.WebRootPath: {e.WebRootPath}");
     this._logger.LogInformation($"info: ApplicationName: {e.ApplicationName}  e.WebRootPath: {e.WebRootPath}");
     this._logger.LogError($"error: ApplicationName: {e.ApplicationName}  e.WebRootPath: {e.WebRootPath}");
 }
 public ExpenseController(IExpenseRepository expensesRepository, IAttorneyRepository attorneyRepository,
                          Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment, IActivityRepository activityRepository)
 {
     this._expensesRepo  = expensesRepository;
     this._attorneyRepo  = attorneyRepository;
     _hostingEnvironment = hostingEnvironment;
     this._activityRepo  = activityRepository;
 }
Esempio n. 25
0
        public ServerStartup(Microsoft.AspNetCore.Hosting.IHostingEnvironment env)
        {
            var builder =
                new ConfigurationBuilder()
                .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
Esempio n. 26
0
 public virtual void Configure(IApplicationBuilder app, IHostingEnvironment env,
                               IApplicationLifetime appLifetime, IApiVersionDescriptionProvider provider)
 {
     app.UseForwardedHeaders(new ForwardedHeadersOptions {
         ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
     });
     appLifetime.ApplicationStopping.Register(ProgramBase <TStart> .ConsulConfigCancellationTokenSource.Cancel);
     app.UseCoreFunctionality(provider, ConfigureSwagger);
 }
Esempio n. 27
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     app.UseRouting();
     app.UseEndpoints(x =>
     {
         //x.MapControllers();
         x.MapJasperEndpoints();
     });
 }
Esempio n. 28
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="environment"></param>
 /// <param name="logger"></param>
 public Startup(
     IConfiguration configuration,
     IHostingEnvironment environment,
     ILogger <Startup> logger)
 {
     _configuration = configuration;
     _environment   = environment;
     _logger        = logger;
 }
Esempio n. 29
0
 public CoverScreenshotsService(Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment)
 {
     //this.options = options;
     this._hostingEnvironment = _hostingEnvironment;
     //_service.GetService()
     //this._dbContext = _dbContext;
     //this._dbContext = _dbContext;
     //this._service = _service;
 }
        public Startup(Microsoft.AspNetCore.Hosting.IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
        }