Represents the minimalistic set of fields stored for each tenant. This model is obtained from the IShellSettingsManager, which by default reads this from the App_Data settings.txt files.
示例#1
1
        public void Init() {
            _settingsA = new ShellSettings { Name = "Alpha" };
            _settingsB = new ShellSettings { Name = "Beta", };
            _routes = new RouteCollection();

            var rootBuilder = new ContainerBuilder();
            rootBuilder.Register(ctx => _routes);
            rootBuilder.RegisterType<ShellRoute>().InstancePerDependency();
            rootBuilder.RegisterType<RunningShellTable>().As<IRunningShellTable>().SingleInstance();
            rootBuilder.RegisterModule(new WorkContextModule());
            rootBuilder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
            rootBuilder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>();
            rootBuilder.RegisterType<ExtensionManager>().As<IExtensionManager>();
            rootBuilder.RegisterType<StubCacheManager>().As<ICacheManager>();
            rootBuilder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
            rootBuilder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();

            _rootContainer = rootBuilder.Build();

            _containerA = _rootContainer.BeginLifetimeScope(
                "shell",
                builder => {
                    builder.Register(ctx => _settingsA);
                    builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerMatchingLifetimeScope("shell");
                });

            _containerB = _rootContainer.BeginLifetimeScope(
                "shell",
                builder => {
                    builder.Register(ctx => _settingsB);
                    builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerMatchingLifetimeScope("shell");
                });
        }
        public RemoteStorageProvider(ShellSettings settings, IOrchardServices orchardServices) {
            _settings = settings;
            _orchardServices = orchardServices;


            T = NullLocalizer.Instance;
        }
        public SessionFactoryHolderFactory(
            ShellSettings shellSettings,
            ShellBlueprint shellBlueprint,
            IDataServicesProviderFactory dataServicesProviderFactory,
            IAppDataFolder appDataFolder,
            ISessionConfigurationCache sessionConfigurationCache,
            IHostEnvironment hostEnvironment,
            IDatabaseCacheConfiguration cacheConfiguration,
            Func<IEnumerable<ISessionConfigurationEvents>> configurers,
            IRepository<ConnectionsRecord> connectionsRecordRepository,
            IEncryptionService encryptionService,
            ICacheManager cacheManager)
        {
            _shellSettings = shellSettings;
            _shellBlueprint = shellBlueprint;
            _dataServicesProviderFactory = dataServicesProviderFactory;
            _appDataFolder = appDataFolder;
            _sessionConfigurationCache = sessionConfigurationCache;
            _hostEnvironment = hostEnvironment;
            _cacheConfiguration = cacheConfiguration;
            _configurers = configurers;
            _connectionsRecordRepository = connectionsRecordRepository;
            _encryptionService = encryptionService;
            _cacheManager = cacheManager;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }
 public void DefaultShellMatchesByDefault() {
     var table = (IRunningShellTable)new RunningShellTable();
     var settings = new ShellSettings { Name = "Default" };
     table.Add(settings);
     var match = table.Match(new StubHttpContext());
     Assert.That(match, Is.SameAs(settings));
 }
