public override byte[] Save(Project project) { // Wrap the project in a top-level root element with some info about the XML file // format version. Note that each serializer has its own implementation of storing this metadata var rootElement = new Root { SaveVersion = CurrentSaveFormatVersion, Watermark = ProjectSerializer.DizWatermark, Project = project, }; BeforeSerialize?.Invoke(this, rootElement); var xmlStr = XmlSerializationSupport.Serialize(rootElement); return(Encoding.UTF8.GetBytes(xmlStr)); }
// finally. this is the real deal. private static Root DeserializeProjectXml(string xmlStr) => XmlSerializationSupport.Deserialize <Root>(xmlStr);