Example #1
0
        public void ListSubdirectoriesShouldContainFullSubpath()
        {
            var files = _appDataFolder.ListDirectories("alpha").Select(x => x.Name);

            Assert.Equal(1, files.Count());
            Assert.Contains("omega", files);
        }
        public void ListSubdirectoriesShouldContainFullSubpath()
        {
            var files = _appDataFolder.ListDirectories("alpha");

            Assert.That(files.Count(), Is.EqualTo(1));
            Assert.That(files, Has.Some.EqualTo("alpha/omega"));
        }
Example #3
0
        public void ListSubdirectoriesShouldContainFullSubpath()
        {
            var files = _appDataFolder.ListDirectories("alpha");

            Assert.Equal(files.Count(), 1);
            Assert.Contains(files, t => t.Equals("alpha/omega"));
        }
Example #4
0
        IEnumerable <ShellSettings> IShellSettingsManager.LoadSettings()
        {
            var filePaths = _appDataFolder
                            .ListDirectories("Sites")
                            .SelectMany(path => _appDataFolder.ListFiles(path))
                            .Where(path => {
                var filePathName = Path.GetFileName(path);

                return(_settingFileNameExtensions.Any(p =>
                                                      string.Equals(filePathName, string.Format(_settingsFileNameFormat, p), StringComparison.OrdinalIgnoreCase)
                                                      ));
            });

            List <ShellSettings> shellSettings = new List <ShellSettings>();

            foreach (var filePath in filePaths)
            {
                IConfigurationSourceContainer configurationContainer = null;

                var extension = Path.GetExtension(filePath);

                switch (extension)
                {
                case ".json":
                    configurationContainer = new Microsoft.Framework.ConfigurationModel.Configuration()
                                             .AddJsonFile(filePath);
                    break;

                case ".xml":
                    configurationContainer = new Microsoft.Framework.ConfigurationModel.Configuration()
                                             .AddXmlFile(filePath);
                    break;

                case ".ini":
                    configurationContainer = new Microsoft.Framework.ConfigurationModel.Configuration()
                                             .AddIniFile(filePath);
                    break;

                case ".txt":
                    configurationContainer = new Microsoft.Framework.ConfigurationModel.Configuration()
                                             .Add(new DefaultFileConfigurationSource(_appDataFolder, filePath));
                    break;
                }

                if (configurationContainer != null)
                {
                    var shellSetting = new ShellSettings {
                        Name             = configurationContainer.Get <string>("Name"),
                        RequestUrlPrefix = configurationContainer.Get <string>("RequestUrlPrefix")
                    };

                    TenantState state;
                    shellSetting.State = Enum.TryParse(configurationContainer.Get <string>("State"), true, out state) ? state : TenantState.Uninitialized;

                    shellSettings.Add(shellSetting);
                }
            }

            return(shellSettings);
        }
        IEnumerable <ShellSettings> IShellSettingsManager.LoadSettings()
        {
            var shellSettings = new List <ShellSettings>();

            foreach (var tenant in _appDataFolder.ListDirectories("Sites"))
            {
                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("ShellSettings found in '{0}', attempting to load.", tenant.Name);
                }
                var configurationContainer =
                    new ConfigurationBuilder()
                    .AddJsonFile(_appDataFolder.Combine(tenant.PhysicalPath, string.Format(SettingsFileNameFormat, "json")),
                                 true)
                    .AddXmlFile(_appDataFolder.Combine(tenant.PhysicalPath, string.Format(SettingsFileNameFormat, "xml")),
                                true)
                    .AddYamlFile(_appDataFolder.Combine(tenant.PhysicalPath, string.Format(SettingsFileNameFormat, "txt")),
                                 false);

                var config = configurationContainer.Build();

                var shellSetting = new ShellSettings(config);
                shellSettings.Add(shellSetting);

                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("Loaded ShellSettings for tenant '{0}'", shellSetting.Name);
                }
            }

            return(shellSettings);
        }
Example #6
0
        IEnumerable <ShellSettings> IShellSettingsManager.LoadSettings()
        {
            var shellSettings = new List <ShellSettings>();

            foreach (var tenant in _appDataFolder.ListDirectories(_optionsAccessor.Value.Location))
            {
                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("ShellSettings found in '{0}', attempting to load.", tenant.Name);
                }
                var configurationContainer =
                    new ConfigurationBuilder()
                    .SetBasePath(_appDataFolder.RootPath)
                    .AddJsonFile(_appDataFolder.Combine(tenant.FullName, string.Format(SettingsFileNameFormat, "json")),
                                 true)
                    .AddXmlFile(_appDataFolder.Combine(tenant.FullName, string.Format(SettingsFileNameFormat, "xml")),
                                true)
                    .AddYamlFile(_appDataFolder.Combine(tenant.FullName, string.Format(SettingsFileNameFormat, "txt")),
                                 false);

                var config       = configurationContainer.Build();
                var shellSetting = ShellSettingsSerializer.ParseSettings(config);
                shellSetting.Location = tenant.Name;
                shellSettings.Add(shellSetting);

                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation("Loaded ShellSettings for tenant '{0}'", shellSetting.Name);
                }
            }

            return(shellSettings);
        }
        private IEnumerable <string> GetTemplates()
        {
            string path = Path.Combine("Sites", _shellSettings.Name, ModuleGeneratorService.ModuleTemplatesPathName);

            if (!_appDataFolder.DirectoryExists(path))
            {
                _appDataFolder.CreateDirectory(path);
            }
            return((from d in _appDataFolder.ListDirectories(path)
                    select Path.GetFileName(d)).ToList());
        }
