public void Save(IRun run, Stream stream) { var document = new XmlDocument(); XmlNode docNode = document.CreateXmlDeclaration("1.0", "UTF-8", null); document.AppendChild(docNode); var parent = document.CreateElement("Run"); var version = document.CreateAttribute("version"); version.Value = "1.4.2"; parent.Attributes.Append(version); document.AppendChild(parent); var gameIcon = CreateImageElement(document, "GameIcon", run.GameIcon); parent.AppendChild(gameIcon); var gameName = document.CreateElement("GameName"); gameName.InnerText = run.GameName; parent.AppendChild(gameName); var categoryName = document.CreateElement("CategoryName"); categoryName.InnerText = run.CategoryName; parent.AppendChild(categoryName); var offset = document.CreateElement("Offset"); offset.InnerText = run.Offset.ToString(); parent.AppendChild(offset); var attemptCount = document.CreateElement("AttemptCount"); attemptCount.InnerText = run.AttemptCount.ToString(); parent.AppendChild(attemptCount); var runHistory = document.CreateElement("RunHistory"); foreach (var historyItem in run.RunHistory) { runHistory.AppendChild(historyItem.ToXml(document)); } parent.AppendChild(runHistory); var segmentElement = document.CreateElement("Segments"); parent.AppendChild(segmentElement); var bf = new BinaryFormatter(); foreach (var segment in run) { var splitElement = document.CreateElement("Segment"); segmentElement.AppendChild(splitElement); var name = document.CreateElement("Name"); name.InnerText = segment.Name; splitElement.AppendChild(name); var icon = CreateImageElement(document, "Icon", segment.Icon); splitElement.AppendChild(icon); var splitTimes = document.CreateElement("SplitTimes"); foreach (var comparison in run.CustomComparisons) { var splitTime = segment.Comparisons[comparison].ToXml(document, "SplitTime"); var comparisonName = document.CreateAttribute("name"); comparisonName.Value = comparison; splitTime.Attributes.Append(comparisonName); splitTimes.AppendChild(splitTime); } splitElement.AppendChild(splitTimes); var goldSplit = segment.BestSegmentTime.ToXml(document, "BestSegmentTime"); splitElement.AppendChild(goldSplit); var history = document.CreateElement("SegmentHistory"); foreach (var historySegment in segment.SegmentHistory) { history.AppendChild(historySegment.ToXml(document)); } splitElement.AppendChild(history); } var autoSplitterSettings = document.CreateElement("AutoSplitterSettings"); if (run.IsAutoSplitterActive()) { autoSplitterSettings.InnerXml = run.AutoSplitter.Component.GetSettings(document).InnerXml; } parent.AppendChild(autoSplitterSettings); document.Save(stream); }
public void Save(IRun run, Stream stream) { var document = new XmlDocument(); XmlNode docNode = document.CreateXmlDeclaration("1.0", "UTF-8", null); document.AppendChild(docNode); var parent = document.CreateElement("Run"); parent.Attributes.Append(ToAttribute(document, "version", "1.7.0")); document.AppendChild(parent); CreateSetting(document, parent, "GameIcon", run.GameIcon); CreateSetting(document, parent, "GameName", run.GameName); CreateSetting(document, parent, "CategoryName", run.CategoryName); CreateSetting(document, parent, "LayoutPath", run.LayoutPath); var metadata = document.CreateElement("Metadata"); var runElement = document.CreateElement("Run"); runElement.Attributes.Append(ToAttribute(document, "id", run.Metadata.RunID)); metadata.AppendChild(runElement); var platform = ToElement(document, "Platform", run.Metadata.PlatformName); platform.Attributes.Append(ToAttribute(document, "usesEmulator", run.Metadata.UsesEmulator)); metadata.AppendChild(platform); CreateSetting(document, metadata, "Region", run.Metadata.RegionName); var variables = document.CreateElement("Variables"); foreach (var variable in run.Metadata.VariableValueNames) { var variableElement = ToElement(document, "Variable", variable.Value); variableElement.Attributes.Append(ToAttribute(document, "name", variable.Key)); variables.AppendChild(variableElement); } metadata.AppendChild(variables); parent.AppendChild(metadata); CreateSetting(document, parent, "Offset", run.Offset); CreateSetting(document, parent, "AttemptCount", run.AttemptCount); var runHistory = document.CreateElement("AttemptHistory"); foreach (var attempt in run.AttemptHistory) { runHistory.AppendChild(attempt.ToXml(document)); } parent.AppendChild(runHistory); var segmentElement = document.CreateElement("Segments"); parent.AppendChild(segmentElement); var bf = new BinaryFormatter(); foreach (var segment in run) { var splitElement = document.CreateElement("Segment"); segmentElement.AppendChild(splitElement); CreateSetting(document, splitElement, "Name", segment.Name); CreateSetting(document, splitElement, "Icon", segment.Icon); var splitTimes = document.CreateElement("SplitTimes"); foreach (var comparison in run.CustomComparisons) { var splitTime = segment.Comparisons[comparison].ToXml(document, "SplitTime"); splitTime.Attributes.Append(ToAttribute(document, "name", comparison)); splitTimes.AppendChild(splitTime); } splitElement.AppendChild(splitTimes); splitElement.AppendChild(segment.BestSegmentTime.ToXml(document, "BestSegmentTime")); var history = document.CreateElement("SegmentHistory"); foreach (var historySegment in segment.SegmentHistory) { var indexedTime = new IndexedTime(historySegment.Value, historySegment.Key); history.AppendChild(indexedTime.ToXml(document)); } splitElement.AppendChild(history); } var autoSplitterSettings = document.CreateElement("AutoSplitterSettings"); if (run.IsAutoSplitterActive()) { autoSplitterSettings.InnerXml = run.AutoSplitter.Component.GetSettings(document).InnerXml; } parent.AppendChild(autoSplitterSettings); document.Save(stream); }
public void Save(IRun run, Stream stream) { var document = new XmlDocument(); XmlNode docNode = document.CreateXmlDeclaration("1.0", "UTF-8", null); document.AppendChild(docNode); var parent = document.CreateElement("Run"); parent.Attributes.Append(SettingsHelper.ToAttribute(document, "version", "1.5.0")); document.AppendChild(parent); parent.AppendChild(SettingsHelper.CreateImageElement(document, "GameIcon", run.GameIcon)); parent.AppendChild(SettingsHelper.ToElement(document, "GameName", run.GameName)); parent.AppendChild(SettingsHelper.ToElement(document, "CategoryName", run.CategoryName)); parent.AppendChild(SettingsHelper.ToElement(document, "Offset", run.Offset)); parent.AppendChild(SettingsHelper.ToElement(document, "AttemptCount", run.AttemptCount)); var runHistory = document.CreateElement("AttemptHistory"); foreach (var attempt in run.AttemptHistory) { runHistory.AppendChild(attempt.ToXml(document)); } parent.AppendChild(runHistory); var segmentElement = document.CreateElement("Segments"); parent.AppendChild(segmentElement); var bf = new BinaryFormatter(); foreach (var segment in run) { var splitElement = document.CreateElement("Segment"); segmentElement.AppendChild(splitElement); splitElement.AppendChild(SettingsHelper.ToElement(document, "Name", segment.Name)); splitElement.AppendChild(SettingsHelper.CreateImageElement(document, "Icon", segment.Icon)); var splitTimes = document.CreateElement("SplitTimes"); foreach (var comparison in run.CustomComparisons) { var splitTime = segment.Comparisons[comparison].ToXml(document, "SplitTime"); splitTime.Attributes.Append(SettingsHelper.ToAttribute(document, "name", comparison)); splitTimes.AppendChild(splitTime); } splitElement.AppendChild(splitTimes); splitElement.AppendChild(segment.BestSegmentTime.ToXml(document, "BestSegmentTime")); var history = document.CreateElement("SegmentHistory"); foreach (var historySegment in segment.SegmentHistory) { history.AppendChild(historySegment.ToXml(document)); } splitElement.AppendChild(history); } var autoSplitterSettings = document.CreateElement("AutoSplitterSettings"); if (run.IsAutoSplitterActive()) autoSplitterSettings.InnerXml = run.AutoSplitter.Component.GetSettings(document).InnerXml; parent.AppendChild(autoSplitterSettings); document.Save(stream); }
public void Save(IRun run, Stream stream) { var document = new XmlDocument(); XmlNode docNode = document.CreateXmlDeclaration("1.0", "UTF-8", null); document.AppendChild(docNode); var parent = document.CreateElement("Run"); parent.Attributes.Append(SettingsHelper.ToAttribute(document, "version", "1.6.0")); document.AppendChild(parent); parent.AppendChild(SettingsHelper.CreateImageElement(document, "GameIcon", run.GameIcon)); parent.AppendChild(SettingsHelper.ToElement(document, "GameName", run.GameName)); parent.AppendChild(SettingsHelper.ToElement(document, "CategoryName", run.CategoryName)); parent.AppendChild(SettingsHelper.ToElement(document, "Offset", run.Offset)); parent.AppendChild(SettingsHelper.ToElement(document, "AttemptCount", run.AttemptCount)); var runHistory = document.CreateElement("AttemptHistory"); foreach (var attempt in run.AttemptHistory) { runHistory.AppendChild(attempt.ToXml(document)); } parent.AppendChild(runHistory); var segmentElement = document.CreateElement("Segments"); parent.AppendChild(segmentElement); var bf = new BinaryFormatter(); foreach (var segment in run) { var splitElement = document.CreateElement("Segment"); segmentElement.AppendChild(splitElement); splitElement.AppendChild(SettingsHelper.ToElement(document, "Name", segment.Name)); splitElement.AppendChild(SettingsHelper.CreateImageElement(document, "Icon", segment.Icon)); var splitTimes = document.CreateElement("SplitTimes"); foreach (var comparison in run.CustomComparisons) { var splitTime = segment.Comparisons[comparison].ToXml(document, "SplitTime"); splitTime.Attributes.Append(SettingsHelper.ToAttribute(document, "name", comparison)); splitTimes.AppendChild(splitTime); } splitElement.AppendChild(splitTimes); splitElement.AppendChild(segment.BestSegmentTime.ToXml(document, "BestSegmentTime")); var history = document.CreateElement("SegmentHistory"); foreach (var historySegment in segment.SegmentHistory) { history.AppendChild(historySegment.ToXml(document)); } splitElement.AppendChild(history); } var autoSplitterSettings = document.CreateElement("AutoSplitterSettings"); if (run.IsAutoSplitterActive()) autoSplitterSettings.InnerXml = run.AutoSplitter.Component.GetSettings(document).InnerXml; parent.AppendChild(autoSplitterSettings); var metadata = document.CreateElement("Metadata"); var runElement = document.CreateElement("Run"); runElement.Attributes.Append(SettingsHelper.ToAttribute(document, "id", run.Metadata.RunID ?? string.Empty)); metadata.AppendChild(runElement); var platform = SettingsHelper.ToElement(document, "Platform", run.Metadata.PlatformName ?? string.Empty); platform.Attributes.Append(SettingsHelper.ToAttribute(document, "usesEmulator", run.Metadata.UsesEmulator)); metadata.AppendChild(platform); metadata.AppendChild(SettingsHelper.ToElement(document, "Region", run.Metadata.RegionName ?? string.Empty)); var variables = document.CreateElement("Variables"); foreach (var variable in run.Metadata.VariableValueNames) { var variableElement = SettingsHelper.ToElement(document, "Variable", variable.Value ?? string.Empty); variableElement.Attributes.Append(SettingsHelper.ToAttribute(document, "name", variable.Key ?? string.Empty)); variables.AppendChild(variableElement); } metadata.AppendChild(variables); parent.AppendChild(metadata); document.Save(stream); }
public void Save(IRun run, Stream stream) { var document = new XmlDocument(); XmlNode docNode = document.CreateXmlDeclaration("1.0", "UTF-8", null); document.AppendChild(docNode); var parent = document.CreateElement("Run"); var version = document.CreateAttribute("version"); version.Value = "1.5.0"; parent.Attributes.Append(version); document.AppendChild(parent); var gameIcon = CreateImageElement(document, "GameIcon", run.GameIcon); parent.AppendChild(gameIcon); var gameName = document.CreateElement("GameName"); gameName.InnerText = run.GameName; parent.AppendChild(gameName); var categoryName = document.CreateElement("CategoryName"); categoryName.InnerText = run.CategoryName; parent.AppendChild(categoryName); var offset = document.CreateElement("Offset"); offset.InnerText = run.Offset.ToString(); parent.AppendChild(offset); var attemptCount = document.CreateElement("AttemptCount"); attemptCount.InnerText = run.AttemptCount.ToString(); parent.AppendChild(attemptCount); var runHistory = document.CreateElement("AttemptHistory"); foreach (var attempt in run.AttemptHistory) { runHistory.AppendChild(attempt.ToXml(document)); } parent.AppendChild(runHistory); var segmentElement = document.CreateElement("Segments"); parent.AppendChild(segmentElement); var bf = new BinaryFormatter(); foreach (var segment in run) { var splitElement = document.CreateElement("Segment"); segmentElement.AppendChild(splitElement); var name = document.CreateElement("Name"); name.InnerText = segment.Name; splitElement.AppendChild(name); var icon = CreateImageElement(document, "Icon", segment.Icon); splitElement.AppendChild(icon); var splitTimes = document.CreateElement("SplitTimes"); foreach (var comparison in run.CustomComparisons) { var splitTime = segment.Comparisons[comparison].ToXml(document, "SplitTime"); var comparisonName = document.CreateAttribute("name"); comparisonName.Value = comparison; splitTime.Attributes.Append(comparisonName); splitTimes.AppendChild(splitTime); } splitElement.AppendChild(splitTimes); var goldSplit = segment.BestSegmentTime.ToXml(document, "BestSegmentTime"); splitElement.AppendChild(goldSplit); var history = document.CreateElement("SegmentHistory"); foreach (var historySegment in segment.SegmentHistory) { history.AppendChild(historySegment.ToXml(document)); } splitElement.AppendChild(history); } var autoSplitterSettings = document.CreateElement("AutoSplitterSettings"); if (run.IsAutoSplitterActive()) autoSplitterSettings.InnerXml = run.AutoSplitter.Component.GetSettings(document).InnerXml; parent.AppendChild(autoSplitterSettings); document.Save(stream); }