示例#5
0
        public AdminUserController(
            IRepository<RoleRecord> roleRepository,
            IOrderService orderService,
            ICampaignService campaignService,
            IRepository<CurrencyRecord> currencyRepository,
            IMembershipService membershipService,
            ShellSettings shellSettings,
            IOrchardServices services,
            IUserService userService,
            ISiteService siteService,
            IShapeFactory shapeFactory)
        {
            _roleRepository = roleRepository;
            _orderService = orderService;
            _campaignService = campaignService;
            _currencyRepository = currencyRepository;
            _membershipService = membershipService;
            _shellSettings = shellSettings;
            Services = services;
            _siteService = siteService;
            _userService = userService;

            T = NullLocalizer.Instance;
            Shape = shapeFactory;
        }
 public GlobalSetupShellEventHandler(
     ShellSettings shellSettings,
     IWorkContextAccessor wca)
 {
     _shellSettings = shellSettings;
     _wca = wca;
 }
        public static ShellSettings ParseSettings(string text) {
            var shellSettings = new ShellSettings();
            if (String.IsNullOrEmpty(text))
                return shellSettings;

            var settings = new StringReader(text);
            string setting;
            while ((setting = settings.ReadLine()) != null) {
                if (string.IsNullOrWhiteSpace(setting)) continue; ;
                var separatorIndex = setting.IndexOf(Separator);
                if (separatorIndex == -1) {
                    continue;
                }
                string key = setting.Substring(0, separatorIndex).Trim();
                string value = setting.Substring(separatorIndex + 1).Trim();

                if (value != EmptyValue) {
                    switch (key) {
                        case "Name":
                            shellSettings.Name = value;
                            break;
                        case "DataProvider":
                            shellSettings.DataProvider = value;
                            break;
                        case "State":
                            shellSettings.State = new TenantState(value);
                            break;
                        case "DataConnectionString":
                            shellSettings.DataConnectionString = value;
                            break;
                        case "DataPrefix":
                            shellSettings.DataTablePrefix = value;
                            break;
                        case "RequestUrlHost":
                            shellSettings.RequestUrlHost = value;
                            break;
                        case "RequestUrlPrefix":
                            shellSettings.RequestUrlPrefix = value;
                            break;
                        case "EncryptionAlgorithm":
                            shellSettings.EncryptionAlgorithm = value;
                            break;
                        case "EncryptionKey":
                            shellSettings.EncryptionKey = value;
                            break;
                        case "HashAlgorithm":
                            shellSettings.HashAlgorithm = value;
                            break;
                        case "HashKey":
                            shellSettings.HashKey = value;
                            break;
                        case "Themes":
                            shellSettings.Themes = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            break;
                    }
                }
            }

            return shellSettings;
        }
示例#8
0
        public WarmupReportManager(
            ShellSettings shellSettings,
            IAppDataFolder appDataFolder) {
            _appDataFolder = appDataFolder;

            _warmupReportPath = _appDataFolder.Combine("Sites", _appDataFolder.Combine(shellSettings.Name, WarmupReportFilename));
        }
        private void Organize() {
            var qualified =
                _shells.Where(x => !string.IsNullOrEmpty(x.RequestUrlHost) || !string.IsNullOrEmpty(x.RequestUrlPrefix));

            var unqualified =
                _shells.Where(x => string.IsNullOrEmpty(x.RequestUrlHost) && string.IsNullOrEmpty(x.RequestUrlPrefix));

            _shellsByHost = qualified
                .GroupBy(s => s.RequestUrlHost ?? "")
                .OrderByDescending(g => g.Key.Length);

            if (unqualified.Count() == 1) {
                // only one shell had no request url criteria
                _fallback = unqualified.Single();
            }
            else if (unqualified.Any()) {
                // two or more shells had no request criteria. 
                // this is technically a misconfiguration - so fallback to the default shell
                // if it's one which will catch all requests
                _fallback = unqualified.SingleOrDefault(x => x.Name == ShellSettings.DefaultName);
            }
            else {
                // no shells are unqualified - a request that does not match a shell's spec
                // will not be mapped to routes coming from orchard
                _fallback = null;
            }
        }
示例#10
0
 public AdminController(ITenantService tenantService, IOrchardServices orchardServices, ShellSettings shellSettings) {
     _tenantService = tenantService;
     _thisShellSettings = shellSettings;
     
     Services = orchardServices;
     T = NullLocalizer.Instance;
 }
        public RedisOutputCacheStorageProvider(ShellSettings shellSettings, IRedisConnectionProvider redisConnectionProvider) {
            _shellSettings = shellSettings;
            _redisConnectionProvider = redisConnectionProvider;
            _connectionString = _redisConnectionProvider.GetConnectionString(ConnectionStringKey);

            Logger = NullLogger.Instance;
        }
        public string TenantUrl(ShellSettings tenantShellSettings)
        {
            string result = null;
            if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost))
            {
                var tenantHosts = tenantShellSettings.RequestUrlHost.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (tenantHosts.Length > 0)
                {
                    // need to pick suitable host
                    //result = string.Format("//{0}", tenantHosts[0]);
                    result = string.Format("{0}://{1}", _urlHelper.RequestContext.HttpContext.Request.Url.Scheme, tenantHosts[0]);
                }
            }
            
            if(result == null)
            {
                var defaultWorkContext = _twca.GetContext(ShellSettings.DefaultName);
                result = defaultWorkContext.CurrentSite.BaseUrl;
            }

            //application path alwayes in result ???
            //var applicationPath = _urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
            //if (!string.IsNullOrEmpty(applicationPath) && !string.Equals(applicationPath, "/"))
            //    result += applicationPath;

            if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
                result += "/" + tenantShellSettings.RequestUrlPrefix;

            return result;
        }
