本文整理汇总了C#中IServiceCollection.ConfigureDataContext方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceCollection.ConfigureDataContext方法的具体用法?C# IServiceCollection.ConfigureDataContext怎么用?C# IServiceCollection.ConfigureDataContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceCollection
的用法示例。
在下文中一共展示了IServiceCollection.ConfigureDataContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.ConfigureDataContext(Configuration);
// Register MyShuttle dependencies
services.ConfigureDependencies();
//Add Identity services to the services container
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<MyShuttleContext>()
.AddDefaultTokenProviders();
CookieServiceCollectionExtensions.ConfigureCookieAuthentication(services, options =>
{
options.LoginPath = new Microsoft.AspNet.Http.PathString("/Carrier/Login");
});
// Add MVC services to the services container
services.AddMvc();
services
.AddSignalR(options =>
{
options.Hubs.EnableDetailedErrors = true;
});
//Add InMemoryCache
services.AddSingleton<IMemoryCache, MemoryCache>();
}
示例2: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var useInMemoryStore = !_Platform.IsRunningOnWindows || _Platform.IsRunningOnMono || _Platform.IsRunningOnNanoServer;
services.ConfigureDataContext(Configuration, useInMemoryStore);
// Register dependencies
services.ConfigureDependencies(Configuration);
// Add Entity Framework services to the services container.
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<MyHealthContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
// Add MVC services to the services container.
services.AddMvc();
services.AddOptions();
services.Configure<DefaultUser>(Configuration.GetSection("DefaultUser"));
services.Configure<Office365Options>(Configuration.GetSection("Data:Office365"));
services.AddSingleton<IMemoryCache, MemoryCache>();
// Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
// You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
// services.AddWebApiConventions();
}
示例3: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var useInMemoryStore = !_Platform.IsRunningOnWindows || _Platform.IsRunningOnMono || _Platform.IsRunningOnNanoServer;
services.ConfigureDataContext(Configuration, useInMemoryStore);
// Register dependencies
services.ConfigureDependencies();
// Add Identity services to the services container.
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<MyHealthContext>()
.AddDefaultTokenProviders();
services.AddApplicationInsightsTelemetry(Configuration);
// Add MVC services to the services container.
services.AddMvc();
services.AddCaching();
services.AddSession();
services.AddAuthorization(Policies.Configuration);
}
示例4: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.ConfigureDataContext(Configuration);
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<MyShuttleContext>()
.AddDefaultTokenProviders();
services.ConfigureDependencies();
services.AddMvc();
}
示例5: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var useInMemoryStore = !_Platform.IsRunningOnWindows || _Platform.IsRunningOnMono || _Platform.IsRunningOnNanoServer;
services.ConfigureDataContext(Configuration, useInMemoryStore);
// Register dependencies
services.ConfigureDependencies();
// Add Identity services to the services container.
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<MyHealthContext>()
.AddDefaultTokenProviders();
services.AddApplicationInsightsTelemetry(Configuration);
// Add MVC services to the services container.
services.AddMvc();
services.AddCaching();
services.AddSession();
services.AddAuthorization(options =>
{
options.AddPolicy("Admin", policy =>
{
policy.RequireClaim("ManageUsers", "Allowed");
policy.RequireClaim("ManageTenants", "Allowed");
});
options.AddPolicy("Tenant", policy =>
{
policy.RequireClaim("ManageTenants", "Allowed");
});
});
}
示例6: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.ConfigureDataContext(Configuration);
services.ConfigureDependencies();
services.AddMvc();
}