当前位置: 首页>>代码示例>>C#>>正文


C# IServiceCollection.AddElm方法代码示例

本文整理汇总了C#中IServiceCollection.AddElm方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceCollection.AddElm方法的具体用法?C# IServiceCollection.AddElm怎么用?C# IServiceCollection.AddElm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceCollection的用法示例。


在下文中一共展示了IServiceCollection.AddElm方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            services.AddCaching();
            services.AddSession();

            services.AddSwaggerGen();

            services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
            services.Configure<MvcOptions>(options =>
            {
                //options.RespectBrowserAcceptHeader = true;
            });
            services.AddEntityFramework()
                .AddInMemoryDatabase()
                .AddDbContext<ApplicationDbContext>(options => { options.UseInMemoryDatabase(); });

            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddUserStore<ApplicationUserStore<ApplicationUser>>()
                .AddDefaultTokenProviders();

            services.AddTransient<ApplicationUserManager>();
            services.AddTransient<ApplicationSignInManager>();
            services.AddTransient<IUserImageProvider, GravatarProvider>();

            services.AddAuthentication();

            // https://github.com/aspnet/Entropy/blob/dev/samples/Logging.Elm/Startup.cs
            services.AddElm();
        }
开发者ID:CWISoftware,项目名称:accounts,代码行数:32,代码来源:Startup.cs

示例2: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddElm();

            services.ConfigureElm(elmOptions =>
            {
                elmOptions.Filter = (loggerName, loglevel) => loglevel == LogLevel.Verbose;
            });
        }
开发者ID:ryanbrandenburg,项目名称:Diagnostics,代码行数:9,代码来源:Startup.cs

示例3: ConfigureServices

 public void ConfigureServices(IServiceCollection services)
 {
     services.AddElm();
     services.ConfigureElm(options =>
     {
         options.Path = new PathString("/foo");  // defaults to "/Elm"
         options.Filter = (name, level) => level >= LogLevel.Information;
     });
 }
开发者ID:leloulight,项目名称:Entropy,代码行数:9,代码来源:Startup.cs

示例4: ConfigureServices

        // Set up application services
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddElm(options =>
            {
                // We want to log for all log levels and loggers
                options.Filter = (loggerName, logLevel) => true;
            });

            services.AddMvc();
        }
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:11,代码来源:Startup.cs

示例5: ConfigureServices

 public void ConfigureServices(IServiceCollection services)
 {
     services.AddOptions();
     services.AddSingleton<ElmStore>(); // add the store so the ElmLogger can write to it
     services.AddElm(options =>
     {
         options.Path = new PathString("/foo");  // defaults to "/Elm"
         options.Filter = (name, level) => level >= LogLevel.Information;
     });
 }
开发者ID:Tragetaschen,项目名称:Entropy,代码行数:10,代码来源:Startup.cs

示例6: ConfigureServices

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddElm<SqliteDriver>(options => options.ConnectionString = Configuration["Data:IdentityConnection:ConnectionString"]);
            services.Configure<IdentityDbContextOptions>(options =>
            {
                options.DefaultAdminUserName = Configuration["DefaultAdminUsername"];
                options.DefaultAdminPassword = Configuration["DefaultAdminPassword"];
            });

            services.AddElmIdentity<ApplicationUser>();
            
            services.AddIdentity<ApplicationUser, IdentityRole>()
                    // .AddEntityFrameworkStores<ApplicationDbContext>()
                    .AddDefaultTokenProviders();

            services.AddMvc();
        }
开发者ID:folkelib,项目名称:Folke.Identity.Elm,代码行数:17,代码来源:Startup.cs

示例7: ConfigureServices

        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddInstance<IHostingEnvironment>(_hostingEnvironment);
            services.AddInstance<IApplicationEnvironment>(_appEnvironment);
            services.AddOptions();

            services.AddAuthentication();

            services.AddAuthorization(options =>
            {
                options.AddPolicy("Authenticated", policy => policy.RequireAuthenticatedUser());
            });

            services.AddElm();
            services.ConfigureElm(options =>
            {
//                options.Path = new PathString("/foo");  // defaults to "/Elm"
                options.Filter = (name, level) => level >= LogLevel.Information;
            });

            services.AddMvc().AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            });
            services.AddMvcCore().AddJsonFormatters();
            services.AddSwaggerGen(c =>
            {
                c.SingleApiVersion(new Info
                {
                    Version = "v1",
                    Title = "Swashbuckle Sample API",
                    Description = "A sample API for testing Swashbuckle",
                    TermsOfService = "Some terms ..."
                });

                c.DescribeAllEnumsAsStrings();

                c.OperationFilter<AssignOperationVendorExtensions>();
             
            });

            if (_hostingEnvironment.IsDevelopment())
            {
                services.ConfigureSwaggerGen(c =>
                {
                    var xmlPath = string.Format(@"{0}\artifacts\bin\WebApplication1\{1}\{2}{3}\WebApplication1.xml",
                        GetSolutionBasePath(),
                        _appEnvironment.Configuration,
                        _appEnvironment.RuntimeFramework.Identifier,
                        _appEnvironment.RuntimeFramework.Version.ToString().Replace(".", string.Empty));
                   
                    c.IncludeXmlComments(xmlPath);

                    var xmlPath2 = string.Format(@"{0}\artifacts\bin\p6.api.animals.v1\{1}\dotnet5.4\p6.api.animals.v1.xml",
                       GetSolutionBasePath(),
                       _appEnvironment.Configuration);

                    c.IncludeXmlComments(xmlPath2);

                });
            }

            services.AddLogging();
            services.AddWebEncoders();
            services.AddCors();

            services.AddCaching(); // Memory Caching stuff
            services.AddSession();

            // register the global configuration root 
            services.AddSingleton<IConfigurationRoot, GlobalConfigurationRoot>();

            services.Configure<CassandraConfig>(Configuration.GetSection(CassandraConfig.WellKnown_SectionName));


            // Add application services.

            // Do this before we do a BuildServiceProvider because some downstream autofac modules need the librarymanager.
            ILibraryManager libraryManager = null;
            libraryManager = services.GetService<ILibraryManager>();
            TypeGlobals.LibraryManager = libraryManager;

            services.AddSingleton<IFilterProvider, Pingo.Core.Providers.OptOutOptInFilterProvider>();

            services.AddTransient<ClaimsPrincipal>(
               s => s.GetService<IHttpContextAccessor>().HttpContext.User);

            services.Configure<IdentityOptions>(options =>
            {
                options.Cookies.ApplicationCookie.LoginPath = new Microsoft.AspNet.Http.PathString("/Identity/Account/Login");
                options.Cookies.ApplicationCookie.LogoutPath = new Microsoft.AspNet.Http.PathString("/Identity/Account/LogOff");
            });

            services.AddAllConfigureServicesRegistrants(Configuration);
            // autofac auto registration
            services.AddDependencies();
            var serviceProvider = services.BuildServiceProvider(Configuration);

            // Setup the PingoGlobal static .  Easier to use that trying to resolve everytime.
//.........这里部分代码省略.........
开发者ID:ghstahl,项目名称:vNext.Jan2016Web,代码行数:101,代码来源:Startup.cs


注:本文中的IServiceCollection.AddElm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。