Пример #1
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*/));
        }
Пример #2
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);
        }
Пример #3
0
        public static IEnumerable <string> GetDomainList(string configpath, string modulename)
        {
            StorageConfigurationSection section = GetSection(configpath);

            if (section == null)
            {
                throw new ArgumentException("config section not found");
            }
            return
                (section.Modules.Cast <ModuleConfigurationElement>().Where(
                     x => x.Name.Equals(modulename, StringComparison.OrdinalIgnoreCase)).Single().Domains.Cast
                 <DomainConfigurationElement>().Where(x => x.Visible).Select(x => x.Name));
        }
Пример #4
0
        private static IDataStore GetDataStore(string tenant, StorageConfigurationSection section, string module, HttpContext context, IQuotaController controller)
        {
            var moduleElement = section.Modules.GetModuleElement(module);

            if (moduleElement == null)
            {
                throw new ArgumentException("no such module");
            }

            var 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*/));
        }
Пример #5
0
        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);
        }
Пример #6
0
        public static IEnumerable <string> GetModuleList(string configpath)
        {
            StorageConfigurationSection section = GetSection(configpath);

            return(section.Modules.Cast <ModuleConfigurationElement>().Where(x => x.Visible).Select(x => x.Name));
        }