本文整理汇总了C#中XmlReaderSettings类的典型用法代码示例。如果您正苦于以下问题:C# XmlReaderSettings类的具体用法?C# XmlReaderSettings怎么用?C# XmlReaderSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlReaderSettings类属于命名空间,在下文中一共展示了XmlReaderSettings类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: v3
public int v3()
{
string xml = "<a/>";
XmlReaderSettings rs = new XmlReaderSettings();
try
{
rs.MaxCharactersFromEntities = -1;
return TEST_FAIL;
}
catch (ArgumentOutOfRangeException) { }
try
{
rs.MaxCharactersInDocument = -1;
return TEST_FAIL;
}
catch (ArgumentOutOfRangeException) { }
CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error");
CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error");
rs.MaxCharactersFromEntities = 10;
rs.MaxCharactersInDocument = 10;
using (XmlReader r = ReaderHelper.Create(new StringReader(xml), rs))
{
while (r.Read()) ;
CError.Compare((int)r.Settings.MaxCharactersFromEntities, 10, "Error");
CError.Compare((int)r.Settings.MaxCharactersInDocument, 10, "Error");
}
return TEST_PASS;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:29,代码来源:MaxSettings.cs
示例2: LoadXml
public LoadXml(Stream schemaStream)
{
m_settings = new XmlReaderSettings();
m_settings.Schemas.Add(XmlSchema.Read(schemaStream, DoValidationEvent));
m_settings.ValidationEventHandler += DoValidationEvent;
m_settings.ValidationType = ValidationType.Schema;
}
开发者ID:dbremner,项目名称:smokey,代码行数:7,代码来源:MethodCanBeMadeStaticRule.cs
示例3: Create
public override XmlReader Create(MyDict<string, object> options)
{
XmlReaderSettings settings = (XmlReaderSettings)options[ReaderFactory.HT_READERSETTINGS];
if (settings == null)
settings = new XmlReaderSettings();
Stream stream = (Stream)options[ReaderFactory.HT_STREAM];
string filename = (string)options[ReaderFactory.HT_FILENAME];
object readerType = options[ReaderFactory.HT_READERTYPE];
string fragment = (string)options[ReaderFactory.HT_FRAGMENT];
if (stream != null)
{
XmlReader reader = ReaderHelper.Create(stream, settings, filename);
return reader;
}
if (fragment != null)
{
StringReader tr = new StringReader(fragment);
XmlReader reader = ReaderHelper.Create(tr, settings, "someUri");
return reader;
}
if (filename != null)
{
XmlReader reader = ReaderHelper.Create(filename, settings);
return reader;
}
throw new CTestFailedException("No Reader Created");
}
开发者ID:noahfalk,项目名称:corefx,代码行数:33,代码来源:ReaderSettings.cs
示例4: v1
public int v1()
{
string strFile = NameTable_TestFiles.GetTestFileName(EREADER_TYPE.GENERIC);
// create custom nametable
MyXmlNameTable nt = new MyXmlNameTable();
string play = nt.Add("PLAY");
string foo = nt.Add("http://www.foo.com");
XmlReaderSettings xrs = new XmlReaderSettings();
xrs.NameTable = nt;
xrs.DtdProcessing = DtdProcessing.Ignore;
XmlReader r = XmlReader.Create(FilePathUtil.getStream(strFile), xrs);
while (r.Read()) ;
// verify name table
object play2 = nt.Get("PLAY");
object foo2 = nt.Get("http://www.foo.com");
CError.Compare((object)play == play2, "play");
CError.Compare((object)foo == foo2, "foo");
CError.Compare(nt.Get("NONEMPTY0") != null, "NONEMPTY0");
CError.WriteLine("Final count={0} atoms", nt.Count);
return TEST_PASS;
}
开发者ID:ChuangYang,项目名称:corefx,代码行数:27,代码来源:InheritNameTable.cs
示例5: v1
public int v1()
{
XmlReaderSettings rs = new XmlReaderSettings();
CError.Compare(rs.CheckCharacters, true, "CheckCharacters not true");
CError.Compare(rs.ConformanceLevel, ConformanceLevel.Document, "Conformance Level not document by default");
return TEST_PASS;
}
开发者ID:ESgarbi,项目名称:corefx,代码行数:7,代码来源:ConformanceSettings.cs
示例6: Create
public override XmlReader Create(MyDict<string, object> options)
{
string tcDesc = (string)options[ReaderFactory.HT_CURDESC];
string tcVar = (string)options[ReaderFactory.HT_CURVAR];
CError.Compare(tcDesc == "wrappedreader", "Invalid testcase");
XmlReaderSettings rs = (XmlReaderSettings)options[ReaderFactory.HT_READERSETTINGS];
Stream stream = (Stream)options[ReaderFactory.HT_STREAM];
string filename = (string)options[ReaderFactory.HT_FILENAME];
object readerType = options[ReaderFactory.HT_READERTYPE];
object vt = options[ReaderFactory.HT_VALIDATIONTYPE];
string fragment = (string)options[ReaderFactory.HT_FRAGMENT];
StringReader sr = (StringReader)options[ReaderFactory.HT_STRINGREADER];
if (rs == null)
rs = new XmlReaderSettings();
rs.DtdProcessing = DtdProcessing.Ignore;
if (sr != null)
{
CError.WriteLine("WrappedReader String");
XmlReader r = ReaderHelper.Create(sr, rs, string.Empty);
XmlReader wr = ReaderHelper.Create(r, rs);
return wr;
}
if (stream != null)
{
CError.WriteLine("WrappedReader Stream");
XmlReader r = ReaderHelper.Create(stream, rs, filename);
XmlReader wr = ReaderHelper.Create(r, rs);
return wr;
}
if (fragment != null)
{
CError.WriteLine("WrappedReader Fragment");
rs.ConformanceLevel = ConformanceLevel.Fragment;
StringReader tr = new StringReader(fragment);
XmlReader r = ReaderHelper.Create(tr, rs, (string)null);
XmlReader wr = ReaderHelper.Create(r, rs);
return wr;
}
if (filename != null)
{
CError.WriteLine("WrappedReader Filename");
Stream fs = FilePathUtil.getStream(filename);
XmlReader r = ReaderHelper.Create(fs, rs, filename);
XmlReader wr = ReaderHelper.Create(r, rs);
return wr;
}
throw new CTestFailedException("WrappedReader not created");
}
开发者ID:noahfalk,项目名称:corefx,代码行数:59,代码来源:InheritedCases.cs
示例7: v2
public int v2()
{
XmlReaderSettings rs = new XmlReaderSettings();
rs.MaxCharactersFromEntities = 1;
rs.MaxCharactersInDocument = 1;
CError.Compare((int)rs.MaxCharactersFromEntities, 1, "Error");
CError.Compare((int)rs.MaxCharactersInDocument, 1, "Error");
return TEST_PASS;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:MaxSettings.cs
示例8: XmlCustomReader
public XmlCustomReader(TextReader textReader, XmlReaderSettings settings, string baseUri)
{
XmlReader w = ReaderHelper.Create(textReader, settings, baseUri);
XmlReaderSettings wsettings = new XmlReaderSettings();
wsettings.CheckCharacters = true;
wsettings.DtdProcessing = DtdProcessing.Ignore;
wsettings.ConformanceLevel = ConformanceLevel.Auto;
_wrappedreader = ReaderHelper.Create(w, wsettings);
}
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:9,代码来源:CReader.cs
示例9: GetContent
protected SyndicationFeed GetContent()
{
XmlReaderSettings xrs = new XmlReaderSettings();
XmlReader reader = XmlReader.Create(_contentURI, xrs);
SyndicationFeed feed = SyndicationFeed.Load(reader);
return feed;
}
开发者ID:CarlosLCervantes,项目名称:D3Services,代码行数:10,代码来源:RSSReader.cs
示例10: CompareReader
public bool CompareReader(string strExpected)
{
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.CheckCharacters = false;
readerSettings.CloseInput = true;
readerSettings.ConformanceLevel = ConformanceLevel.Auto;
StringReader sr = new StringReader(strExpected);
XmlReader xrExpected = XmlReader.Create(sr, readerSettings);
return this.XmlWriterTestModule.WriterFactory.CompareReader(xrExpected);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:XmlWriterTestCaseBase.cs
示例11: v1
public int v1()
{
XmlReaderSettings rs = new XmlReaderSettings();
CError.Compare(rs.MaxCharactersFromEntities, _defaultCharsEnt, "Error");
CError.Compare(rs.MaxCharactersInDocument, _defaultCharsDoc, "Error");
using (XmlReader r = ReaderHelper.Create(new StringReader("<foo/>")))
{
CError.Compare(r.Settings.MaxCharactersFromEntities, _defaultCharsEnt, "Error");
CError.Compare(r.Settings.MaxCharactersInDocument, _defaultCharsDoc, "Error");
}
return TEST_PASS;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:MaxSettings.cs
示例12: CreateFragmentReader
public static XmlReader CreateFragmentReader(string fragment)
{
var settings = new XmlReaderSettings
{
DtdProcessing = DtdProcessing.Ignore,
CheckCharacters = false,
ConformanceLevel = ConformanceLevel.Fragment
};
var stream = new StringReader(fragment);
return XmlReader.Create(stream, settings);
}
开发者ID:noahfalk,项目名称:corefx,代码行数:13,代码来源:Utils.cs
示例13: LoadDocumentFromFile
public void LoadDocumentFromFile()
{
TextReader textReader = File.OpenText(@"example.xml");
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
settings.DtdProcessing = DtdProcessing.Ignore;
XmlDocument doc = new XmlDocument();
using (StringReader sr = new StringReader(textReader.ReadToEnd()))
using (XmlReader reader = XmlReader.Create(sr, settings))
{
doc.Load(reader);
}
}
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:LoadTests.cs
示例14: DisposeDisposesInputStream
public static void DisposeDisposesInputStream()
{
bool[] asyncValues = { false, true };
bool[] closeInputValues = { false, true };
foreach (var async in asyncValues)
foreach (var closeInput in closeInputValues)
{
using (Stream s = CreateXmlStream())
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.Async = async;
settings.CloseInput = closeInput;
XmlReader reader = XmlReader.Create(s, settings);
if (async)
{
// Underlying Stream is not being disposed when using async and not reading anything
// async is delaying initialization until you start to read (allegedly to not block on IO when creating reader)
reader.Read();
}
reader.Dispose();
if (closeInput)
{
Assert.Throws<ObjectDisposedException>(() =>
{
s.Position = 0;
s.ReadByte();
});
}
else
{
s.Position = 0;
s.ReadByte();
// does not throw ObjectDisposedException
}
// should not throw
reader.Dispose();
}
}
}
开发者ID:noahfalk,项目名称:corefx,代码行数:42,代码来源:DisposeTests.cs
示例15: pi00
public int pi00()
{
XmlReaderSettings settings = new XmlReaderSettings();
if (settings.IgnoreProcessingInstructions == true)
{
CError.WriteLineIgnore("RS default value = true");
return TEST_FAIL;
}
if (settings.IgnoreComments == true)
{
CError.WriteLineIgnore("RS Comm default value = true");
return TEST_FAIL;
}
if (settings.IgnoreWhitespace == true)
{
CError.WriteLineIgnore("RS WS default value = true");
return TEST_FAIL;
}
return TEST_PASS;
}
开发者ID:noahfalk,项目名称:corefx,代码行数:21,代码来源:FilterSettings.cs
示例16: wrappingTests
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Auto", "Auto", "<root/>", "true" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Auto", "Auto", "<root/><root/>", "true" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Fragment", "Auto", "<root/><root/>", "true" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Document", "Auto", "<root/>", "true" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Auto", "Fragment", "<root/>", "false" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Fragment", "Fragment", "<root/>", "true" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Fragment", "Fragment", "<root/><root/>", "true" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Document", "Fragment", "<root/>", "false" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Auto", "Document", "<root/>", "false" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Fragment", "Document", "<root/><root/>", "false" })]
//[Variation("Wrapping Tests: CR with CR", Pri = 2, Params = new object[] { "Document", "Document", "<root/>", "true" })]
public int wrappingTests()
{
string underlyingReaderLevel = this.CurVariation.Params[0].ToString();
string wrappingReaderLevel = this.CurVariation.Params[1].ToString();
string conformanceXml = this.CurVariation.Params[2].ToString();
bool valid = this.CurVariation.Params[3].ToString() == "true";
CError.WriteLine(underlyingReaderLevel);
CError.WriteLine(wrappingReaderLevel);
CError.WriteLine(conformanceXml);
CError.WriteLine("IsValid = " + valid);
try
{
XmlReaderSettings rsU = new XmlReaderSettings();
rsU.ConformanceLevel = (ConformanceLevel)Enum.Parse(typeof(ConformanceLevel), underlyingReaderLevel);
XmlReader rU = ReaderHelper.Create(new StringReader(conformanceXml), rsU, (string)null);
XmlReaderSettings rsW = new XmlReaderSettings();
rsW.ConformanceLevel = (ConformanceLevel)Enum.Parse(typeof(ConformanceLevel), wrappingReaderLevel);
XmlReader rW = ReaderHelper.Create(rU, rsW);
CError.Compare(rW.ReadState, ReadState.Initial, "ReadState not initial");
}
catch (InvalidOperationException ioe)
{
CError.WriteLineIgnore(ioe.ToString());
if (valid)
throw new CTestFailedException("Valid case throws InvalidOperation");
else
return TEST_PASS;
}
if (!valid)
throw new CTestFailedException("Invalid case doesn't throw InvalidOperation");
else
return TEST_PASS;
}
开发者ID:ESgarbi,项目名称:corefx,代码行数:52,代码来源:ConformanceSettings.cs
示例17: XmlLang_5
//[Variation(id = 5, Desc = "Veify XmlLang value when received through WriteAttributes", Pri = 1)]
public int XmlLang_5()
{
XmlReaderSettings xrs = new XmlReaderSettings();
xrs.IgnoreWhitespace = true;
XmlReader tr = XmlReader.Create(FilePathUtil.getStream(FullPath("XmlReader.xml")), xrs);
while (tr.Read())
{
if (tr.LocalName == "XmlLangNode")
{
tr.Read();
tr.MoveToNextAttribute();
break;
}
}
using (XmlWriter w = CreateWriter())
{
w.WriteStartElement("Root");
w.WriteAttributes(tr, false);
CError.Compare(w.XmlLang, "fr", "Error");
w.WriteEndElement();
}
return TEST_PASS;
}
开发者ID:dotnet,项目名称:corefx,代码行数:27,代码来源:CommonTests.cs
示例18: element_bug480250
//[Variation(Desc = "WriteNode with euc-jp encoding.pr-xml-euc-jp.xml", Param = "pr-xml-euc-jp.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.pr-xml-iso-2022-jp.xml", Param = "pr-xml-iso-2022-jp.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.pr-xml-little-endian.xml", Param = "pr-xml-little-endian.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.pr-xml-shift_jis.xml", Param = "pr-xml-shift_jis.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.pr-xml-utf-8.xml", Param = "pr-xml-utf-8.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.pr-xml-utf-16.xml", Param = "pr-xml-utf-16.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.weekly-euc-jp.xml", Param = "weekly-euc-jp.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.weekly-iso-2022-jp.xml", Param = "weekly-iso-2022-jp.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.weekly-little-endian.xml", Param = "weekly-little-endian.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.weekly-shift_jis.xml", Param = "weekly-shift_jis.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.weekly-utf-8.xml", Param = "weekly-utf-8.xml")]
//[Variation(Desc = "WriteNode with euc-jp encoding.weekly-utf-16.xml", Param = "weekly-utf-16.xml")]
public int element_bug480250()
{
string path = FilePathUtil.GetStandardPath();
string xml = (string)CurVariation.Param;
string uri = path + @"\XML10\xmlconf\japanese\" + xml;
XmlReaderSettings rs = new XmlReaderSettings();
rs.IgnoreWhitespace = true;
using (XmlReader r = ReaderHelper.Create(uri, rs))
{
XmlWriterSettings ws = new XmlWriterSettings();
ws.Encoding = System.Text.Encoding.GetEncoding("euc-jp");
using (XmlWriter w = WriterHelper.Create(@"out.xml", ws))
{
w.WriteNode(r, true);
}
}
return TEST_PASS;
}
开发者ID:dotnet,项目名称:corefx,代码行数:30,代码来源:CommonTests.cs
示例19: Validate
internal XmlReader Validate(XmlReader reader, XmlResolver resolver, XmlSchemaSet schemaSet, ValidationEventHandler valEventHandler) {
if (schemaSet != null) {
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.ValidationType = ValidationType.Schema;
readerSettings.Schemas = schemaSet;
readerSettings.ValidationEventHandler += valEventHandler;
return new XsdValidatingReader(reader, resolver, readerSettings, this);
}
return null;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:10,代码来源:XmlSchemaAttribute.cs
示例20: NS_Handling_30a
//[Variation(Desc = "Reader got the default namespaces as default attribute from DTD.Default", Param = NamespaceHandling.Default)]
//[Variation(Desc = "Reader got the default namespaces as default attribute from DTD.OmitDuplicates", Param = NamespaceHandling.OmitDuplicates)]
public int NS_Handling_30a()
{
string xml = "<!DOCTYPE doc " +
"[<!ELEMENT doc ANY>" +
"<!ELEMENT test1 (#PCDATA)>" +
"<!ELEMENT test2 ANY>" +
"<!ELEMENT test3 (#PCDATA)>" +
"<!ENTITY e1 \"&e2;\">" +
"<!ENTITY e2 \"xmlns='x'\">" +
"<!ATTLIST test3 a1 CDATA #IMPLIED>" +
"<!ATTLIST test3 a2 CDATA #IMPLIED>" +
"]>" +
"<doc xmlns:p='&e2;'>" +
" &e2;" +
" <test1 xmlns:p='&e2;'>AA&e2;AA</test1>" +
" <test2 xmlns:p='&e1;'>BB&e1;BB</test2>" +
" <test3 a1=\"&e2;\" a2=\"&e1;\">World</test3>" +
"</doc>";
string exp = ((NamespaceHandling)this.CurVariation.Param == NamespaceHandling.OmitDuplicates) ?
"<!DOCTYPE doc [<!ELEMENT doc ANY><!ELEMENT test1 (#PCDATA)><!ELEMENT test2 ANY><!ELEMENT test3 (#PCDATA)><!ENTITY e1 \"&e2;\"><!ENTITY e2 \"xmlns='x'\"><!ATTLIST test3 a1 CDATA #IMPLIED><!ATTLIST test3 a2 CDATA #IMPLIED>]><doc xmlns:p=\"xmlns='x'\"> xmlns='x' <test1>AAxmlns='x'AA</test1> <test2>BBxmlns='x'BB</test2> <test3 a1=\"xmlns='x'\" a2=\"xmlns='x'\">World</test3></doc>" :
"<!DOCTYPE doc [<!ELEMENT doc ANY><!ELEMENT test1 (#PCDATA)><!ELEMENT test2 ANY><!ELEMENT test3 (#PCDATA)><!ENTITY e1 \"&e2;\"><!ENTITY e2 \"xmlns='x'\"><!ATTLIST test3 a1 CDATA #IMPLIED><!ATTLIST test3 a2 CDATA #IMPLIED>]><doc xmlns:p=\"xmlns='x'\"> xmlns='x' <test1 xmlns:p=\"xmlns='x'\">AAxmlns='x'AA</test1> <test2 xmlns:p=\"xmlns='x'\">BBxmlns='x'BB</test2> <test3 a1=\"xmlns='x'\" a2=\"xmlns='x'\">World</test3></doc>";
XmlWriterSettings wSettings = new XmlWriterSettings();
wSettings.NamespaceHandling = (NamespaceHandling)this.CurVariation.Params[0];
XmlReaderSettings rs = new XmlReaderSettings();
using (XmlReader r = ReaderHelper.Create(new StringReader(xml), rs))
{
using (XmlWriter w = CreateMemWriter(wSettings))
{
w.WriteNode(r, false);
}
}
VerifyOutput(exp); return TEST_PASS;
}
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:36,代码来源:NamespaceHandlingTests.cs
注:本文中的XmlReaderSettings类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论