/// <summary> /// Saves the collection to file. /// </summary> void Save() { using (var w = XmlValueWriter.Create(_dataFile, _rootNodeName)) { w.WriteManyNodes(_rootNodeName, _textureHash, Write); } }
/// <summary> /// Writes the <see cref="ActionDisplayCollection"/> to file. /// </summary> /// <param name="path">The path of the file to write to.</param> public void Save(string path) { using (var writer = XmlValueWriter.Create(path, _fileRootName)) { ((IPersistable)this).WriteState(writer); } }
/// <summary> /// Saves the <see cref="BodyInfoManager"/> data to file. /// </summary> /// <param name="filePath">The file to save to.</param> public void Save(string filePath) { using (var writer = XmlValueWriter.Create(filePath, _rootNodeName)) { Write(writer); } }
/// <summary> /// Saves the cache items to the cache file. /// </summary> public virtual void Save() { using (var writer = XmlValueWriter.Create(CacheFile, _rootNodeName)) { writer.WriteManyNodes("Item", _cache.Values.OrderBy(x => x.GrhIndex).ToImmutable(), (w, x) => x.WriteState(w)); } }
public void Save(ContentPaths contentPath) { var filePath = GetFilePath(contentPath); // Build up a list of the valid walls, and join them with their GrhIndex var wallsToWrite = new List <KeyValuePair <GrhIndex, List <WallEntityBase> > >(_walls.Count); for (var i = 0; i < _walls.Length; i++) { var walls = _walls[i]; if (walls == null || walls.Count == 0) { continue; } var kvp = new KeyValuePair <GrhIndex, List <WallEntityBase> >(new GrhIndex(i), walls); wallsToWrite.Add(kvp); } // Write the values using (var writer = XmlValueWriter.Create(filePath, _rootNodeName)) { writer.WriteManyNodes(_rootNodeName, wallsToWrite, WriteWalls); } }
/// <summary> /// Saves the quest descriptions to file. /// </summary> /// <param name="contentPath">The <see cref="ContentPaths"/> to use to get the file path.</param> public void Save(ContentPaths contentPath) { var filePath = GetFilePath(contentPath); using (var w = XmlValueWriter.Create(filePath, _rootFileNodeName)) { WriteState(w); } }
/// <summary> /// When overridden in the derived class, gets the IValueWriter instance. This method is always called first. /// </summary> /// <returns>The IValueReader instance.</returns> public override IValueWriter GetWriter() { return(XmlValueWriter.Create(_filePath, _rootNodeName)); }
public void TestWriteReadManyValuesExtensiveXml() { const int count = 100; var filePath = Path.GetTempFileName(); try { var sources = new List <DE>(count); using (var writer = XmlValueWriter.Create(filePath, "DynamicEntities")) { writer.Write("Count", count); for (var i = 0; i < count; i++) { var src = new DE(); sources.Add(src); var key = "Entity" + Parser.Invariant.ToString(i); writer.WriteStartNode(key); _dynamicEntityFactoryBase.Write(writer, src); writer.WriteEndNode(key); } } var reader = XmlValueReader.CreateFromFile(filePath, "DynamicEntities"); for (var i = 0; i < count; i++) { var key = "Entity" + Parser.Invariant.ToString(i); var r = reader.ReadNode(key); var src = sources[i]; var dest = (DE)_dynamicEntityFactoryBase.Read(r); Assert.AreEqual(src.Position, dest.Position); Assert.AreEqual(src.Size, dest.Size); Assert.AreEqual(src.Velocity, dest.Velocity); Assert.AreEqual(src.Weight, dest.Weight); Assert.AreEqual(src.MapEntityIndex, dest.MapEntityIndex); Assert.AreEqual(src.Center, dest.Center); Assert.AreEqual(src.A, dest.A, "Index: " + i); Assert.AreEqual(src.B, dest.B, "Index: " + i); Assert.AreEqual(src.C, dest.C, "Index: " + i); Assert.AreEqual(src.D, dest.D, "Index: " + i); Assert.AreEqual(src.E, dest.E, "Index: " + i); Assert.AreEqual(src.F, dest.F, "Index: " + i); Assert.AreEqual(src.G, dest.G, "Index: " + i); Assert.AreEqual(Math.Round(src.H), Math.Round(dest.H), "Index: " + i); Assert.AreEqual(src.I, dest.I, "Index: " + i); Assert.AreEqual(src.J, dest.J, "Index: " + i); Assert.AreEqual(Math.Round(src.K), Math.Round(dest.K), "Index: " + i); Assert.AreEqual(src.L.Round(), dest.L.Round(), "Index: " + i); Assert.AreEqual(src.M, dest.M, "Index: " + i); Assert.AreEqual(src.N, dest.N, "Index: " + i); Assert.AreEqual(src.O, dest.O, "Index: " + i); Assert.AreEqual(src.P, dest.P, "Index: " + i); Assert.AreEqual(src.Q.Round(), dest.Q.Round(), "Index: " + i); Assert.AreEqual(src.R.Round(), dest.R.Round(), "Index: " + i); } } finally { if (File.Exists(filePath)) { File.Delete(filePath); } } }