예제 #1
0
        private IEnumerable <ShellSettings> LoadSettings()
        {
            var filePaths = appDataFolder
                            .ListDirectories("Sites")
                            .SelectMany(path => appDataFolder.ListFiles(path))
                            .Where(path => string.Equals(Path.GetFileName(path), "Settings.txt", StringComparison.OrdinalIgnoreCase));

            foreach (var filePath in filePaths)
            {
                yield return(ShellSettingsSerializer.ParseSettings(appDataFolder.ReadFile(filePath)));
            }
        }
예제 #2
0
        void IShellSettingsManager.SaveSettings(ShellSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentException(T("There are no settings to save.").ToString());
            }

            if (string.IsNullOrEmpty(settings.Name))
            {
                throw new ArgumentException(T("Settings \"Name\" is not set.").ToString());
            }

            var filePath = Path.Combine(Path.Combine("Sites", settings.Name), "Settings.txt");

            appDataFolder.CreateFile(filePath, ShellSettingsSerializer.ComposeSettings(settings));
            events.Saved(settings);
        }