BatchGuy.App.Eac3To.Services.BatchGuyEAC3ToSettingsService.Save C# (CSharp) Method

Save() public method

public Save ( string settingsFile, BatchGuyEAC3ToSettings batchGuyEAC3ToSettings ) : void
settingsFile string
batchGuyEAC3ToSettings BatchGuy.App.Eac3To.Models.BatchGuyEAC3ToSettings
return void
        public void Save(string settingsFile, BatchGuyEAC3ToSettings batchGuyEAC3ToSettings)
        {
            try
            {
                _jsonSerializationService.WriteToJsonFile(settingsFile, batchGuyEAC3ToSettings, false);
            }
            catch (Exception ex)
            {
                _log.ErrorFormat(Program.GetLogErrorFormat(), ex.Message, ex.StackTrace, MethodBase.GetCurrentMethod().Name);
                _errors.Add(new Error() { Description = "There was a problem saving the BatchGuy eac3to Settings File" });
            }
        }

Usage Example

        private void HandlesSaveToolStripMenuItemClick()
        {
            this.SetEac3ToConfiguration();
            this.SetEAC3ToRemuxFileNameTemplate();
            if (this.IsAtLeastOneDiscLoaded() && this.IsScreenValid())
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "BatchGuy File|*.batchGuyEac3toSettings";
                sfd.Title = "Save eac3to Settings File";
                sfd.ShowDialog();

                if (!string.IsNullOrEmpty(sfd.FileName))
                {
                    dgvBluRayDiscInfo.CurrentCell = null; //force the cell change so cell changed event fires
                    dgvBluRaySummary.CurrentCell = null; //force the cell change so cell changed event fires
                    List<BluRayDiscInfo> discs = this.GetBluRayDiscInfoList();
                    if (_batchGuyEAC3ToSettings == null)
                        _batchGuyEAC3ToSettings = new BatchGuyEAC3ToSettings();

                    _batchGuyEAC3ToSettings.BluRayDiscs = discs;
                    _batchGuyEAC3ToSettings.EAC3ToSettings = _eac3toConfiguration;

                    IJsonSerializationService<BatchGuyEAC3ToSettings> jsonSerializationService = new JsonSerializationService<BatchGuyEAC3ToSettings>();
                    IBatchGuyEAC3ToSettingsService batchGuyEAC3ToSettingsService = new BatchGuyEAC3ToSettingsService(jsonSerializationService);
                    batchGuyEAC3ToSettingsService.Save(sfd.FileName, _batchGuyEAC3ToSettings);
                    if (batchGuyEAC3ToSettingsService.Errors.Count() > 0)
                    {
                        MessageBox.Show(batchGuyEAC3ToSettingsService.Errors.GetErrorMessage(), "Error Occurred.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
All Usage Examples Of BatchGuy.App.Eac3To.Services.BatchGuyEAC3ToSettingsService::Save