public void ConfigureServices(IServiceCollection services)
        {
            var serilogSettings = Configuration.GetSection("SerilogSettings").Get <SerilogSettings>();

            SerilogConfiguration.Configure(serilogSettings);

            var ravenConfig = Configuration.GetSection("RavenDbSettings").Get <RavenDbSettings>();

            services.AddSingleton(RavenDbConfiguration.Configure(ravenConfig));

            var filesConfig = Configuration.GetSection("FileSettings").Get <FilesSettings>();

            services.AddSingleton(filesConfig);

            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options => {
                options.Events.OnRedirectToLogin = (context) =>
                {
                    context.Response.StatusCode = 401;
                    return(Task.CompletedTask);
                };
            });

            services.AddMvc();
        }
Exemple #2
0
        public void ApplicationNameCannotBeEmpty(string applicationName)
        {
            Action method = () => SerilogConfiguration.Configure(fakeHostingEnvironment, fakeConfiguration, fakeLoggingBuilder, applicationName);

            method.Should()
            .Throw <ArgumentException>()
            .WithMessage("applicationName cannot be empty.");
        }
Exemple #3
0
        public void LoggingBuilderCannotBeNull()
        {
            Action method = () => SerilogConfiguration.Configure(fakeHostingEnvironment, fakeConfiguration, null, A.Dummy <string>());

            method.Should()
            .Throw <ArgumentNullException>()
            .WithMessage(ExceptionsUtility.NullArgument("logging"));
        }
        public void LoggingBuilderCannotBeNull()
        {
            Action method = () => SerilogConfiguration.Configure(fakeHostingEnvironment, fakeConfiguration, null, A.Dummy <string>());

            method.Should()
            .Throw <ArgumentNullException>()
            .WithMessage($"Value cannot be null.{Environment.NewLine}Parameter name: logging");
        }
Exemple #5
0
        public void ConfigureServices(IServiceCollection services)
        {
            var serilogSettings = Configuration.GetSection("SerilogSettings").Get <SerilogSettings>();

            SerilogConfiguration.Configure(serilogSettings);

            var ravenConfig = Configuration.GetSection("RavenDbSettings").Get <RavenDbSettings>();

            services.AddSingleton(RavenDbConfiguration.Configure(ravenConfig));

            var highScoreSettings = Configuration.GetSection("HighScoreSettings").Get <HighScoreSettings>();

            services.AddSingleton(highScoreSettings);

            services.AddMvc();
        }
 private static void ConfigureLogging(WebHostBuilderContext context, ILoggingBuilder logging)
 {
     SerilogConfiguration.Configure(context.HostingEnvironment, context.Configuration, logging, "OnionPattern.Api");
 }