本文整理汇总了C#中System.Xml.XmlNodeReader.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNodeReader.Dispose方法的具体用法?C# XmlNodeReader.Dispose怎么用?C# XmlNodeReader.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNodeReader
的用法示例。
在下文中一共展示了XmlNodeReader.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadXSL_Resolver
// --------------------------------------------------------------------------------------------------------------
// LoadXSL_Resolver
// -------------------------------------------------------------------------------------------------------------
public int LoadXSL_Resolver(String _strXslFile, XmlResolver xr)
{
_strXslFile = FullFilePath(_strXslFile);
xslt = new XslCompiledTransform();
XmlReaderSettings xrs = null;
switch (_nInputXsl)
{
case XslInputType.URI:
_output.WriteLine("Loading style sheet as URI " + _strXslFile);
xslt.Load(_strXslFile, XsltSettings.TrustedXslt, xr);
break;
case XslInputType.Reader:
switch (_readerType)
{
case ReaderType.XmlTextReader:
XmlTextReader trTemp = new XmlTextReader(_strXslFile);
try
{
_output.WriteLine("Loading style sheet as XmlTextReader " + _strXslFile);
xslt.Load(trTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (trTemp != null)
trTemp.Dispose();
}
break;
case ReaderType.XmlNodeReader:
XmlDocument docTemp = new XmlDocument();
docTemp.Load(_strXslFile);
XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
try
{
_output.WriteLine("Loading style sheet as XmlNodeReader " + _strXslFile);
xslt.Load(nrTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (nrTemp != null)
nrTemp.Dispose();
}
break;
case ReaderType.XmlValidatingReader:
default:
xrs = new XmlReaderSettings();
#pragma warning disable 0618
xrs.ProhibitDtd = false;
#pragma warning restore 0618
XmlReader vrTemp = XmlReader.Create(_strXslFile, xrs);
try
{
_output.WriteLine("Loading style sheet as XmlValidatingReader " + _strXslFile);
xslt.Load(vrTemp, XsltSettings.TrustedXslt, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (vrTemp != null)
vrTemp.Dispose();
}
break;
}
break;
case XslInputType.Navigator:
xrs = new XmlReaderSettings();
#pragma warning disable 0618
xrs.ProhibitDtd = false;
#pragma warning restore 0618
XmlReader xrLoad = XmlReader.Create(_strXslFile, xrs);
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
_output.WriteLine("Loading style sheet as Navigator " + _strXslFile);
xslt.Load(xdTemp, XsltSettings.TrustedXslt, xr);
break;
}
return 1;
}
示例2: LoadXSL_Resolver
// --------------------------------------------------------------------------------------------------------------
// LoadXSL_Resolver
// -------------------------------------------------------------------------------------------------------------
public int LoadXSL_Resolver(String _strXslFile, XmlResolver xr)
{
_strXslFile = FullFilePath(_strXslFile);
#pragma warning disable 0618
xslt = new XslTransform();
#pragma warning restore 0618
switch (_nInput)
{
case InputType.URI:
_output.WriteLine("Loading style sheet as URI {0}", _strXslFile);
xslt.Load(_strXslFile, xr);
break;
case InputType.Reader:
switch (_readerType)
{
case ReaderType.XmlTextReader:
XmlTextReader trTemp = new XmlTextReader(_strXslFile);
try
{
_output.WriteLine("Loading style sheet as XmlTextReader {0}", _strXslFile);
xslt.Load(trTemp, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (trTemp != null)
trTemp.Dispose();
}
break;
case ReaderType.XmlNodeReader:
XmlDocument docTemp = new XmlDocument();
docTemp.Load(_strXslFile);
XmlNodeReader nrTemp = new XmlNodeReader(docTemp);
try
{
_output.WriteLine("Loading style sheet as XmlNodeReader {0}", _strXslFile);
xslt.Load(nrTemp, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (nrTemp != null)
nrTemp.Dispose();
}
break;
case ReaderType.XmlValidatingReader:
default:
#pragma warning disable 0618
XmlValidatingReader vrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
vrTemp.ValidationType = ValidationType.None;
vrTemp.EntityHandling = EntityHandling.ExpandEntities;
try
{
_output.WriteLine("Loading style sheet as XmlValidatingReader {0}", _strXslFile);
xslt.Load(vrTemp, xr);
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (vrTemp != null)
vrTemp.Dispose();
}
break;
}
break;
case InputType.Navigator:
#pragma warning disable 0618
XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
_output.WriteLine("Loading style sheet as Navigator {0}", _strXslFile);
xslt.Load(xdTemp, xr);
break;
}
return 1;
}