public virtual void SaveSettings(ShellSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (String.IsNullOrEmpty(settings.Name))
            {
                throw new ArgumentException("The Name property of the supplied ShellSettings object is null or empty; the settings cannot be saved.", "settings");
            }

            Logger.Debug("Saving ShellSettings for tenant '{0}'...", settings.Name);
            var content  = ShellSettingsSerializer.ComposeSettings(settings);
            var filePath = _fileSystem.Combine(settings.Name, Constants.ShellSettingsFileName);
            var file     = _fileSystem.FileExists(filePath) ? _fileSystem.GetFile(filePath) : _fileSystem.CreateFile(filePath);

            using (var stream = file.OpenWrite()) {
                using (var writer = new StreamWriter(stream)) {
                    writer.Write(content);
                }
            }

            Logger.Debug("ShellSettings saved successfully; flagging tenant '{0}' for restart.", settings.Name);
            _events.Saved(settings);
        }
Example #2
0
        void IShellSettingsManager.SaveSettings(ShellSettings settings)
        {
            var content  = ShellSettingsSerializer.ComposeSettings(settings);
            var filePath = _fileSystem.Combine(settings.Name, SettingsFilename);

            var file = _fileSystem.FileExists(filePath)
                ? _fileSystem.GetFile(filePath)
                : _fileSystem.CreateFile(filePath);

            using (var stream = file.OpenWrite()) {
                using (var writer = new StreamWriter(stream)) {
                    writer.Write(content);
                }
            }

            _events.Saved(settings);
        }
 public void GetFileShouldOnlyAcceptRelativePath()
 {
     _azureBlobStorageProvider.CreateFile("foo.txt");
     _azureBlobStorageProvider.GetFile("/foot.txt");
 }