示例#13
0
        public AdminController(
            IEnumerable<IExtensionDisplayEventHandler> extensionDisplayEventHandlers,
            IOrchardServices services,
            IDataMigrationManager dataMigraitonManager,
            IFeatureManager featureManager,
            ISiteThemeService siteThemeService,
            IExtensionManager extensionManager,
            ShellDescriptor shellDescriptor,
            IPreviewTheme previewTheme, 
            IThemeService themeService,
            ShellSettings shellSettings) {
            Services = services;

            _extensionDisplayEventHandler = extensionDisplayEventHandlers.FirstOrDefault();
            _dataMigrationManager = dataMigraitonManager;
            _siteThemeService = siteThemeService;
            _extensionManager = extensionManager;
            _shellDescriptor = shellDescriptor;
            _featureManager = featureManager;
            _previewTheme = previewTheme;
            _themeService = themeService;
            _shellSettings = shellSettings;
            
            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }
        public void NormalExecutionReturnsExpectedObjects() {
            var settings = new ShellSettings { Name = "Default" };
            var topologyDescriptor = new ShellDescriptor { SerialNumber = 6655321 };
            var topology = new ShellTopology();
            var shellLifetimeScope = _container.BeginLifetimeScope("shell");

            _container.Mock<IShellDescriptorCache>()
                .Setup(x => x.Fetch("Default"))
                .Returns(topologyDescriptor);

            _container.Mock<ICompositionStrategy>()
                .Setup(x => x.Compose(settings, topologyDescriptor))
                .Returns(topology);

            _container.Mock<IShellContainerFactory>()
                .Setup(x => x.CreateContainer(settings, topology))
                .Returns(shellLifetimeScope);

            _container.Mock<IShellDescriptorManager>()
                .Setup(x => x.GetShellDescriptor())
                .Returns(topologyDescriptor);

            var factory = _container.Resolve<IShellContextFactory>();

            var context = factory.CreateShellContext(settings);

            Assert.That(context.Settings, Is.SameAs(settings));
            Assert.That(context.Descriptor, Is.SameAs(topologyDescriptor));
            Assert.That(context.Topology, Is.SameAs(topology));
            Assert.That(context.LifetimeScope, Is.SameAs(shellLifetimeScope));
            Assert.That(context.Shell, Is.SameAs(shellLifetimeScope.Resolve<IOrchardShell>()));
        }
        public ThumbnailsService(ShellSettings settings, IWorkContextAccessor wca, ICacheManager cacheManager, IMediaService mediaService, ISignals signals, IStorageProvider storageProvider)
        {
            _wca = wca;
            _cacheManager = cacheManager;
            _mediaService = mediaService;
            _signals = signals;
            _storageProvider = storageProvider;
            var appPath = "";
            if (HostingEnvironment.IsHosted)
            {
                appPath = HostingEnvironment.ApplicationVirtualPath;
            }
            if (!appPath.EndsWith("/"))
                appPath = appPath + '/';
            if (!appPath.StartsWith("/"))
                appPath = '/' + appPath;

            _publicPath = appPath + "Media/" + settings.Name + "/";

            var physPath = ThumbnailsCacheMediaPath.Replace('/', Path.DirectorySeparatorChar);
            var parent = Path.GetDirectoryName(physPath);
            var folder = Path.GetFileName(physPath);
            if (_mediaService.GetMediaFolders(parent).All(f => f.Name != folder))
            {
                _mediaService.CreateFolder(parent, folder);
            }
        }
