本文整理汇总了C#中XmlReader.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.Dispose方法的具体用法?C# XmlReader.Dispose怎么用?C# XmlReader.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlReader
的用法示例。
在下文中一共展示了XmlReader.Dispose方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParsePartialContent
internal XmlNamespaceManager ParsePartialContent(XmlNode parentNode, string innerxmltext, XmlNodeType nt)
{
//the function shouldn't be used to set innerxml for XmlDocument node
Debug.Assert(parentNode.NodeType != XmlNodeType.Document);
_doc = parentNode.OwnerDocument;
Debug.Assert(_doc != null);
XmlParserContext pc = GetContext(parentNode);
_reader = CreateInnerXmlReader(innerxmltext, nt, pc, _doc);
try
{
_preserveWhitespace = true;
bool bOrigLoading = _doc.IsLoading;
_doc.IsLoading = true;
if (nt == XmlNodeType.Entity)
{
XmlNode node = null;
while (_reader.Read() && (node = LoadNodeDirect()) != null)
{
parentNode.AppendChildForLoad(node, _doc);
}
}
else
{
XmlNode node = null;
while (_reader.Read() && (node = LoadNode(true)) != null)
{
parentNode.AppendChildForLoad(node, _doc);
}
}
_doc.IsLoading = bOrigLoading;
}
finally
{
_reader.Dispose();
}
return pc.NamespaceManager;
}
示例2: NestRead
private XmlReader NestRead(XmlReader r)
{
r.Read();
r.Read();
if (!(r.Name == "elem0" && r.NodeType == XmlNodeType.Element))
{
NestRead(r.ReadSubtree());
}
r.Dispose();
return r;
}
示例3: TransformResolver
public int TransformResolver(String szXmlFile, XmlResolver xr, bool errorCase)
{
lock (s_outFileMemoryLock)
{
szXmlFile = FullFilePath(szXmlFile);
_output.WriteLine("Loading XML {0}", szXmlFile);
IXPathNavigable xd = LoadXML(szXmlFile, _docType);
_output.WriteLine("Executing transform");
xrXSLT = null;
Stream strmTemp = null;
switch (_nTransform)
{
case TransformType.Reader:
xrXSLT = xslt.Transform(xd, null, xr);
if (errorCase)
{
try
{
while (xrXSLT.Read()) { }
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (xrXSLT != null)
xrXSLT.Dispose();
}
}
break;
case TransformType.Stream:
try
{
strmTemp = new FileStream(_strOutFile, FileMode.Create, FileAccess.ReadWrite);
xslt.Transform(xd, null, strmTemp, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (strmTemp != null)
strmTemp.Dispose();
}
break;
case TransformType.Writer:
XmlWriter xw = null;
try
{
xw = new XmlTextWriter(_strOutFile, Encoding.UTF8);
xw.WriteStartDocument();
xslt.Transform(xd, null, xw, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (xw != null)
xw.Dispose();
}
break;
case TransformType.TextWriter:
TextWriter tw = null;
try
{
tw = new StreamWriter(new FileStream(_strOutFile, FileMode.Create, FileAccess.Write), Encoding.UTF8);
xslt.Transform(xd, null, tw, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (tw != null)
tw.Dispose();
}
break;
}
return 1;
}
}
示例4: Load
public void Load(string _strXslFile, string _strXmlFile)
{
_xrData = XmlReader.Create(_strPath + _strXmlFile);
_xd = new XPathDocument(_xrData, XmlSpace.Preserve);
_xrData.Dispose();
XmlReaderSettings xrs = new XmlReaderSettings();
#pragma warning disable 0618
xrs.ProhibitDtd = false;
#pragma warning restore 0618
XmlReader xrTemp = XmlReader.Create(_strPath + _strXslFile, xrs);
xsltSameInstance.Load(xrTemp);
}
示例5: LoadFromConfigXmlReader
private void LoadFromConfigXmlReader(ConfigXmlReader reader)
{
IConfigErrorInfo err = (IConfigErrorInfo) reader;
_filename = err.Filename;
_lineOffset = err.LineNumber + 1;
try {
_reader = reader;
base.Load(_reader);
}
finally {
if (_reader != null) {
_reader.Dispose();
_reader = null;
}
}
}
示例6: Load
public void Load(string filename)
{
_filename = filename;
try {
_reader = XmlReader.Create(filename);
//_reader.XmlResolver = null;
base.Load(_reader);
}
finally {
if (_reader != null) {
_reader.Dispose();
_reader = null;
}
}
}
示例7: CompareReader
public bool CompareReader(XmlReader xrExpected, XmlDiffOption option)
{
bool bReturn = false;
XmlReader xrActual = GetReader();
XmlDiff diff = new XmlDiff();
diff.Option = option;
try
{
bReturn = diff.Compare(xrExpected, xrActual);
}
catch (Exception e)
{
CError.WriteLine(e);
}
finally
{
xrActual.Dispose();
xrExpected.Dispose();
}
if (!bReturn)
{
CError.WriteLine("Mismatch in XmlDiff");
CError.WriteLine("Actual o/p:");
CError.WriteLine(this.GetString());
}
return bReturn;
}
示例8: destroyXmlReader
private void destroyXmlReader(XmlReader xmlreader)
{
if (xmlreader != null)
{ xmlreader.Close(); xmlreader.Dispose(); }
}