private static IDataStore GetStoreAndCache(string tenant, string module, StorageConfigurationSection section, HttpContext context, IQuotaController controller) { IDataStore store = GetDataStore(tenant, section, module, context, controller); if (store != null) { DataStoreCache.Put(store, tenant, module); } return store; }
private static IDataStore GetDataStore(string tenant, StorageConfigurationSection section, string module, HttpContext context, IQuotaController controller) { ModuleConfigurationElement moduleElement = section.Modules.GetModuleElement(module); if (moduleElement == null) throw new ArgumentException("no such module"); HandlerConfigurationElement handler = section.Handlers.GetHandler(moduleElement.Type); return ((IDataStore) Activator.CreateInstance(handler.Type, tenant, moduleElement, context)).Configure( handler.GetProperties()).SetQuotaController(moduleElement.Count?controller:null/*don't count quota if specified on module*/); }
public static IDataStore GetStorage(string configpath, string tenant, string module, HttpContext context, IQuotaController controller) { if (tenant == null) tenant = DefaultTenantName; //Make tennant path tenant = TennantPath.CreatePath(tenant); IDataStore store = DataStoreCache.Get(tenant, module); if (store == null) { StorageConfigurationSection section = GetSection(configpath); if (section == null) throw new InvalidOperationException("config section not found"); store = GetStoreAndCache(tenant, module, section, context, controller); } return store; }
public IDataStore SetQuotaController(IQuotaController controller) { QuotaController = controller; return this; }
private static IDataStore GetDataStore(string tenant, StorageConfigurationSection section, string module, IQuotaController controller) { var moduleElement = section.Modules.GetModuleElement(module); if (moduleElement == null) { throw new ArgumentException("no such module", module); } var handler = section.Handlers.GetHandler(moduleElement.Type); return(((IDataStore)Activator.CreateInstance(handler.Type, tenant, handler, moduleElement)) .Configure(handler.GetProperties()) .SetQuotaController(moduleElement.Count ? controller : null /*don't count quota if specified on module*/)); }
private static IDataStore GetStoreAndCache(string tenant, string module, StorageConfigurationSection section, IQuotaController controller) { var store = GetDataStore(tenant, section, module, controller); if (store != null) { DataStoreCache.Put(store, tenant, module); } return(store); }
public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller) { if (tenant == null) { tenant = DefaultTenantName; } //Make tennant path tenant = TennantPath.CreatePath(tenant); var store = DataStoreCache.Get(tenant, module); if (store == null) { var section = GetSection(configpath); if (section == null) { throw new InvalidOperationException("config section not found"); } store = GetStoreAndCache(tenant, module, section, controller); } return(store); }
public IDataStore SetQuotaController(IQuotaController controller) { QuotaController = controller; return(this); }
private IDataStore GetDataStore(string tenant, string module, DataStoreConsumer consumer, IQuotaController controller) { var storage = StorageFactoryConfig.Section; var moduleElement = storage.GetModuleElement(module); if (moduleElement == null) { throw new ArgumentException("no such module", module); } var handler = storage.GetHandler(moduleElement.Type); Type instanceType; IDictionary <string, string> props; if (CoreBaseSettings.Standalone && !moduleElement.DisableMigrate && consumer.IsSet) { instanceType = consumer.HandlerType; props = consumer; } else { instanceType = Type.GetType(handler.Type, true); props = handler.Property.ToDictionary(r => r.Name, r => r.Value); } return(((IDataStore)Activator.CreateInstance(instanceType, TenantManager, PathUtils, EmailValidationKeyProvider, HttpContextAccessor, Options)) .Configure(tenant, handler, moduleElement, props) .SetQuotaController(moduleElement.Count ? controller : null /*don't count quota if specified on module*/)); }
private IDataStore GetStoreAndCache(string tenant, string module, DataStoreConsumer consumer, IQuotaController controller) { var store = GetDataStore(tenant, module, consumer, controller); if (store != null) { DataStoreCache.Put(store, tenant, module); } return(store); }
public IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller) { var tenantId = -2; if (string.IsNullOrEmpty(tenant)) { tenant = DefaultTenantName; } else { tenantId = Convert.ToInt32(tenant); } //Make tennant path tenant = TenantPath.CreatePath(tenant); //remove cache //var store = DataStoreCache.Get(tenant, module); //if (store == null) //{ var section = StorageFactoryConfig.Section; if (section == null) { throw new InvalidOperationException("config section not found"); } var settings = SettingsManager.LoadForTenant <StorageSettings>(tenantId); //} return(GetDataStore(tenant, module, StorageSettingsHelper.DataStoreConsumer(settings), controller)); }
public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller) { var tenantId = -2; if (string.IsNullOrEmpty(tenant)) { tenant = DefaultTenantName; } else { tenantId = Convert.ToInt32(tenant); } //Make tennant path tenant = TennantPath.CreatePath(tenant); var store = DataStoreCache.Get(tenant, module); if (store == null) { var section = GetSection(configpath); if (section == null) { throw new InvalidOperationException("config section not found"); } var settings = StorageSettings.LoadForTenant(tenantId); store = GetStoreAndCache(tenant, module, section, settings.DataStoreConsumer, controller); } return(store); }
private static IDataStore GetDataStore(string tenant, string module, StorageConfigurationSection section, DataStoreConsumer consumer, IQuotaController controller) { var moduleElement = section.Modules.GetModuleElement(module); if (moduleElement == null) { throw new ArgumentException("no such module", module); } var handler = section.Handlers.GetHandler(moduleElement.Type); Type instanceType; IDictionary <string, string> props; if (CoreContext.Configuration.Standalone && !moduleElement.DisabledMigrate && consumer.IsSet) { instanceType = consumer.HandlerType; props = consumer; } else { instanceType = handler.Type; props = handler.GetProperties(); } return(((IDataStore)Activator.CreateInstance(instanceType, tenant, handler, moduleElement)) .Configure(props) .SetQuotaController(moduleElement.Count ? controller : null /*don't count quota if specified on module*/)); }