Example #8
0
        private IEnumerable <ShellSettings> LoadSettingsInternal()
        {
            var filePaths = _appDataFolder
                            .ListDirectories("Sites")
                            .SelectMany(path => _appDataFolder.ListFiles(path))
                            .Where(path => String.Equals(Path.GetFileName(path), SettingsFileName, StringComparison.OrdinalIgnoreCase));

            foreach (var filePath in filePaths)
            {
                yield return(ShellSettingsSerializer.ParseSettings(_appDataFolder.ReadFile(filePath)));
            }
        }
        IEnumerable <ShellSettings> IShellSettingsManager.LoadSettings()
        {
            var tenantPaths = _appDataFolder
                              .ListDirectories("Sites")
                              .Select(path => _appDataFolder.MapPath(path));

            var shellSettings = new List <ShellSettings>();

            foreach (var tenantPath in tenantPaths)
            {
                _logger.LogInformation("ShellSettings found in '{0}', attempting to load.", tenantPath);

                var configurationContainer =
                    new ConfigurationBuilder()
                    .AddJsonFile(_appDataFolder.Combine(tenantPath, string.Format(SettingsFileNameFormat, "json")),
                                 true)
                    .AddXmlFile(_appDataFolder.Combine(tenantPath, string.Format(SettingsFileNameFormat, "xml")),
                                true)
                    .Add(
                        new DefaultFileConfigurationSource(
                            _appDataFolder.Combine(tenantPath, string.Format(SettingsFileNameFormat, "txt")), false));

                var config = configurationContainer.Build();

                var shellSetting = new ShellSettings {
                    Name = config["Name"],
                    DataConnectionString = config["DataConnectionString"],
                    DataProvider         = config["DataProvider"],
                    DataTablePrefix      = config["DataTablePrefix"],
                    RequestUrlHost       = config["RequestUrlHost"],
                    RequestUrlPrefix     = config["RequestUrlPrefix"]
                };

                TenantState state;
                shellSetting.State = Enum.TryParse(config["State"], true, out state)
                    ? state
                    : TenantState.Uninitialized;

                shellSettings.Add(shellSetting);

                _logger.LogInformation("Loaded ShellSettings for tenant '{0}'", shellSetting.Name);
            }

            return(shellSettings);
        }
        IEnumerable <ShellSettings> IShellSettingsManager.LoadSettings()
        {
            var tenantPaths = _appDataFolder
                              .ListDirectories("Sites")
                              .Select(path => _appDataFolder.MapPath(path));

            var shellSettings = new List <ShellSettings>();

            foreach (var tenantPath in tenantPaths)
            {
                Logger.Information("ShellSettings found in '{0}', attempting to load.", tenantPath);

                IConfigurationSourceRoot configurationContainer =
                    new Microsoft.Framework.ConfigurationModel.Configuration()
                    .AddJsonFile(_appDataFolder.Combine(tenantPath, string.Format(_settingsFileNameFormat, "json")),
                                 true)
                    .AddXmlFile(_appDataFolder.Combine(tenantPath, string.Format(_settingsFileNameFormat, "xml")),
                                true)
                    .AddIniFile(_appDataFolder.Combine(tenantPath, string.Format(_settingsFileNameFormat, "ini")),
                                true)
                    .Add(
                        new DefaultFileConfigurationSource(
                            _appDataFolder.Combine(tenantPath, string.Format(_settingsFileNameFormat, "txt")), false));

                var shellSetting = new ShellSettings {
                    Name = configurationContainer.Get <string>("Name"),
                    DataConnectionString = configurationContainer.Get <string>("DataConnectionString"),
                    DataProvider         = configurationContainer.Get <string>("DataProvider"),
                    DataTablePrefix      = configurationContainer.Get <string>("DataTablePrefix"),
                    RequestUrlHost       = configurationContainer.Get <string>("RequestUrlHost"),
                    RequestUrlPrefix     = configurationContainer.Get <string>("RequestUrlPrefix")
                };

                TenantState state;
                shellSetting.State = Enum.TryParse(configurationContainer.Get <string>("State"), true, out state)
                    ? state
                    : TenantState.Uninitialized;

                shellSettings.Add(shellSetting);

                Logger.Information("Loaded ShellSettings for tenant '{0}'", shellSetting.Name);
            }

            return(shellSettings);
        }
Example #11
0
 public IEnumerable <string> List()
 {
     return(_appDataFolder.ListDirectories(_basePath).Select(Path.GetFileNameWithoutExtension));
 }