public override void WriteToXml(XmlWriter writer) { writer.WriteStartElement(TypeIdString); writer.WriteElementString(XmlName_Name, Name); if (Filter != null) { writer.WriteElementString(XmlName_Filter, Filter); } if (Prefix != null) { writer.WriteElementString(XmlName_Prefix, Prefix); } writer.WriteElementString(XmlName_IncludeUnknown, IncludeUnknown.ToString().ToLowerInvariant()); writer.WriteElementString(XmlName_UnknownText, UnknownText); foreach (HowLongToBeatRule rule in Rules) { writer.WriteStartElement(XmlName_Rule); writer.WriteElementString(XmlName_Rule_Text, rule.Name); writer.WriteElementString(XmlName_Rule_MinHours, rule.MinHours.ToString()); writer.WriteElementString(XmlName_Rule_MaxHours, rule.MaxHours.ToString()); writer.WriteElementString(XmlName_Rule_TimeType, rule.TimeType.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); }
public override void WriteToXml(XmlWriter writer) { writer.WriteStartElement(TypeIdString); writer.WriteElementString(XmlName_Name, Name); writer.WriteElementString(XmlName_Prefix, Prefix); writer.WriteElementString(XmlName_IncludeUnknown, IncludeUnknown.ToString()); writer.WriteElementString(XmlName_UnknownText, UnknownText); writer.WriteElementString(XmlName_GroupingMode, GroupingMode.ToString()); writer.WriteEndElement(); // type ID string }
public override void WriteToXml(XmlWriter writer) { writer.WriteStartElement(TypeIdString); writer.WriteElementString(XmlName_Name, Name); if (Filter != null) writer.WriteElementString(XmlName_Filter, Filter); if (Prefix != null) writer.WriteElementString(XmlName_Prefix, Prefix); writer.WriteElementString(XmlName_IncludeUnknown, IncludeUnknown.ToString().ToLowerInvariant()); writer.WriteElementString(XmlName_UnknownText, UnknownText); writer.WriteElementString(XmlName_GroupingMode, GroupingMode.ToString()); writer.WriteEndElement(); // type ID string }
public override void WriteToXml(XmlWriter writer) { writer.WriteStartElement(TypeIdString); writer.WriteElementString(XmlNameName, Name); if (Filter != null) { writer.WriteElementString(XmlNameFilter, Filter); } if (Prefix != null) { writer.WriteElementString(XmlNamePrefix, Prefix); } writer.WriteElementString(XmlNameIncludeUnknown, IncludeUnknown.ToString()); writer.WriteElementString(XmlNameUnknownText, UnknownText); writer.WriteElementString(XmlNameGroupingMode, GroupingMode.ToString()); writer.WriteEndElement(); // type ID string }
/// <inheritdoc /> public void Save(string path) { Logger.Info(GlobalStrings.Profile_SavingProfile, path); XmlWriterSettings writeSettings = new XmlWriterSettings { CloseOutput = true, Indent = true }; try { Utility.BackupFile(path, Settings.Instance.ConfigBackupCount); } catch (Exception e) { Logger.Error(GlobalStrings.Log_Profile_ConfigBackupFailed, e.Message); } XmlWriter writer; try { writer = XmlWriter.Create(path, writeSettings); } catch (Exception e) { Logger.Warn(GlobalStrings.Profile_FailedToOpenProfileFile, e.Message); throw new ApplicationException(GlobalStrings.Profile_ErrorSavingProfileFile + e.Message, e); } writer.WriteStartElement(XmlNameProfile); writer.WriteElementString(XmlNameSteamId, SteamID64.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString(XmlNameAutoUpdate, AutoUpdate.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameAutoImport, AutoImport.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameAutoExport, AutoExport.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameLocalUpdate, LocalUpdate.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameWebUpdate, WebUpdate.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameExportDiscard, ExportDiscard.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameAutoIgnore, AutoIgnore.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameIncludeUnknown, IncludeUnknown.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameBypassIgnoreOnImport, BypassIgnoreOnImport.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameOverwriteNames, OverwriteOnDownload.ToString().ToLowerInvariant()); writer.WriteElementString(XmlNameIncludeShortcuts, IncludeShortcuts.ToString().ToLowerInvariant()); writer.WriteStartElement(XmlNameGameList); foreach (GameInfo gameInfo in GameData.Games.Values) { if (!IncludeShortcuts && gameInfo.Id <= 0) { continue; } // Don't save shortcuts if we aren't including them writer.WriteStartElement(XmlNameGame); writer.WriteElementString(XmlNameGameId, gameInfo.Id.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString(XmlNameGameSource, gameInfo.Source.ToString()); if (gameInfo.Name != null) { writer.WriteElementString(XmlNameGameName, gameInfo.Name); } writer.WriteElementString(XmlNameGameHidden, gameInfo.IsHidden.ToString().ToLowerInvariant()); if (gameInfo.LastPlayed != 0) { writer.WriteElementString(XmlNameGameLastPlayed, gameInfo.LastPlayed.ToString(CultureInfo.InvariantCulture)); } if (gameInfo.HoursPlayed > 0) { writer.WriteElementString(XmlNameGameHoursPlayed, gameInfo.HoursPlayed.ToString(CultureInfo.InvariantCulture)); } if (!gameInfo.Executable.Contains("steam://")) { writer.WriteElementString(XmlNameGameExecutable, gameInfo.Executable); } writer.WriteStartElement(XmlNameGameCategoryList); foreach (Category category in gameInfo.Categories) { string categoryName = category.Name; if (category.Name == GameList.FavoriteNewConfigValue) { categoryName = GameList.FavoriteConfigValue; } writer.WriteElementString(XmlNameGameCategory, categoryName); } writer.WriteEndElement(); // categories writer.WriteEndElement(); // game } writer.WriteEndElement(); // games writer.WriteStartElement(XmlNameFilterList); foreach (Filter filter in GameData.Filters) { WriteFilterToXml(writer, filter); } writer.WriteEndElement(); //game filters writer.WriteStartElement(XmlNameAutoCatList); foreach (AutoCat autoCat in AutoCats) { autoCat.WriteToXml(writer); } writer.WriteEndElement(); //autocats writer.WriteStartElement(XmlNameExclusionList); foreach (int i in IgnoreList) { writer.WriteElementString(XmlNameExclusion, i.ToString(CultureInfo.InvariantCulture)); } writer.WriteEndElement(); // exclusions writer.WriteEndElement(); // profile writer.Close(); FilePath = path; Logger.Info(GlobalStrings.Profile_ProfileSaveComplete); }