private static object Deserialize(Type type, Stream stream) { XmlReaderSettings xmlReaderSettings = null; XmlSchema xmlSchema = null; XmlSerializer xmlSerializer = VersionedXmlTypeFactory.GetXmlSerializer(type, out xmlSchema); if (xmlSchema != null) { xmlReaderSettings = new XmlReaderSettings(); xmlReaderSettings.ValidationType = ValidationType.Schema; xmlReaderSettings.ValidationFlags = (XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.AllowXmlAttributes); xmlReaderSettings.Schemas.Add(xmlSchema); } object result; using (XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings)) { result = xmlSerializer.Deserialize(xmlReader); } return(result); }
private static void Serialize(Stream stream, object obj) { VersionedXmlTypeFactory.GetXmlSerializer(obj.GetType()).Serialize(stream, obj); }
public static XmlSerializer GetXmlSerializer(Type type) { XmlSchema xmlSchema = null; return(VersionedXmlTypeFactory.GetXmlSerializer(type, out xmlSchema)); }