示例#16
0
        public CASClient(
            ShellSettings settings, 
            ITicketValidatorFactory ticketValidatorFactory,
            IRequestEvaluator requestEvaluator,
            IClock clock,
            IUrlUtil urlUtil,
            IAuthenticationService authenticationService,
            ICasServices casServices) {
            _settings = settings;
            _ticketValidatorFactory = ticketValidatorFactory;
            _requestEvaluator = requestEvaluator;
            _clock = clock;
            _urlUtil = urlUtil;
            _authenticationService = authenticationService;
            _casServices = casServices;

            _xmlNamespaceManager = new XmlNamespaceManager(_xmlNameTable);
            _xmlNamespaceManager.AddNamespace("cas", "http://www.yale.edu/tp/cas");
            _xmlNamespaceManager.AddNamespace("saml", "urn: oasis:names:tc:SAML:1.0:assertion");
            _xmlNamespaceManager.AddNamespace("saml2", "urn: oasis:names:tc:SAML:1.0:assertion");
            _xmlNamespaceManager.AddNamespace("samlp", "urn: oasis:names:tc:SAML:1.0:protocol");

            Logger = NullLogger.Instance;
            T = NullLocalizer.Instance;
        }
        public AzureOutputCacheStorageProvider(ShellSettings shellSettings, IAzureOutputCacheHolder cacheHolder) {

            var region = shellSettings.Name;

            // Azure Cache supports only alphanumeric strings for regions, but Orchard supports some
            // non-alphanumeric characters in tenant names. Remove all non-alphanumering characters
            // from the region, and append the hash code of the original string to mitigate the risk
            // of two distinct original region strings yielding the same transformed region string.
            _regionAlphaNumeric = new String(Array.FindAll(region.ToCharArray(), Char.IsLetterOrDigit)) + region.GetHashCode().ToString(CultureInfo.InvariantCulture);


            _cache = cacheHolder.TryGetDataCache(() => {
                CacheClientConfiguration cacheConfig;

                try {
                    cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings.Name, Constants.OutputCacheSettingNamePrefix);
                    cacheConfig.Validate();
                }
                catch (Exception ex) {
                    throw new Exception(String.Format("The {0} configuration settings are missing or invalid.", Constants.OutputCacheFeatureName), ex);
                }

                var cache = cacheConfig.CreateCache();
                cache.CreateRegion(_regionAlphaNumeric);

                return cache;
            });
        }
示例#18
0
 public UsersService(
     IContentManager contentManager, 
     IOrchardServices orchardServices, 
     IRoleService roleService, 
     IMessageManager messageManager, 
     IScheduledTaskManager taskManager, 
     IRepository<EmailPartRecord> emailRepository, 
     ShellSettings shellSettings, 
     IRepository<UserRolesPartRecord> userRolesRepository, 
     ICacheManager cache, 
     IClock clock, 
     ISignals signals) 
 {
     _signals = signals;
     _clock = clock;
     _cache = cache;
     _emailRepository = emailRepository;
     _orchardServices = orchardServices;
     _contentManager = contentManager;
     _roleService = roleService;
     _messageManager = messageManager;
     _taskManager = taskManager;
     _shellSettings = shellSettings;
     _userRolesRepository = userRolesRepository;
     T = NullLocalizer.Instance;
     Logger = NullLogger.Instance;            
 }
示例#19
0
 public CookieCultureSelector(IHttpContextAccessor httpContextAccessor,
     IClock clock,
     ShellSettings shellSettings) {
     _httpContextAccessor = httpContextAccessor;
     _clock = clock;
     _shellSettings = shellSettings;
 }
示例#20
0
        public ExecuteRecipeAction(
            IOrchardServices orchardServices,
            ISetupService setupService,
            ShellSettings shellSettings,
            IEnumerable<IRecipeExecutionStep> recipeExecutionSteps,
            IRecipeParser recipeParser,
            IRecipeExecutor recipeExecutor,
            IDatabaseManager databaseManager,
            ISweepGenerator sweepGenerator,
            IRecipeStepQueue recipeStepQueue,
            IRepository<RecipeStepResultRecord> recipeStepResultRepository)
        {
            _orchardServices = orchardServices;
            _setupService = setupService;
            _shellSettings = shellSettings;
            _recipeExecutionSteps = recipeExecutionSteps;
            _recipeParser = recipeParser;
            _recipeExecutor = recipeExecutor;
            _databaseManager = databaseManager;
            _sweepGenerator = sweepGenerator;
            _recipeStepQueue = recipeStepQueue;
            _recipeStepResultRepository = recipeStepResultRepository;

            RecipeExecutionTimeout = 600;
        }
示例#21
0
        public LastSynchronizedDate(IAppDataFolder appDataFolder, ShellSettings shellSettings) {
            _appDataFolder = appDataFolder;
            _shellSettings = shellSettings;

            _basePath = _appDataFolder.Combine("Sites", _shellSettings.Name, "Packages");
            CreateBaseDirectoryIfItDoesNotExist();
        }
