public bool LoadSettings(ProgramSettings programSettings, out bool createSample)
        {
            createSample = false;
            var settingsFileFullPath = programSettings.settingsFileFullPath;

            var fileAvailabilityValidator = new SettingsFileAvailabilityValidator();
            var validationResult          = fileAvailabilityValidator.Validate(settingsFileFullPath);

            if (!validationResult.IsValid)
            {
                foreach (var failure in validationResult.Errors)
                {
                    _logger.LogError(failure.ErrorMessage);
                }
                createSample = true;
                return(false);
            }

            var fileNotEmptyValidator = new FileNotEmptyValidator();

            validationResult = fileNotEmptyValidator.Validate(settingsFileFullPath);

            if (!validationResult.IsValid)
            {
                foreach (var failure in validationResult.Errors)
                {
                    _logger.LogError(failure.ErrorMessage);
                }
                createSample = true;
                return(false);
            }

            var jsonTextValidator = new JsonTextValidator();

            validationResult = jsonTextValidator.Validate(settingsFileFullPath);
            if (!validationResult.IsValid)
            {
                foreach (var failure in validationResult.Errors)
                {
                    _logger.LogError(failure.ErrorMessage);
                }
                return(false);
            }

            var settingsJson = File.ReadAllText(settingsFileFullPath);

            try
            {
                var jsonParsed = JObject.Parse(settingsJson).ToObject <ProgramSettings>();
                programSettings.EmailSettingsList = jsonParsed.EmailSettingsList;
                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(false);
            }
        }
        public void CreateSampleSettingsFile()
        {
            var defaultEmailSettingsList = new List <EmailSettings> {
                EmailSettings.CreateSample()
            };
            var defaultSettings         = new ProgramSettings(defaultEmailSettingsList);
            var defaultSettingsFilePath = Properties.Resources.ResourceManager.GetString("SettingsFilename");

            var fileAvailabilityValidator = new SettingsFileAvailabilityValidator();
            var validationResult          = fileAvailabilityValidator.Validate(defaultSettingsFilePath);

            if (!validationResult.IsValid)
            {
                foreach (var failure in validationResult.Errors)
                {
                    _logger.LogError(failure.ErrorMessage);
                }
            }

            File.WriteAllText(defaultSettingsFilePath, JObject.FromObject(defaultSettings).ToString());
            _logger.LogInformation(
                $"Создан образец файла настроек {defaultSettingsFilePath}. Измените настройки и перезапустите программу.");
        }