本文整理汇总了C#中XmlReaderSettings类的典型用法代码示例。如果您正苦于以下问题:C# XmlReaderSettings类的具体用法?C# XmlReaderSettings怎么用?C# XmlReaderSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlReaderSettings类属于命名空间,在下文中一共展示了XmlReaderSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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");
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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);
}
示例9: GetContent
protected SyndicationFeed GetContent()
{
XmlReaderSettings xrs = new XmlReaderSettings();
XmlReader reader = XmlReader.Create(_contentURI, xrs);
SyndicationFeed feed = SyndicationFeed.Load(reader);
return feed;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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();
}
}
}
示例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;
}