本文整理汇总了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();
}
示例2: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddElm();
services.ConfigureElm(elmOptions =>
{
elmOptions.Filter = (loggerName, loglevel) => loglevel == LogLevel.Verbose;
});
}
示例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;
});
}
示例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();
}
示例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;
});
}
示例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();
}
示例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.
//.........这里部分代码省略.........