当前位置: 首页>>代码示例>>C#>>正文


C# XmlNodeReader.Close方法代码示例

本文整理汇总了C#中System.Xml.XmlNodeReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNodeReader.Close方法的具体用法?C# XmlNodeReader.Close怎么用?C# XmlNodeReader.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlNodeReader的用法示例。


在下文中一共展示了XmlNodeReader.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: isSuper

 //�ΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡΡ�
 public bool isSuper(FileInfo obFile, FileInfo obExtends)
 {
     string infoPath = m_obFinder.getClassPath(obExtends.Name.Replace(".as", ""));
     if (File.Exists(infoPath))
     {
         XmlDocument xml = new XmlDocument();
         xml.Load(infoPath);
         XmlNodeReader reader = new XmlNodeReader(xml);
         while (reader.Read())
         {
             if (reader.NodeType == XmlNodeType.Element)
             {
                 if (reader.Name == "item")
                 {
                     string className = reader.GetAttribute("name");
                     string superSign = reader.GetAttribute("super");
                     if (className == obFile.Name.Replace(".as", ""))
                     {
                         if (superSign != null)
                         {
                             reader.Close();
                             //ErrorBox.Show(obExtends.Name + " extends " + obFile.Name,"ClassRelationsFinderError");
                             return true;
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:r1ng0to3tour,项目名称:swsplayer,代码行数:32,代码来源:ClassRelationsFinder.cs

示例2: WMIBMySQL

 public WMIBMySQL()
 {
     string file = Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + "unwrittensql.xml";
     Core.RecoverFile(file);
     if (File.Exists(file))
     {
         Syslog.WarningLog("There is a mysql dump file from previous run containing mysql rows that were never successfuly inserted, trying to recover them");
         XmlDocument document = new XmlDocument();
         TextReader sr = new StreamReader(file);
         document.Load(sr);
         XmlNodeReader reader = new XmlNodeReader(document.DocumentElement);
         XmlSerializer xs = new XmlSerializer(typeof(Unwritten));
         Unwritten un = (Unwritten)xs.Deserialize(reader);
         reader.Close();
         sr.Close();
         lock (unwritten.PendingRows)
         {
             unwritten.PendingRows.AddRange(un.PendingRows);
         }
     }
     reco = new Thread(Exec);
     reco.Name = "Recovery";
     Core.ThreadManager.RegisterThread(reco);
     reco.Start();
 }
开发者ID:johnduhart,项目名称:wikimedia-bot,代码行数:25,代码来源:MySQL.cs

示例3: Deserialize

 /// <summary>
 /// Deserializes this xml document and convert it to a ChmProject object.
 /// </summary>
 /// <returns>The ChmProject object readed from the xml.</returns>
 public ChmProject Deserialize()
 {
     XmlReader reader = new XmlNodeReader(this);
     XmlSerializer serializer = new XmlSerializer(typeof(ChmProject));
     ChmProject cfg = (ChmProject)serializer.Deserialize(reader);
     reader.Close();
     return cfg;
 }
开发者ID:huoxudong125,项目名称:chmProcessor,代码行数:12,代码来源:ChmProjectXml.cs

示例4: XMLToCSV

        /// <summary>
        /// Converts an XML file to CSV
        /// </summary>
        /// <param name="xmlDoc">An XML file</param>
        /// <returns></returns>
        public static String XMLToCSV(System.Xml.XmlDocument xmlDoc)
        {
            DataSet dataSet = new DataSet();
            using( XmlNodeReader xmlReader = new XmlNodeReader(xmlDoc) )
            {
                dataSet.ReadXml(xmlReader);
                xmlReader.Close();
            }

            return dtToCSV(dataSet.Tables[0]);
        }
开发者ID:GFTUSA,项目名称:GFTInternal,代码行数:16,代码来源:DataTableToCSV.cs

示例5: Create

        public object Create(object parent, object configContext, XmlNode section)
        {
            XmlSerializer ser = new XmlSerializer(typeof(MinecraftConfig));
            MinecraftConfig config = null;

            using (XmlNodeReader reader = new XmlNodeReader(section))
            {
                config = ser.Deserialize(reader) as MinecraftConfig;
                reader.Close();
            }

            return config;
        }
开发者ID:jar349,项目名称:Minecraft-Windows-Service,代码行数:13,代码来源:MinecraftConfig.cs

示例6: GetXml

        /// <summary>
        /// 获取XML
        /// </summary>
        /// <param name="xmlFile"></param>
        /// <returns></returns>
        // xmlFile = HttpContext.Server.MapPath("~/Student.xml")
        public string GetXml(string xmlFile)
        {
            string id = "";
            string Info = "";

            if (XmlDoc == null)
            {
                lock (DocLock)
                {
                    if (XmlDoc == null)
                    {
                        XmlDoc = new XmlDocument();
                        XmlDoc.Load(xmlFile);
                    }
                }
            }

            string Name = string.Empty;
            string _id = string.Empty;
            XmlElement root = XmlDoc.DocumentElement;
            XmlNodeList personNodes = root.GetElementsByTagName("person");
            foreach (XmlNode node in personNodes)
            {
                if (((XmlElement)node).GetAttribute("id") == "2" || ((XmlElement)node).GetAttribute("id") == "4")
                {
                    Name += ((XmlElement)node).InnerText;
                    _id += ((XmlElement)node).GetAttribute("id");
                    var str = node.GetEnumerator();
                }
            }

            XmlNodeReader ParaReader = new XmlNodeReader(XmlDoc);
            while (ParaReader.Read())
            {
                if (ParaReader.NodeType == XmlNodeType.Element && ParaReader.Name == "person")
                {
                    if (!string.IsNullOrEmpty(ParaReader.GetAttribute("id")))
                    {
                        id += ParaReader.GetAttribute("id") + "+";
                        Info += ParaReader.ReadInnerXml() + "+";

                    }
                    //if (f == "PaymentDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute(1);//Info = ParaReader.GetAttribute(1).Replace("{2}", Member.ValidBeginDate + "");//缴费
                    //if (f == "ReplacementDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute("value");//Info = ParaReader.GetAttribute("value").Replace("{2}", Member.ValidBeginDate + "").Replace("{3}", Member.ReplacementDate + "");  //换证 
                    //if (f == "ContributionsDate" && f == ParaReader.GetAttribute(0)) Info = ParaReader.GetAttribute("value"); //体检 
                }
                string str = ParaReader.GetAttribute("id") + ParaReader.GetAttribute("sex") + ParaReader.ReadInnerXml();
            }
            ParaReader.Close();
            return System.Text.Encoding.GetEncoding("gb2312").GetString(System.Text.Encoding.Default.GetBytes(id + "\n" + Info));
        }
开发者ID:qinfengwangyi,项目名称:Qin.Blog,代码行数:57,代码来源:XmlHelper.cs

示例7: GetOpenDentalConnStr

		///<summary></summary>
		private string GetOpenDentalConnStr() {
			XmlDocument document=new XmlDocument();
			string path=ODFileUtils.CombinePaths(Application.StartupPath,"FreeDentalConfig.xml");
			if(!File.Exists(path)) {
				return "";
			}
			string computerName="";
			string database="";
			string user="";
			string password="";
			try {
				document.Load(path);
				XmlNodeReader reader=new XmlNodeReader(document);
				string currentElement="";
				while(reader.Read()) {
					if(reader.NodeType==XmlNodeType.Element) {
						currentElement=reader.Name;
					}
					else if(reader.NodeType==XmlNodeType.Text) {
						switch(currentElement) {
							case "ComputerName":
								computerName=reader.Value;
								break;
							case "Database":
								database=reader.Value;
								break;
							case "User":
								user=reader.Value;
								break;
							case "Password":
								password=reader.Value;
								break;
						}
					}
				}
				reader.Close();
			}
			catch {
				return "";
			}
			//example:
			//Server=localhost;Database=opendental;User ID=root;Password=;CharSet=utf8
			return "Server="+computerName
				+";Database="+database
				+";User ID="+user
				+";Password="+password
				+";CharSet=utf8";
		}
开发者ID:mnisl,项目名称:OD,代码行数:49,代码来源:DataConnection.cs

示例8: FormDatabaseCheck_Load

		private void FormDatabaseCheck_Load(object sender,EventArgs e) {
			XmlDocument document=new XmlDocument();
			if(!File.Exists("FreeDentalConfig.xml")) {
				textComputerName.Text="localhost";
				#if(TRIALONLY)
					textDatabase.Text="demo";
				#else
					textDatabase.Text="opendental";
				#endif
				textUser.Text="root";
				return;
			}
			try {
				document.Load("FreeDentalConfig.xml");
				XmlNodeReader reader=new XmlNodeReader(document);
				string currentElement="";
				while(reader.Read()) {
					if(reader.NodeType==XmlNodeType.Element) {
						currentElement=reader.Name;
					}
					else if(reader.NodeType==XmlNodeType.Text) {
						switch(currentElement) {
							case "ComputerName":
								textComputerName.Text=reader.Value;
								break;
							case "Database":
								textDatabase.Text=reader.Value;
								break;
							case "User":
								textUser.Text=reader.Value;
								break;
							case "Password":
								textPassword.Text=reader.Value;
								break;
						}
					}
				}
				reader.Close();
			}
			catch {//Exception e) {
				//MessageBox.Show(e.Message);
				textComputerName.Text="localhost";
				textDatabase.Text="opendental";
				textUser.Text="root";
			}
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:46,代码来源:FormDatabaseCheck.cs

示例9: Validate

        /// <summary>
        /// Validates <paramref name="xmlString"/> using the XSD schema stored at <paramref name="xsdPath"/>.
        /// </summary>
        /// <param name="xmlString">The Xml string to validate.</param>
        /// <param name="xsdPath">The path of the XSD schema file.</param>
        /// <returns>True when <paramref name="xmlString"/> is valid according to xsd schema at <paramref name="xsdPath"/> or false otherwise.</returns>
        /// <exception cref="System.NullReferenceException">Thrown when <paramref name="xmlString"/> or <paramref name="xsdPath"/> is null.</exception>
        public bool Validate(string xmlString, string xsdPath)
        {
            if (string.IsNullOrEmpty(xmlString))
                throw new System.ArgumentNullException("Xml string is null or empty.");
            if (string.IsNullOrEmpty(xsdPath))
                throw new System.ArgumentNullException("Xsd path is null or empty.");

            xsdPath = System.AppDomain.CurrentDomain.BaseDirectory + xsdPath;
            System.Xml.XmlDocument document = new XmlDocument();
            document.LoadXml(xmlString);
            System.Xml.XmlDocument schema = new XmlDocument();

            schema.Load(xsdPath);
            using (System.Xml.XmlNodeReader nrDocument = new System.Xml.XmlNodeReader(document))
            {
                using (System.Xml.XmlNodeReader nrSchema = new System.Xml.XmlNodeReader(schema))
                {
                    System.Xml.XmlReaderSettings rsDocument = new System.Xml.XmlReaderSettings();
                    rsDocument.Schemas.Add(null, nrSchema);
                    rsDocument.ValidationType = System.Xml.ValidationType.Schema;
                    rsDocument.ValidationEventHandler +=
                     new System.Xml.Schema.ValidationEventHandler(ValidationEventHandler);

                    using (System.Xml.XmlReader rDocument = System.Xml.XmlReader.Create(nrDocument, rsDocument))
                    {
                        try
                        {
                            while (rDocument.Read()) ;
                        }
                        catch (System.Xml.Schema.XmlSchemaException eCurrent)
                        {
                            throw new System.Exception("Xml inputed is invalid. " + eCurrent.Message);
                        }

                        rDocument.Close();
                    }

                    nrSchema.Close();
                }

                nrDocument.Close();
            }

            return true;
        }
开发者ID:CaffGeek,项目名称:manitobamasterbowlers.com,代码行数:52,代码来源:Utility.cs

示例10: GetConnectionString

		///<summary></summary>
		private string GetConnectionString(){
			XmlDocument document=new XmlDocument();
			string configFile=ODFileUtils.CombinePaths(new string[] {"..","..","..","OpenDental","bin","Release","FreeDentalConfig.xml"} );
			if(!File.Exists(configFile)){
				MessageBox.Show(configFile+" does not exist.");
				Application.Exit();
				return "";
			}
			document.Load(configFile);
			XmlNodeReader reader=new XmlNodeReader(document);
			string currentElement="";
			string ComputerName="";
			string Database="";
			string DbUser="";
			string Password="";
			while(reader.Read()) {
				if(reader.NodeType==XmlNodeType.Element) {
					currentElement=reader.Name;
				}
				else if(reader.NodeType==XmlNodeType.Text) {
					switch(currentElement) {
						case "ComputerName":
							ComputerName=reader.Value;
							break;
						case "Database":
							Database=reader.Value;
							break;
						case "User":
							DbUser=reader.Value;
							break;
						case "Password":
							Password=reader.Value;
							break;
					}
				}
			}
			reader.Close();
			return "Server="+ComputerName
				+";Database="+Database
				+";User ID="+DbUser
				+";Password="+Password
				+";CharSet=utf8";
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:44,代码来源:DataConnection.cs

示例11: ConvertToXmlString

        public static string ConvertToXmlString(XmlDocument XmlDocument, XslCompiledTransform XslTransformer)
        {
            string strConvertedXml = string.Empty;

            StringWriter objStringWriter = new StringWriter();
            XmlNodeReader objXmlReader = new XmlNodeReader(XmlDocument);

            try
            {
                XslTransformer.Transform(objXmlReader, null, objStringWriter);
                strConvertedXml = objStringWriter.ToString();
            }
            finally
            {
                objXmlReader.Close();
                objStringWriter.Close();
            }

            return strConvertedXml;
        }
开发者ID:IntertechInc,项目名称:.net-utilities,代码行数:20,代码来源:XslHelper.cs

示例12: XssFilterInfo

        internal XssFilterInfo(string schemaLocation)
        {
            XmlDocument schemaDoc = GetSchemaDoc(schemaLocation);
            XmlReader schemaReader = new XmlNodeReader(schemaDoc);
            try
            {
                Schema = XmlSchema.Read(schemaReader, null);
            }
            finally
            {
                schemaReader.Close();
            }

            Schema.Compile(null);
            if (Type.GetType("Mono.Runtime", false) != null)
            {
                UriAndStyleValidator = new AttributeValueValidator();
                UriAndStyleValidator.Add(schemaDoc, Schema, "URI", Schema.TargetNamespace);
                UriAndStyleValidator.Add(schemaDoc, Schema, "InlineStyle", Schema.TargetNamespace);
                // NOTE: We don't bother with attributes of type "URIs" (plural) because only <object> has such an
                // attribute and we don't allow that element.
            }
        }
开发者ID:joeaudette,项目名称:mojoportal,代码行数:23,代码来源:XssFilterInfo.cs

示例13: PrintToString

        public string PrintToString(XmlNode myXmlNode)
        {
            // write the step node to a stream so that we can get the nice indented formatting for free
            XmlNodeReader xnr = new XmlNodeReader(myXmlNode);
            MemoryStream myStream = new MemoryStream();
            XmlTextWriter xtw = new XmlTextWriter(myStream, System.Text.Encoding.UTF8);
            xtw.Formatting = Formatting.Indented;
            xtw.WriteNode(xnr, true);
            xtw.Flush();
            myStream.Position = 0;
            StreamReader sr = new StreamReader(myStream, System.Text.Encoding.UTF8);

            // copy the new xml to the other box
            string myTabbedXmlString = sr.ReadToEnd();

            // clean up
            sr.Close();
            xtw = null;
            myStream.Close();
            xnr.Close();

            return myTabbedXmlString;
        }
开发者ID:imanavaz,项目名称:CONVErT,代码行数:23,代码来源:XmlPrettyPrinter.cs

示例14: validate

        private Boolean validate(IController controller, XmlDocument document)
        {
            XmlNodeReader nodeReader = new XmlNodeReader(document);

            Boolean isValid = false;
            XmlReader schemaDatabase = controller.GetXSD("database.xsd");

            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ValidationType = ValidationType.Schema;
            settings.Schemas.Add(null, schemaDatabase);
            //settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
            //settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
            settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
            settings.ValidationEventHandler += new ValidationEventHandler(validationEventHandler);

            XmlReader reader = XmlReader.Create(nodeReader, settings);

            try
            {
                while (reader.Read()) ;
                isValid = true;
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message, "Validation Error");
            }
            finally
            {
                schemaDatabase.Close();
                nodeReader.Close();
                reader.Close();
            }
            return isValid;
        }
开发者ID:wshanshan,项目名称:DDD,代码行数:34,代码来源:ImportTool.cs

示例15: WriteExtensionObjectBody

        /// <summary>
        /// Writes the body of an ExtensionObject to the stream.
        /// </summary>
        public void WriteExtensionObjectBody(object body)
        {            
            // nothing to do for null bodies.
            if (body == null)
            {
                return;
            }

            // encode byte body.
            byte[] bytes = body as byte[];

            if (bytes != null)
            {
                m_writer.WriteStartElement("ByteString", Namespaces.OpcUaXsd);
                m_writer.WriteString(Convert.ToBase64String(bytes));                                        
                m_writer.WriteEndElement();
                return;
            }
            
            // encode xml body.
            XmlElement xml = body as XmlElement;

            if (xml != null)
            {
                #if !SILVERLIGHT
                XmlNodeReader reader = new XmlNodeReader(xml);
                m_writer.WriteNode(reader, false);
                reader.Close();
                #endif
                return;
            }

            IEncodeable encodeable = body as IEncodeable;

            if (encodeable == null)
            {
                throw new ServiceResultException(
                    StatusCodes.BadEncodingError,
                    Utils.Format("Don't know how to encode extension object body with type '{0}'.", body.GetType().FullName));
            }
            
            // encode extension object in xml.
            XmlQualifiedName xmlName = EncodeableFactory.GetXmlName(encodeable.GetType());
            m_writer.WriteStartElement(xmlName.Name, xmlName.Namespace);
            encodeable.Encode(this);
            m_writer.WriteEndElement();
        }
开发者ID:OPCFoundation,项目名称:Misc-Tools,代码行数:50,代码来源:XmlEncoder.cs


注:本文中的System.Xml.XmlNodeReader.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。