2 using System.Collections.Generic;
14 private XmlWriter writer;
15 private XmlWriterSettings settings;
16 private bool closed =
false;
20 File = manager.
Open( fileName,
true );
21 settings =
new XmlWriterSettings();
22 settings.ConformanceLevel = ConformanceLevel.Document;
23 settings.Encoding = Encoding.UTF8;
24 settings.Indent =
true;
26 writer.WriteStartDocument();
27 writer.WriteStartElement(
"State" );
30 internal void BeginWriteXml()
33 throw new IOException(
"Tried to write to a closed state file." );
36 writer = XmlWriter.Create(
File.
Stream, settings );
44 public void Save<T>(
object obj,
string name )
46 Save( obj, typeof(
T ), name );
49 public void Save(
object obj, Type objType,
string name )
52 writer.WriteStartElement(
"Object" );
53 writer.WriteAttributeString(
"Name", name );
54 writer.WriteAttributeString(
"TypeAssembly", objType.Assembly.FullName );
55 writer.WriteAttributeString(
"Type", objType.Name );
56 File.SaveData( writer, objType, obj,
false );
57 writer.WriteEndElement();
65 writer.WriteEndElement();
66 writer.WriteEndDocument();
void Save(object obj, Type objType, string name)
abstract StorageFile Open(string fileName, bool write)
void Save< T >(object obj, string name)