示例#22
0
        public void Remove(ShellSettings settings) {
            _shells = _shells
                .Where(s => s.Name != settings.Name)
                .ToArray();

            Organize();
        }
示例#23
0
 public IEnumerable<string> GetTenantDatabaseTableNames(ShellSettings settings) {
     IEnumerable<string> result = null;
     ExecuteOnTenantScope(settings, environment => {
         result = GetTenantDatabaseTableNames(environment);
     });
     return result;
 }
        public TermsPartHandler(
            IContentDefinitionManager contentDefinitionManager,
            IRepository<TermsPartRecord> repository,
            ITaxonomyService taxonomyService,
            IContentManager contentManager,
            IProcessingEngine processingEngine,
            ShellSettings shellSettings,
            IShellDescriptorManager shellDescriptorManager) {
            _contentDefinitionManager = contentDefinitionManager;
            _contentManager = contentManager;

            Filters.Add(StorageFilter.For(repository));
            OnPublished<TermsPart>((context, part) => RecalculateCount(processingEngine, shellSettings, shellDescriptorManager, part));
            OnUnpublished<TermsPart>((context, part) => RecalculateCount(processingEngine, shellSettings, shellDescriptorManager, part));
            OnRemoved<TermsPart>((context, part) => RecalculateCount(processingEngine, shellSettings, shellDescriptorManager, part));

            // Tells how to load the field terms on demand, when a content item it loaded or when it has been created
            OnInitialized<TermsPart>((context, part) => InitializerTermsLoader(part));
            OnLoading<TermsPart>((context, part) => InitializerTermsLoader(part));
            OnUpdating<TermsPart>((context, part) => InitializerTermsLoader(part));

            OnIndexing<TermsPart>(
                (context, part) => {

                    foreach (var term in part.Terms) {
                        var termContentItem = context.ContentManager.Get(term.TermRecord.Id);
                        context.DocumentIndex.Add(term.Field, termContentItem.As<TitlePart>().Title).Analyze();
                        context.DocumentIndex.Add(term.Field + "-id", termContentItem.Id).Store();
                        // tag the current content item with all parent terms
                        foreach (var parent in taxonomyService.GetParents(termContentItem.As<TermPart>())) {
                            context.DocumentIndex.Add(term.Field + "-id", parent.Id).Store();
                        }
                    }
                });
        }
示例#25
0
        public void FactoryMethodWillCreateShellRoutes() {
            var settings = new ShellSettings { Name = "Alpha" };
            var builder = new ContainerBuilder();
            builder.RegisterType<ShellRoute>().InstancePerDependency();
            builder.RegisterAutoMocking();
            builder.Register(ctx => settings);

            var container = builder.Build();
            var buildShellRoute = container.Resolve<Func<RouteBase, ShellRoute>>();

            var routeA = new Route("foo", new MvcRouteHandler());
            var route1 = buildShellRoute(routeA);

            var routeB = new Route("bar", new MvcRouteHandler()) {
                DataTokens = new RouteValueDictionary { { "area", "Beta" } }
            };
            var route2 = buildShellRoute(routeB);

            Assert.That(route1, Is.Not.SameAs(route2));

            Assert.That(route1.ShellSettingsName, Is.EqualTo("Alpha"));
            Assert.That(route1.Area, Is.Null);

            Assert.That(route2.ShellSettingsName, Is.EqualTo("Alpha"));
            Assert.That(route2.Area, Is.EqualTo("Beta"));
        }
