System;SystemCollectionsGeneric;SystemLinq;SystemText;SystemXmlSerialization;SystemIO;SystemXml; { XmlSerializeInternal(stream, o, encoding) { ( o ) (); ( encoding ) (); serializer (oGetType()); settings (); settingsIndent ; settingsNewLineChars ; settingsEncoding encoding; settingsIndentChars ; ( writer Create(stream, settings) ) { serializerSerialize(writer, o); writerClose(); } } XmlSerialize(o, encoding) { ( stream () ) { XmlSerializeInternal(stream, o, encoding); streamPosition ; ( reader (stream, encoding) ) { readerReadToEnd(); } } } XmlSerializeToFile(o, path, encoding) { ( IsNullOrEmpty(path) ) (); ( file (path, Create, Write) ) { XmlSerializeInternal(file, o, encoding); } } T XmlDeserializeT(s, encoding) { ( IsNullOrEmpty(s) ) (); ( encoding ) (); mySerializer ((T)); ( ms (encodingGetBytes(s)) ) { ( sr (ms, encoding) ) { (T)mySerializerDeserialize(sr); } } } T XmlDeserializeFromFileT(path, encoding) { ( IsNullOrEmpty(path) ) (); ( encoding ) (); xml ReadAllText(path, encoding); XmlDeserializeT(xml, encoding); } } |