本文整理汇总了C#中System.Xml.XmlReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReader.Close方法的具体用法?C# XmlReader.Close怎么用?C# XmlReader.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlReader
的用法示例。
在下文中一共展示了XmlReader.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: expandNamespace_namespace
private void expandNamespace_namespace(TreeNodeCollection outNodes, TreeNode outInstanceMethods, string strSection, string strNamespace, XmlReader reader)
{
bool bContinue = reader.ReadToDescendant("namespace");
while (bContinue)
{
if (reader.GetAttribute("name") == strNamespace)
{
expandNamespace_function(outNodes, outInstanceMethods, strSection, strNamespace, reader.ReadSubtree());
reader.Close();
return;
}
bContinue = ReadToNextSibling(reader, "namespace");
}
reader.Close();
}
示例2: expandNamespace_function
private void expandNamespace_function(TreeNodeCollection outNodes, TreeNode outInstanceMethods, string strSection, string strNamespace, XmlReader reader)
{
bool bContinue = reader.ReadToDescendant("function");
while (bContinue)
{
// if (reader.GetAttribute("args") != null) MessageBox.Show("instance?");
NodeDocLnzFunction node = new NodeDocLnzFunction(strSection, strNamespace, reader.GetAttribute("name"));
bool bInstance = reader.GetAttribute("instance") == "true";
node.bIsInstanceMethod = bInstance;
string strArgs = reader.GetAttribute("args"); if (strArgs != null && strArgs != "") node.strArguments = strArgs;
string strReturns = reader.GetAttribute("returns"); if (strReturns != null && strReturns != "") node.strReturns = strReturns;
node.strDocumentationAndExample = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example
if (bInstance)
{
//MessageBox.Show("instance found");
outInstanceMethods.Nodes.Add(node);
}
else
outNodes.Add(node);
bContinue = ReadToNextSibling(reader, "function");
}
reader.Close();
}
示例3: expandNamespace_function
private void expandNamespace_function(TreeNodeCollection outNodes, string strSection, string strNamespace, XmlReader reader)
{
bool bContinue = reader.ReadToDescendant("function");
while (bContinue)
{
NodeDocPythonFunction node = newnode(strSection, strNamespace, reader.GetAttribute("name"));
outNodes.Add(node);
bool bInstance = reader.GetAttribute("instance") == "true";
node.bIsInstanceMethod = bInstance;
string strSyntax = reader.GetAttribute("fullsyntax"); if (strSyntax != null && strSyntax != "") node.strFullSyntax = strSyntax;
node.strDocumentation = getFunctionDocAndExample(reader.ReadSubtree()); //assumes doc before example
if (this.emphasizeStaticness())
{
if (!bInstance)
{
//change visible node text to emphasize static-ness
node.Text = node.strNamespacename + "." + node.strFunctionname;
}
}
bContinue = ReadToNextSibling(reader, "function");
}
reader.Close();
}
示例4: Task1
public string Task1()
{
reader = XmlReader.Create(FILE_NAME);
decimal in_v = 0;
decimal out_v = 0;
while (reader.Read())
{
if (reader.IsStartElement())
{
switch (reader.Name)
{
case IN_V:
if(reader.Read())
in_v += Convert.ToDecimal(reader.Value.Trim());
break;
case OUT_V:
if (reader.Read())
out_v += Convert.ToDecimal(reader.Value.Trim());
break;
}
}
}
reader.Close();
return IN_V + in_v.ToString() + "\n" + OUT_V + out_v.ToString();
}
示例5: ReadXmlSerializable
private static void ReadXmlSerializable(DataTable dt, XmlReader xr)
{
XmlSerializer serializer = new XmlSerializer(dt.GetType());
IXmlSerializable idt = dt;
idt.ReadXml(xr);
xr.Close();
}
示例6: ReadResults
void ReadResults(XmlReader reader)
{
CodeCoverageModule currentModule = null;
CodeCoverageMethod currentMethod = null;
string currentClassName = String.Empty;
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element:
if (reader.Name == "Type") {
currentModule = AddModule(reader);
currentClassName = reader.GetAttribute("name");
} else if ((reader.Name == "Method") && (currentModule != null)) {
currentMethod = AddMethod(currentModule, currentClassName, reader);
} else if ((reader.Name == "pt") && (currentMethod != null)) {
AddSequencePoint(currentMethod, reader);
} else if (reader.Name == "File") {
AddFileName(reader);
} else if (reader.Name == "Assembly") {
AddAssembly(reader);
}
break;
}
}
reader.Close();
}
示例7: Disc
internal Disc (XmlReader reader)
{
reader.Read ();
int.TryParse (reader ["sectors"], out sectors);
id = reader ["id"];
reader.Close ();
}
示例8: DataHandler
XDocument settings; //xml settings document
#endregion Fields
#region Constructors
public DataHandler()
{
//instantiate lists
history = new History();
bookmarks = new Bookmarks();
//set path to user.home
path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\settings.xml";
//Read xml from user home, if no document exist, skip
try
{
reader = XmlTextReader.Create(@path);
settings = XDocument.Load(reader);
//create objects and lists from xml
loadBookmarks();
loadHistory();
loadHomePage();
reader.Close();
}
catch (FileNotFoundException)
{
//skip this step
}
}
示例9: updateLastPost
private void updateLastPost()
{
reader = XmlReader.Create(URL);
SyndicationFeed feed = SyndicationFeed.Load(reader);
reader.Close();
lastPost = feed.Items.First();
}
示例10: ReadResults
void ReadResults(XmlReader reader)
{
CodeCoverageModule currentModule = null;
CodeCoverageMethod currentMethod = null;
string currentClassName = String.Empty;
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element:
if (reader.Name == "Type") {
currentModule = AddModule(reader);
currentClassName = reader.GetAttribute("name");
} else if ((reader.Name == "Method") && (currentModule != null) && (!reader.IsEmptyElement)) {
currentMethod = AddMethod(currentModule, currentClassName, reader);
} else if ((reader.Name == "pt") && (currentMethod != null)) {
AddSequencePoint(currentMethod, reader);
} else if (reader.Name == "File") {
AddFileName(reader);
} else if (reader.Name == "Assembly") {
AddAssembly(reader);
}
break;
case XmlNodeType.EndElement:
if (currentMethod != null && reader.Name == "Method" && currentMethod.SequencePoints.Count == 0) {
// Remove method that has no sequence points.
currentModule.Methods.Remove(currentMethod);
}
break;
}
}
reader.Close();
RemoveModulesWithNoMethods();
}
示例11: Load
public bool Load(string FileName)
{
if (!File.Exists(FileName)) return false;
if ((new FileInfo(FileName).Length) == 0)
{
File.Delete(FileName);
return false;
}
F = XmlReader.Create(FileName);
try
{
F.MoveToContent();
}
catch (Exception)
{
F.Close();
File.Delete(FileName);
return false;
}
return true;
}
示例12: ReadOuterXml
private string ReadOuterXml(XmlReader forReader) {
try {
forReader.MoveToContent();
return forReader.ReadOuterXml();
} finally {
forReader.Close();
}
}
示例13: DeSerializeObject
/// <summary>
/// Serializes an object instance to a file.
/// </summary>
/// <param name="instance">the object instance to serialize</param>
/// <param name="resultBuffer">The result buffer.</param>
/// <param name="throwExceptions">if set to <c>true</c> [throw exceptions].</param>
/// <returns></returns>
/// <summary>
/// Serializes an object to an XML string. Unlike the other SerializeObject overloads
/// this methods *returns a string* rather than a bool result!
/// </summary>
/// <param name="instance"></param>
/// <param name="throwExceptions">Determines if a failure throws or returns null</param>
/// <returns>
/// null on error otherwise the Xml String.
/// </returns>
/// <remarks>
/// If null is passed in null is also returned so you might want
/// to check for null before calling this method.
/// </remarks>
/// <summary>
/// Deserializes an object from file and returns a reference.
/// </summary>
/// <param name="fileName">name of the file to serialize to</param>
/// <param name="objectType">The Type of the object. Use typeof(yourobject class)</param>
/// <param name="binarySerialization">determines whether we use Xml or Binary serialization</param>
/// <returns>Instance of the deserialized object or null. Must be cast to your object type</returns>
/// <summary>
/// Deserializes an object from file and returns a reference.
/// </summary>
/// <param name="fileName">name of the file to serialize to</param>
/// <param name="objectType">The Type of the object. Use typeof(yourobject class)</param>
/// <param name="binarySerialization">determines whether we use Xml or Binary serialization</param>
/// <param name="throwExceptions">determines whether failure will throw rather than return null on failure</param>
/// <returns>Instance of the deserialized object or null. Must be cast to your object type</returns>
/// <summary>
/// Deserialize an object from an XmlReader object.
/// </summary>
/// <param name="reader"></param>
/// <param name="objectType"></param>
/// <returns></returns>
public static object DeSerializeObject(XmlReader reader, Type objectType)
{
var serializer = new XmlSerializer(objectType);
var instance = serializer.Deserialize(reader);
reader.Close();
return instance;
}
示例14: DeserializePropertyElement
protected override void DeserializePropertyElement(XmlReader reader)
{
if (reader.Name.ToLower () == "optional") {
optional = true;
reader.Close ();
} else {
base.DeserializePropertyElement (reader);
}
}
示例15: Compile
/// <exclude />
public void Compile(XmlReader reader, IFormChannelIdentifier channel,
Dictionary<string, object> bindingObjects, bool withDebug, string customControlIdPrefix,
Dictionary<string, List<ClientValidationRule>> bindingsValidationRules)
{
XDocument doc = XDocument.Load(reader);
reader.Close();
Compile(doc, channel, bindingObjects, withDebug, customControlIdPrefix, bindingsValidationRules);
}