示例#26
0
        public AdminController(
            IEnumerable<IExtensionDisplayEventHandler> extensionDisplayEventHandlers,
            IOrchardServices services,
            IModuleService moduleService,
            IDataMigrationManager dataMigrationManager,
            IReportsCoordinator reportsCoordinator,
            IExtensionManager extensionManager,
            IFeatureManager featureManager,
            IRecipeHarvester recipeHarvester,
            IRecipeManager recipeManager,
            ShellDescriptor shellDescriptor,
            ShellSettings shellSettings,
            IShapeFactory shapeFactory)
        {
            Services = services;
            _extensionDisplayEventHandler = extensionDisplayEventHandlers.FirstOrDefault();
            _moduleService = moduleService;
            _dataMigrationManager = dataMigrationManager;
            _reportsCoordinator = reportsCoordinator;
            _extensionManager = extensionManager;
            _featureManager = featureManager;
            _recipeHarvester = recipeHarvester;
            _recipeManager = recipeManager;
            _shellDescriptor = shellDescriptor;
            _shellSettings = shellSettings;
            Shape = shapeFactory;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }
        public OutputCacheFilter(
            ICacheManager cacheManager,
            IOutputCacheStorageProvider cacheStorageProvider,
            ITagCache tagCache,
            IDisplayedContentItemHandler displayedContentItemHandler,
            IWorkContextAccessor workContextAccessor,
            IThemeManager themeManager,
            IClock clock,
            ICacheService cacheService,
            ISignals signals,
            ShellSettings shellSettings) {

            _cacheManager = cacheManager;
            _cacheStorageProvider = cacheStorageProvider;
            _tagCache = tagCache;
            _displayedContentItemHandler = displayedContentItemHandler;
            _workContextAccessor = workContextAccessor;
            _themeManager = themeManager;
            _clock = clock;
            _cacheService = cacheService;
            _signals = signals;
            _shellSettings = shellSettings;

            Logger = NullLogger.Instance;
        }
示例#28
0
        public IStandaloneEnvironment FindOrCreateTenant(string tenant)
        {
            IStandaloneEnvironment result;
            if (_tenants.TryGetValue(tenant, out result))
                return result;

            var host = _hostContainer.Resolve<IOrchardHost>();
            var tenantManager = _hostContainer.Resolve<IShellSettingsManager>();

            // Retrieve settings for speficified tenant.
            var settingsList = tenantManager.LoadSettings();
            if (settingsList.Any()) {
                var settings = settingsList.SingleOrDefault(s => String.Equals(s.Name, tenant, StringComparison.OrdinalIgnoreCase));
                if (settings == null) {
                    throw new OrchardException(string.Format("Tenant {0} does not exist", tenant));
                }

                var env = host.CreateStandaloneEnvironment(settings);

                // Store in cache for next calls
                _tenants.Add(tenant, env);
                return env;
            }
            else {
                // In case of an unitiliazed site (no default settings yet), we create a default settings instance.
                var settings = new ShellSettings {Name = "Default", State = new TenantState("Uninitialized")};
                return host.CreateStandaloneEnvironment(settings);
            }
        }
示例#29
0
        private void Organize() {
            var qualified =
                _shells.Where(x => !string.IsNullOrEmpty(x.RequestUrlHost) || !string.IsNullOrEmpty(x.RequestUrlPrefix));

            var unqualified = _shells
                .Where(x => string.IsNullOrEmpty(x.RequestUrlHost) && string.IsNullOrEmpty(x.RequestUrlPrefix))
                .ToList();

            _shellsByHost = qualified
                .SelectMany(s => s.RequestUrlHost == null || s.RequestUrlHost.IndexOf(',') == -1 ? new[] {s} : 
                    s.RequestUrlHost.Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries)
                     .Select(h => new ShellSettings(s) {RequestUrlHost = h}))
                .GroupBy(s => s.RequestUrlHost ?? string.Empty)
                .OrderByDescending(g => g.Key.Length);

            if (unqualified.Count() == 1) {
                // only one shell had no request url criteria
                _fallback = unqualified.Single();
            }
            else if (unqualified.Any()) {
                // two or more shells had no request criteria. 
                // this is technically a misconfiguration - so fallback to the default shell
                // if it's one which will catch all requests
                _fallback = unqualified.SingleOrDefault(x => x.Name == ShellSettings.DefaultName);
            }
            else {
                // no shells are unqualified - a request that does not match a shell's spec
                // will not be mapped to routes coming from orchard
                _fallback = null;
            }
        }
 public AppConfigurationAccessor(ShellSettings shellSettings)
 {
     _shellSettings = shellSettings;
 }
