Exemplo n.º 1
0
 public StorageWrapper(DataStoreConsumer consumer, StorageSettings current)
 {
     StorageWrapperInit(consumer, current);
 }
Exemplo n.º 2
0
        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*/));
        }
Exemplo n.º 3
0
        public IDataStore GetStorageFromConsumer(string configpath, string tenant, string module, DataStoreConsumer consumer)
        {
            if (tenant == null)
            {
                tenant = DefaultTenantName;
            }

            //Make tennant path
            tenant = TenantPath.CreatePath(tenant);

            var section = StorageFactoryConfig.Section;

            if (section == null)
            {
                throw new InvalidOperationException("config section not found");
            }

            int.TryParse(tenant, out var tenantId);
            return(GetDataStore(tenant, module, consumer, new TenantQuotaController(tenantId, TenantManager)));
        }
Exemplo n.º 4
0
        private static IDataStore GetStoreAndCache(string tenant, string module, StorageConfigurationSection section, DataStoreConsumer consumer, IQuotaController controller)
        {
            var store = GetDataStore(tenant, module, section, consumer, controller);

            if (store != null)
            {
                DataStoreCache.Put(store, tenant, module);
            }
            return(store);
        }