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


C# IServiceCollection.AddMultitenancy方法代码示例

本文整理汇总了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>();
        }
开发者ID:3arlN3t,项目名称:saaskit,代码行数:30,代码来源:Startup.cs

示例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());
            });


        }
开发者ID:joeaudette,项目名称:cloudscribe.Web.SimpleAuth,代码行数:22,代码来源:Startup.cs

示例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>();
        }
开发者ID:saaskit,项目名称:saaskit,代码行数:24,代码来源:Startup.cs

示例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>();
        }
开发者ID:HopeNB,项目名称:web,代码行数:32,代码来源:Startup.cs

示例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>();
 }
开发者ID:rdefreitas,项目名称:saaskit,代码行数:6,代码来源:Startup.cs

示例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()));
        }
开发者ID:SergiyTrygub,项目名称:mynotes,代码行数:27,代码来源:Startup.cs


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