本文整理汇总了C#中IServiceCollection.AddMultitenancy方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceCollection.AddMultitenancy方法的具体用法?C# IServiceCollection.AddMultitenancy怎么用?C# IServiceCollection.AddMultitenancy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceCollection
的用法示例。
在下文中一共展示了IServiceCollection.AddMultitenancy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMultitenancy<AppTenant, CachingAppTenantResolver>();
// Add framework services.
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddOptions();
services.AddMvc();
services.Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationExpanders.Add(new TenantViewLocationExpander());
});
services.Configure<MultitenancyOptions>(Configuration.GetSection("Multitenancy"));
// Add application services.
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
}
示例2: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<MultiTenancyOptions>(Configuration.GetSection("MultiTenancy"));
services.AddMultitenancy<AppTenant, CachingAppTenantResolver>();
services.Configure<SimpleAuthSettings>(Configuration.GetSection("SimpleAuthSettings"));
services.AddScoped<IUserLookupProvider, AppTenantUserLookupProvider>();
services.Configure<List<SimpleAuthUser>>(Configuration.GetSection("Users"));
services.AddScoped<IPasswordHasher<SimpleAuthUser>, PasswordHasher<SimpleAuthUser>>();
services.AddScoped<IAuthSettingsResolver, AppTenantAuthSettingsResolver>();
services.AddScoped<SignInManager, SignInManager>();
services.AddMvc();
services.Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationExpanders.Add(new TenantViewLocationExpander());
});
}
示例3: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMultitenancy<AppTenant, AppTenantResolver>();
var container = new Container();
container.Populate(services);
container.Configure(c =>
{
// Application Services
// c.For<ITenantContainerBuilder<AppTenant>>().Use(() => new AppTenantContainerBuilder(container));
});
container.ConfigureTenants<AppTenant>(c =>
{
// Tenant Scoped Services
c.For<IMessageService>().Singleton().Use<MessageService>();
});
return container.GetInstance<IServiceProvider>();
}
示例4: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddOptions();
services.AddSingleton<IConfigurationRoot>(Configuration);
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddAuthentication(Configuration);
services.Configure<PayPalClientSettings>(Configuration.GetSection("PayPalClientSettings"));
services.AddSingleton<PayPalClient>();
services.AddLogging();
services.AddMvc();
// register document store
var store = DocumentStore.For(_ =>
{
_.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate;
_.Connection(Configuration.GetConnectionString("HopeNB"));
AsyncSessionFactory.Register(_);
});
store.Schema.ApplyAllConfiguredChangesToDatabase();
services.AddSingleton<IDocumentStore>(store);
AsyncSessionFactory.DocumentStore = store;
services.AddDistributedMemoryCache();
services.AddMultitenancy<Organization, CachingOrganizationResolver>();
}
示例5: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddMultitenancy<AppTenant, CachingAppTenantResolver>();
}
示例6: ConfigureServices
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddLogging();
//services.AddGlimpse();
services.AddDbContext<MyWishesDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddMultitenancy<MultiTenancyResolver>().Configure<MultiTenancyOptions>(opt =>
{
opt.Resolvers.Add(new UrlTenantResolver() { TenantsSources = new[] { new MemoryTenantsSource() } });
});
services.AddMvc(options => {
var formatter = new JsonOutputFormatter
{
SerializerSettings = { ContractResolver = new CamelCasePropertyNamesContractResolver() }
};
options.OutputFormatters.Insert(0, formatter);
});
services.AddMyWishesDbContext();
services.AddTransient<ITenantsService, TenantsService>();
services.AddTransient<IWishDaysService, WishDaysService>();
services.AddTransient<IWishItemsService, WishItemsService>();
//services.AddTransient<IUserContextService>(new FakeUserContextService(Guid.NewGuid()));
}