本文整理匯總了C#中System.Xml.XmlValidatingReader.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlValidatingReader.Dispose方法的具體用法?C# XmlValidatingReader.Dispose怎麽用?C# XmlValidatingReader.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlValidatingReader
的用法示例。
在下文中一共展示了XmlValidatingReader.Dispose方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: 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;
}
示例2: SharedArgList
////////////////////////////////////////////////////////////////
// Same instance testing:
// Multiple Transform() using shared ArgumentList
////////////////////////////////////////////////////////////////
public int SharedArgList(object args)
{
string _strXslFile = ((object[])args)[1].ToString();
string _strXmlFile = ((object[])args)[2].ToString();
if (_strXslFile.Substring(0, 5) != "http:")
_strXslFile = _strPath + _strXslFile;
if (_strXmlFile.Substring(0, 5) != "http:")
_strXmlFile = _strPath + _strXmlFile;
#pragma warning disable 0618
XmlValidatingReader xrData = new XmlValidatingReader(new XmlTextReader(_strXmlFile));
XPathDocument xd = new XPathDocument(xrData, XmlSpace.Preserve);
xrData.Dispose();
XslTransform xslt = new XslTransform();
XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
xrTemp.ValidationType = ValidationType.None;
xrTemp.EntityHandling = EntityHandling.ExpandCharEntities;
xslt.Load(xrTemp);
XmlReader xrXSLT = null;
for (int i = 1; i <= 100; i++)
{
xrXSLT = xslt.Transform(xd, xsltArg1);
_output.WriteLine("SharedArgumentList: Thread " + ((object[])args)[0] + "\tIteration " + i + "\tDone with transform...");
}
return 1;
}
示例3: LoadXmlReader5
public void LoadXmlReader5()
{
Boolean fTEST_FAIL = false;
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
#pragma warning restore 0618
xrTemp.ValidationType = ValidationType.None;
xrTemp.EntityHandling = EntityHandling.ExpandEntities;
xslt.Load(xrTemp);
try
{
xslt.Load(xrTemp); // should now be at end and should give exception
fTEST_FAIL = true;
}
catch (System.Xml.Xsl.XsltCompileException e)
{
CheckExpectedError(e.InnerException, "system.xml", "Xslt_WrongStylesheetElement", new string[] { "" });
}
finally
{
xrTemp.Dispose();
}
if (fTEST_FAIL)
Assert.True(false);
return;
}
示例4: LoadXmlReader7
public void LoadXmlReader7()
{
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(FullFilePath("XmlResolver/XsltResolverTestMain.xsl")));
#pragma warning restore 0618
xrLoad.XmlResolver = GetDefaultCredResolver();
xslt.Load(xrLoad, GetDefaultCredResolver());
xrLoad.Dispose();
if ((Transform("fruits.xml") == 1) && (CheckResult(382.4519733094) == 1))
return;
Assert.True(false);
}
示例5: LoadXmlReader3
public void LoadXmlReader3()
{
Boolean fTEST_FAIL = false;
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
#pragma warning restore 0618
xrTemp.ValidationType = ValidationType.None;
xrTemp.EntityHandling = EntityHandling.ExpandEntities;
try
{
xslt.Load(xrTemp);
}
catch (Exception ex)
{
fTEST_FAIL = true;
throw (ex);
}
finally
{
if (!fTEST_FAIL || (xrTemp.ReadState != ReadState.Closed))
fTEST_FAIL = false;
xrTemp.Dispose();
}
if (fTEST_FAIL)
{
_output.WriteLine("Appear to have accidently closed the Reader");
Assert.True(false);
}
return;
}
示例6: LoadXmlReader4
public void LoadXmlReader4()
{
Boolean fTEST_FAIL = false;
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
#pragma warning restore 0618
xrTemp.ValidationType = ValidationType.None;
xrTemp.EntityHandling = EntityHandling.ExpandEntities;
try
{
xslt.Load(xrTemp);
}
catch (Exception ex)
{
fTEST_FAIL = true;
throw (ex);
}
finally
{
if (!fTEST_FAIL && (!xrTemp.EOF))
fTEST_FAIL = false;
xrTemp.Dispose();
}
if (fTEST_FAIL)
{
_output.WriteLine("Reader does not appear to be at the end of file.");
Assert.True(false);
}
return;
}
示例7: LoadXmlReader1
public void LoadXmlReader1()
{
Boolean fTEST_FAIL = false;
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
#pragma warning restore 0618
xrTemp.ValidationType = ValidationType.None;
xrTemp.EntityHandling = EntityHandling.ExpandEntities;
try
{
xslt.Load(xrTemp);
}
catch (Exception ex)
{
fTEST_FAIL = true;
throw (ex);
}
finally
{
xrTemp.Dispose();
}
if (fTEST_FAIL)
Assert.True(false);
if ((Transform("fruits.xml") == 1) && (CheckResult(466.5112789241) == 1))
return;
Assert.True(false);
}
示例8: LoadXmlReader2
public void LoadXmlReader2()
{
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
#pragma warning restore 0618
xrTemp.ValidationType = ValidationType.None;
xrTemp.EntityHandling = EntityHandling.ExpandEntities;
xrTemp.Dispose();
try
{
xslt.Load(xrTemp);
}
catch (System.Xml.Xsl.XsltCompileException e)
{
CheckExpectedError(e.InnerException, "system.xml", "Xslt_WrongStylesheetElement", new string[] { "" });
return;
}
_output.WriteLine("No exception thrown for a loading a closed reader!");
Assert.True(false);
}
示例9: LoadNavigator1
public void LoadNavigator1()
{
#pragma warning disable 0618
xslt = new XslTransform();
#pragma warning restore 0618
String _strXslFile = "showParam.xsl";
_strXslFile = FullFilePath(_strXslFile);
_output.WriteLine("Compiling {0}", _strXslFile);
#pragma warning disable 0618
XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
xslt.Load(xdTemp);
if ((Transform("fruits.xml") == 1) && (CheckResult(466.5112789241) == 1))
return;
Assert.True(false);
}
示例10: LoadNavigator2
public void LoadNavigator2()
{
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
#pragma warning restore 0618
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
XPathNavigator xP = ((IXPathNavigable)xdTemp).CreateNavigator();
xP.MoveToNext();
xslt.Load(xP);
if ((Transform("fruits.xml") == 1) && (CheckResult(466.5112789241) == 1))
return;
Assert.True(false);
}
示例11: LoadXmlReader7
public void LoadXmlReader7()
{
string expected = @"<?xml version=""1.0"" encoding=""utf-8""?><out>Red50Orange25</out>";
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(FullFilePath("XmlResolver/XsltResolverTestMain.xsl")));
#pragma warning restore 0618
xrLoad.XmlResolver = GetDefaultCredResolver();
xslt.Load(xrLoad, GetDefaultCredResolver());
xrLoad.Dispose();
if (Transform("fruits.xml") == 1)
{
VerifyResult(expected);
return;
}
Assert.True(false);
}
示例12: LoadXmlReader1
public void LoadXmlReader1()
{
string expected = @"<?xml version=""1.0"" encoding=""utf-8""?><result>
1.No Value Specified
2.No Value Specified
3.No Value Specified
4.No Value Specified
5.No Value Specified
6.No Value Specified</result>";
Boolean fTEST_FAIL = false;
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
#pragma warning restore 0618
xrTemp.ValidationType = ValidationType.None;
xrTemp.EntityHandling = EntityHandling.ExpandEntities;
try
{
xslt.Load(xrTemp);
}
catch (Exception ex)
{
fTEST_FAIL = true;
throw (ex);
}
finally
{
xrTemp.Dispose();
}
if (fTEST_FAIL)
Assert.True(false);
if (Transform("fruits.xml") == 1)
{
VerifyResult(expected);
return;
}
Assert.True(false);
}
示例13: LoadNavigator2
public void LoadNavigator2()
{
string expected = @"<?xml version=""1.0"" encoding=""utf-8""?><result>
1.No Value Specified
2.No Value Specified
3.No Value Specified
4.No Value Specified
5.No Value Specified
6.No Value Specified</result>";
#pragma warning disable 0618
xslt = new XslTransform();
XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(FullFilePath("showParam.xsl")));
#pragma warning restore 0618
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
XPathNavigator xP = ((IXPathNavigable)xdTemp).CreateNavigator();
xP.MoveToNext();
xslt.Load(xP);
if (Transform("fruits.xml") == 1)
{
VerifyResult(expected);
return;
}
Assert.True(false);
}
示例14: LoadNavigator1
public void LoadNavigator1()
{
string expected = @"<?xml version=""1.0"" encoding=""utf-8""?><result>
1.No Value Specified
2.No Value Specified
3.No Value Specified
4.No Value Specified
5.No Value Specified
6.No Value Specified</result>";
#pragma warning disable 0618
xslt = new XslTransform();
#pragma warning restore 0618
String _strXslFile = "showParam.xsl";
_strXslFile = FullFilePath(_strXslFile);
_output.WriteLine("Compiling {0}", _strXslFile);
#pragma warning disable 0618
XmlValidatingReader xrLoad = new XmlValidatingReader(new XmlTextReader(_strXslFile));
#pragma warning restore 0618
XPathDocument xdTemp = new XPathDocument(xrLoad, XmlSpace.Preserve);
xrLoad.Dispose();
xslt.Load(xdTemp);
if (Transform("fruits.xml") == 1)
{
VerifyResult(expected);
return;
}
Assert.True(false);
}
示例15: Load
public override void Load(string _strXslFile, string _strXmlFile)
{
#pragma warning disable 0618
XmlValidatingReader xrData = new XmlValidatingReader(new XmlTextReader(_strPath + _strXmlFile));
#pragma warning restore 0618
_xd = new XPathDocument(xrData, XmlSpace.Preserve);
xrData.Dispose();
#pragma warning disable 0618
XmlValidatingReader xrTemp = new XmlValidatingReader(new XmlTextReader(_strPath + _strXslFile));
xrTemp.ValidationType = ValidationType.None;
xrTemp.EntityHandling = EntityHandling.ExpandEntities;
xsltSameInstance.Load(xrTemp);
}