本文整理匯總了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;
}