private void SaveToFile(string AFileName = null) { CheckActive(); if (AFileName == null) { DOMPersist.Save(FFileName); } else { DOMPersist.Save(AFileName); } SetModified(false); }
private void LoadData() { bool Status; /* Data loading precedence: * - XML Property (FXMLStrings) * - LoadFromStream/LoadFromXML (FXMLData) * - FileName Property/LoadFromFile (FFileName) */ DocSource = TXMLDocumentSource.xdsNone; FXMLStrRead = -1; AssignParseOptions(); if (!string.IsNullOrEmpty(FXMLString)) { Status = DOMPersist.LoadXml(FXMLString); DocSource = TXMLDocumentSource.xdsXMLProperty; FXMLStrRead = 0; } else if (FXMLData != null && FXMLData.Length != 0) // string is used as word array, without conversion { using (MemoryStream stream = new MemoryStream(FXMLData, 0, FXMLData.Length, false, true)) { Status = DOMPersist.LoadFromStream(stream); } FXMLData = null; if (DocSource == TXMLDocumentSource.xdsNone) { DocSource = TXMLDocumentSource.xdsXMLData; } } else if (FSrcStream != null) { FSrcStream.Position = 0; Status = DOMPersist.LoadFromStream(FSrcStream); DocSource = TXMLDocumentSource.xdsStream; FSrcStream = null; } else if (!string.IsNullOrEmpty(FFileName)) { Status = DOMPersist.Load(FFileName); DocSource = TXMLDocumentSource.xdsFile; } else { Status = true; // No load, just create empty doc. } if (!Status) { DocSource = TXMLDocumentSource.xdsNone; IDOMParseError ParseError = (IDOMParseError)DOMDocument; string srcText = ParseError.SrcText; if (srcText == null) { srcText = string.Empty; } else if (srcText.Length > 40) { srcText = srcText.Substring(0, 40); } string Msg = string.Format("{0}{1}{2}: {3}{4}{5}", ParseError.Reason, Environment.NewLine, SLine, ParseError.Line, Environment.NewLine, srcText); throw new XmlException(Msg, null, ParseError.Line, ParseError.LinePos); } SetModified(false); FDOMDocument.NodeChanging += new XmlNodeChangedEventHandler(FXmlDoc_NodeChanging); FDOMDocument.NodeInserting += new XmlNodeChangedEventHandler(FXmlDoc_NodeChanging); FDOMDocument.NodeRemoving += new XmlNodeChangedEventHandler(FXmlDoc_NodeChanging); FDOMDocument.NodeChanged += new XmlNodeChangedEventHandler(FXmlDoc_NodeChanged); FDOMDocument.NodeInserted += new XmlNodeChangedEventHandler(FXmlDoc_NodeChanged); FDOMDocument.NodeRemoved += new XmlNodeChangedEventHandler(FXmlDoc_NodeChanged); }
private void SaveToStream(Stream stream) { CheckActive(); DOMPersist.SaveToStream(stream); }