示例#1
0
        protected void SaveData()
        {
            var filePath = GetSettingsFilePath(FileName);

            try {
                var doc = new XDocument();
                WriteXml(doc);
                doc.Save(filePath);
            } catch (Exception ex) {
                if (DisplayLoadSaveWarnings)
                {
                    DataManagerLogger.Warning("Failed to save xml to " + filePath + ". Exception was: " + ex);
                }
                if (!SuppressLoadSaveExceptions)
                {
                    throw;
                }
            }
        }
示例#2
0
        protected void LoadData()
        {
            var filePath = GetSettingsFilePath(FileName);

            if (!File.Exists(filePath))
            {
                return;
            }
            try {
                var doc = XDocument.Load(filePath);
                LoadFromXml(doc);
            } catch (Exception ex) {
                if (DisplayLoadSaveWarnings)
                {
                    DataManagerLogger.Warning("Exception loading xml from " + filePath + ". " +
                                              "Loading defaults instead. Exception was: " + ex
                                              );
                }
                if (!SuppressLoadSaveExceptions)
                {
                    throw;
                }
            }
        }