public cLibrary LoadSnapshotFromFile(string filename = "Library.xml") { String rawData; LibraryProvider.LoadStream(filename); XmlDocument doc = new XmlDocument(); LibraryProvider.StreamSnapshot.Position = 0; doc.Load(LibraryProvider.StreamSnapshot); rawData = doc.InnerXml; XmlSerializer serializer = new XmlSerializer(typeof(cLibrary)); StreamProvider StreamBackup = LibraryProvider; try { using (TextReader reader = new StringReader(rawData)) { cLibrary result = serializer.Deserialize(reader) as cLibrary; result.LibraryProvider = StreamBackup; return(result); } } catch { return(null); } }
public static cLibrary LoadLibrary(string filename = "Library.xml") { String rawData; XmlDocument doc = new XmlDocument(); doc.Load(filename); rawData = doc.InnerXml; XmlSerializer serializer = new XmlSerializer(typeof(cLibrary)); try { using (TextReader reader = new StringReader(rawData)) { cLibrary result = (cLibrary)serializer.Deserialize(reader); return(result); } } catch { return(null); } }