/// <summary> /// convenience method which initiates parsing of an XML source from string. /// </summary> /// <param name="handler"> /// XMLHandler based object which will process the XML elements. /// </param> /// <param name="source"> /// The XML source passed as a String /// </param> /// <param name="schemaName"> /// String object holding the name of the XML schema file to use for validating the XML. /// Note that whether this is used or not is dependant upon the XMLParser in use. /// </param> public virtual void ParseXmlString(XmlHandler handler, string source, string schemaName) { // Put the source string into a RawDataContainer using (var rawXMLData = new RawDataContainer()) { rawXMLData.SetData(new MemoryStream(global::System.Text.Encoding.ASCII.GetBytes(source))); try { // The actual parsing action (this is overridden and depends on the specific parser) ParseXml(handler, rawXMLData, schemaName); } catch { //// make sure we don't allow rawXMLData to release String owned data no matter what! //rawXMLData.SetData((byte[]) null); //rawXMLData.SetSize(0); //throw; } //// !!! We must not allow DataContainer to delete String owned data, //// therefore, we set it's data to 0 to avoid double-deletion //rawXMLData.SetData((byte[]) null); //rawXMLData.SetSize(0); } }
public override void LoadRawDataContainer(string filename, RawDataContainer output, string resourceGroup) { if (String.IsNullOrEmpty(filename)) { throw new InvalidRequestException("Filename supplied for data loading must be valid."); } var finalFilename = GetFinalFilename(filename, resourceGroup); var buffer = File.ReadAllBytes(finalFilename); output.SetData(new MemoryStream(buffer, 0, buffer.Length, false, true)); }