示例#31
0
        public static ShellSettings ParseSettings(string text)
        {
            var shellSettings = new ShellSettings();

            if (String.IsNullOrEmpty(text))
            {
                return(shellSettings);
            }

            var    settings = new StringReader(text);
            string setting;

            while ((setting = settings.ReadLine()) != null)
            {
                if (string.IsNullOrWhiteSpace(setting))
                {
                    continue;
                }
                ;
                var separatorIndex = setting.IndexOf(Separator);
                if (separatorIndex == -1)
                {
                    continue;
                }
                string key   = setting.Substring(0, separatorIndex).Trim();
                string value = setting.Substring(separatorIndex + 1).Trim();

                if (value != EmptyValue)
                {
                    switch (key)
                    {
                    case "Name":
                        shellSettings.Name = value;
                        break;

                    case "DataProvider":
                        shellSettings.DataProvider = value;
                        break;

                    case "State":
                        shellSettings.State = new TenantState(value);
                        break;

                    case "DataConnectionString":
                        shellSettings.DataConnectionString = value;
                        break;

                    case "DataPrefix":
                        shellSettings.DataTablePrefix = value;
                        break;

                    case "RequestUrlHost":
                        shellSettings.RequestUrlHost = value;
                        break;

                    case "RequestUrlPrefix":
                        shellSettings.RequestUrlPrefix = value;
                        break;

                    case "EncryptionAlgorithm":
                        shellSettings.EncryptionAlgorithm = value;
                        break;

                    case "EncryptionKey":
                        shellSettings.EncryptionKey = value;
                        break;

                    case "HashAlgorithm":
                        shellSettings.HashAlgorithm = value;
                        break;

                    case "HashKey":
                        shellSettings.HashKey = value;
                        break;

                    case "Themes":
                        shellSettings.Themes = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }

            return(shellSettings);
        }
        public static ShellSettings ParseSettings(string text)
        {
            var shellSettings = new ShellSettings();

            if (String.IsNullOrEmpty(text))
            {
                return(shellSettings);
            }

            var    settings = new StringReader(text);
            string setting;

            while ((setting = settings.ReadLine()) != null)
            {
                if (string.IsNullOrWhiteSpace(setting))
                {
                    continue;
                }
                var separatorIndex = setting.IndexOf(Separator);
                if (separatorIndex == -1)
                {
                    continue;
                }
                string key   = setting.Substring(0, separatorIndex).Trim();
                string value = setting.Substring(separatorIndex + 1).Trim();

                if (!value.Equals(EmptyValue, StringComparison.OrdinalIgnoreCase))
                {
                    switch (key)
                    {
                    case "Name":
                        shellSettings.Name = value;
                        break;

                    case "DataProvider":
                        shellSettings.DataProvider = value;
                        break;

                    case "State":
                        TenantState state;
                        shellSettings.State = Enum.TryParse(value, true, out state) ? state : TenantState.Uninitialized;
                        break;

                    case "DataConnectionString":
                        shellSettings.DataConnectionString = value;
                        break;

                    case "DataPrefix":
                        shellSettings.DataTablePrefix = value;
                        break;

                    case "RequestUrlHost":
                        shellSettings.RequestUrlHost = value;
                        break;

                    case "RequestUrlPrefix":
                        shellSettings.RequestUrlPrefix = value;
                        break;

                    case "EncryptionAlgorithm":
                        shellSettings.EncryptionAlgorithm = value;
                        break;

                    case "EncryptionKey":
                        shellSettings.EncryptionKey = value;
                        break;

                    case "HashAlgorithm":
                        shellSettings.HashAlgorithm = value;
                        break;

                    case "HashKey":
                        shellSettings.HashKey = value;
                        break;

                    case "Themes":
                        shellSettings.Themes = value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        break;

                    default:
                        shellSettings[key] = value;
                        break;
                    }
                }
            }

            return(shellSettings);
        }
        public CustomSessionFactoryHolder(
            ShellSettings shellSettings,
            ShellBlueprint shellBlueprint,
            IDataServicesProviderFactory dataServicesProviderFactory,
            IAppDataFolder appDataFolder,
            ISessionConfigurationCache sessionConfigurationCache,
            IHostEnvironment hostEnvironment,
            IDatabaseCacheConfiguration cacheConfiguration,
            Func<IEnumerable<ISessionConfigurationEvents>> configurers,
            string provider,
            string connectionString
            )
        {
            _shellSettings = shellSettings;
            _shellBlueprint = shellBlueprint;
            _dataServicesProviderFactory = dataServicesProviderFactory;
            _appDataFolder = appDataFolder;
            _sessionConfigurationCache = sessionConfigurationCache;
            _hostEnvironment = hostEnvironment;
            _cacheConfiguration = cacheConfiguration;
            _configurers = configurers;

            _provider = provider;
            _connectionString = connectionString;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }