예제 #1
0
        private bool SaveConfigurationFile <T>(AppData <T> appData, bool askForConfirmation = true) where T : INamed, new()
        {
            bool configurationSaved = false;

            var fileName   = appData.Status[ApplicationStatusBackup.StatusItem.ConfigurationFileName];
            var dbLocation = appData.Status[ApplicationStatusBackup.StatusItem.ConfigurationFileLocation];

            string fullPath = string.Empty;

            if (appData.IsNewConfiguration)
            {
                fullPath = CommonDialogs.SaveToFileDialogBox(fileName, dbLocation);
            }
            else
            {
                fullPath = Path.Combine(dbLocation, fileName);
                if (askForConfirmation && CommonDialogs.AreYouSure($"Save file?\n{fullPath}") == DialogResult.No)
                {
                    fullPath = string.Empty;
                }
            }

            if (!string.IsNullOrEmpty(fullPath))
            {
                appData.SaveItems(Path.GetDirectoryName(fullPath), Path.GetFileName(fullPath));
                configurationSaved = true;
            }

            return(configurationSaved);
        }