Ejemplo n.º 1
0
        private void SerializeSettings(IDirectoryProvider directoryProvider, IFilenameGenerator filenameGenerator, IFileSaver fileSaver)
        {
            // Create Settings object
            Settings settings = new Settings
            {
                EnableColors          = EnableColors,
                EnableHolidaysTexts   = EnableHolidaysTexts,
                EnableSundaysTexts    = EnableSundaysTexts,
                EnableTableStretching = EnableTableStretching,
                Fullnames             = Fullnames
            };

            // Serialize settings
            SettingsSerializer serializer = new SettingsSerializer();
            string             json       = serializer.Serialize(settings);

            // Get directory and filename
            string path     = directoryProvider.GetApplicationDirectoryPath();
            string filename = filenameGenerator.GenerateJsonSettingsFilename();

            // Save serialized setting to file
            fileSaver.SaveJsonFile(json, path, filename);
        }