Пример #1
0
 private static void ConfigureCoreContextByUnity(object section)
 {
     if (((UnityConfigurationSection)section).Containers["Core"] != null)
     {
         var unity = new UnityContainer().LoadConfiguration("Core");
         if (unity.IsRegistered<CoreConfiguration>())
         {
             Configuration = unity.Resolve<CoreConfiguration>();
         }
         if (unity.IsRegistered<TenantManager>())
         {
             TenantManager = unity.Resolve<TenantManager>();
         }
         if (unity.IsRegistered<UserManager>())
         {
             UserManager = unity.Resolve<UserManager>();
         }
         if (unity.IsRegistered<AuthManager>())
         {
             Authentication = unity.Resolve<AuthManager>();
         }
         if (unity.IsRegistered<AuthorizationManager>())
         {
             AuthorizationManager = unity.Resolve<AuthorizationManager>();
         }
         if (unity.IsRegistered<SubscriptionManager>())
         {
             SubscriptionManager = unity.Resolve<SubscriptionManager>();
         }
     }
 }
Пример #2
0
        private static void ConfigureCoreContextByDefault()
        {
            var cs = DbRegistry.GetConnectionString("core");
            if (cs == null)
            {
                throw new ConfigurationErrorsException("Can not configure CoreContext: connection string with name core not found.");
            }

            var tenantService = new CachedTenantService(new DbTenantService(cs));
            var userService = new CachedUserService(new DbUserService(cs));
            var azService = new CachedAzService(new DbAzService(cs));
            var quotaService = new CachedQuotaService(new DbQuotaService(cs));
            var subService = new CachedSubscriptionService(new DbSubscriptionService(cs));
            var tariffService = new TariffService(cs, quotaService, tenantService);

            Configuration = new CoreConfiguration(tenantService);
            TenantManager = new TenantManager(tenantService, quotaService, tariffService);
            PaymentManager = new PaymentManager(Configuration, quotaService, tariffService);
            UserManager = new UserManager(userService);
            Authentication = new AuthManager(userService);
            AuthorizationManager = new AuthorizationManager(azService);
            SubscriptionManager = new SubscriptionManager(subService);
        }