Loads and saves XmlData to file
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Content.Xml XmlFile
Namespace: DeltaEngine.Content.Xml
Assembly: DeltaEngine.Content.Xml (in DeltaEngine.Content.Xml.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The XmlFile type exposes the following members.
Constructors
Name | Description | |
---|---|---|
XmlFile(Stream) | Initializes a new instance of the XmlFile class | |
XmlFile(String) | Initializes a new instance of the XmlFile class | |
XmlFile(XmlData) | Initializes a new instance of the XmlFile class |
Methods
Name | Description | |
---|---|---|
Save | ||
ToMemoryStream |
Properties
Name | Description | |
---|---|---|
Root |
Remarks
Examples
[Test] public void XmlDataConstructor() { var data = new XmlData("name"); var file = new XmlFile(data); Assert.AreEqual(data, file.Root); }
[Test] public void LoadXmlFromStream() { var memoryStream = new MemoryStream(); var writer = new BinaryWriter(memoryStream); writer.Write(new XmlData("MyData").ToString()); memoryStream.Seek(0, SeekOrigin.Begin); var file = new XmlFile(memoryStream); Assert.AreEqual("MyData", file.Root.Name); }
[Test] public void SavingAndLoadingLeavesItUnchanged() { XmlData data = CreateTestXmlData(); var file = new XmlFile(data); file.Save("file.xml"); XmlData loaded = new XmlFile("file.xml").Root; Assert.AreEqual(data.ToString(), loaded.ToString()); }
See Also