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


C# StringReader.Dispose方法代码示例

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


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

示例1: GetData

        public static SkillData GetData(string data)
        {
            SkillData skillData = new SkillData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/SKILLS]")
                {
                    break;
                }
                else if (line == "[SKILL]")
                {
                    skillData.Skills.Add(ReadSkill(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return skillData;
        }
开发者ID:andreberg,项目名称:TLII.IO,代码行数:28,代码来源:SkillDataConverter.cs

示例2: Parse

		public override ParsedDocument Parse (ProjectDom dom, string fileName, string fileContent)
		{
			XmlParsedDocument doc = new XmlParsedDocument (fileName);
			doc.Flags = ParsedDocumentFlags.NonSerializable;
			
			TextReader tr = new StringReader (fileContent);
			try {
				Parser xmlParser = new Parser (
					new XmlFreeState (new HtmlTagState (true), new HtmlClosingTagState (true)),
					true);
				
				xmlParser.Parse (tr);
				doc.XDocument = xmlParser.Nodes.GetRoot ();
				doc.Add (xmlParser.Errors);
				if (doc.XDocument != null)
					doc.Add (Validate (doc.XDocument));
			}
			catch (Exception ex) {
				MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing HTML document", ex);
			}
			finally {
				if (tr != null)
					tr.Dispose ();
			}
			
			return doc;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:27,代码来源:HtmlParser.cs

示例3: Parse

		public override ParsedDocument Parse (ProjectDom dom, string fileName, string fileContent)
		{
			XmlParsedDocument doc = new XmlParsedDocument (fileName);
			doc.Flags |= ParsedDocumentFlags.NonSerializable;
			TextReader tr = new StringReader (fileContent);
			try {
				Parser xmlParser = new Parser (new XmlFreeState (), true);
				xmlParser.Parse (tr);
				doc.XDocument = xmlParser.Nodes.GetRoot ();
				doc.Add (xmlParser.Errors);
				
				if (doc.XDocument != null && doc.XDocument.RootElement != null) {
					if (!doc.XDocument.RootElement.IsEnded)
						doc.XDocument.RootElement.End (xmlParser.Location);
				}
			}
			catch (Exception ex) {
				MonoDevelop.Core.LoggingService.LogError ("Unhandled error parsing xml document", ex);
			}
			finally {
				if (tr != null)
					tr.Dispose ();
			}
			return doc;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:25,代码来源:XmlDocumentParser.cs

示例4: GetData

        public static AffixData GetData(string data)
        {
            AffixData affixData = new AffixData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;


            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/AFFIXES]")
                {
                    break;
                }
                else if (line == "[AFFIX]")
                {
                    affixData.Affixes.Add(ReadAffix(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return affixData;
        }
开发者ID:andreberg,项目名称:TLII.IO,代码行数:29,代码来源:AffixDataConverter.cs

示例5: GetData

        public static MissileData GetData(string data)
        {
            MissileData missileData = new MissileData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/MISSILES]")
                {
                    break;
                }
                else if (line == "[MISSILE]")
                {
                    missileData.Missiles.Add(ReadMissile(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return missileData;
        }
开发者ID:andreberg,项目名称:TLII.IO,代码行数:28,代码来源:MissileDataConverter.cs

示例6: RunTest

 void RunTest(string c_code, string expectedXml)
 {
     StringReader reader = null;
     StringWriter writer = null;
     try
     {
         reader = new StringReader(c_code);
         writer = new StringWriter();
         var xWriter = new XmlnsHidingWriter(writer)
         {
             Formatting = Formatting.Indented
         };
         var xc = new XmlConverter(reader, xWriter);
         xc.Convert();
         writer.Flush();
         Assert.AreEqual(expectedXml, writer.ToString());
     }
     catch
     {
         Debug.WriteLine(writer.ToString());
         throw;
     }
     finally
     {
         if (writer != null)
             writer.Dispose();
         if (reader != null)
             reader.Dispose();
     }
 }
开发者ID:gh0std4ncer,项目名称:reko,代码行数:30,代码来源:XmlConverterTests.cs

示例7: GetAllCities

        public List<string> GetAllCities(string country)
        {
            List<string> cityNames = new List<string>();

            // Creating object of WeatherService proxy class and calling GlobalWeatherSoap12 endpoint
            WeatherService.GlobalWeatherSoapClient client = new WeatherService.GlobalWeatherSoapClient("GlobalWeatherSoap12");
            // Invoke service method through service proxy
            var allCountryCities = client.GetCitiesByCountry(country);

            if (allCountryCities.ToString() == "Data Not Found")
            {
                return null;
            }

            DataSet ds = new DataSet();

            //Creating a stringReader object with Xml Data
            StringReader stringReader = new StringReader(allCountryCities);

            // Xml Data is read and stored in the DataSet object
            ds.ReadXml(stringReader);

            //Adding all city names to the List objects
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                cityNames.Add(item["City"].ToString());
            }

            stringReader.Dispose();

            return cityNames;
        }
开发者ID:Shuvayu,项目名称:DevBox,代码行数:32,代码来源:GetWeatherData.cs

示例8: GetData

        public static UserInterfaceData GetData(string data)
        {
            UserInterfaceData userInterfaceData = new UserInterfaceData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/USERINTERFACES]")
                {
                    break;
                }
                else if (line == "[USERINTERFACE]")
                {
                    userInterfaceData.UserInterfaces.Add(ReadUserInterface(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return userInterfaceData;
        }
开发者ID:andreberg,项目名称:TLII.IO,代码行数:28,代码来源:UserInterfaceDataConverter.cs

示例9: Token

		private Token(string tokenXml, Uri audience, TokenDecryptor decryptor) {
			Requires.NotNullOrEmpty(tokenXml, "tokenXml");
			Requires.True(decryptor != null || !IsEncrypted(tokenXml), null);
			Contract.Ensures(this.AuthorizationContext != null);

			byte[] decryptedBytes;
			string decryptedString;

			using (StringReader xmlReader = new StringReader(tokenXml)) {
				var readerSettings = MessagingUtilities.CreateUntrustedXmlReaderSettings();
				using (XmlReader tokenReader = XmlReader.Create(xmlReader, readerSettings)) {
					Contract.Assume(tokenReader != null); // BCL contract should say XmlReader.Create result != null
					if (IsEncrypted(tokenReader)) {
						Logger.InfoCard.DebugFormat("Incoming SAML token, before decryption: {0}", tokenXml);
						decryptedBytes = decryptor.DecryptToken(tokenReader);
						decryptedString = Encoding.UTF8.GetString(decryptedBytes);
						Contract.Assume(decryptedString != null); // BCL contracts should be enhanced here
					} else {
						decryptedBytes = Encoding.UTF8.GetBytes(tokenXml);
						decryptedString = tokenXml;
					}
				}
			}

			var stringReader = new StringReader(decryptedString);
			try {
				this.Xml = new XPathDocument(stringReader).CreateNavigator();
			} catch {
				stringReader.Dispose();
				throw;
			}

			Logger.InfoCard.DebugFormat("Incoming SAML token, after any decryption: {0}", this.Xml.InnerXml);
			this.AuthorizationContext = TokenUtility.AuthenticateToken(this.Xml.ReadSubtree(), audience);
		}
开发者ID:rynqs,项目名称:DotNetOpenAuth,代码行数:35,代码来源:Token.cs

示例10: GetData

        public static TriggerableData GetData(string data)
        {
            TriggerableData triggerableData = new TriggerableData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/TRIGGERABLES]")
                {
                    break;
                }
                else if (line == "[TRIGGERABLE]")
                {
                    triggerableData.Triggerables.Add(ReadTriggerable(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return triggerableData;
        }
开发者ID:andreberg,项目名称:TLII.IO,代码行数:28,代码来源:TriggerableDataConverter.cs

示例11: GetData

        public static RoomPieceData GetData(string data)
        {
            RoomPieceData roomPieceData = new RoomPieceData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/ROOMPIECES]")
                {
                    break;
                }
                else if (line == "[LEVELSET]")
                {
                    roomPieceData.LevelSets.Add(ReadLevelSet(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return roomPieceData;
        }
开发者ID:andreberg,项目名称:TLII.IO,代码行数:28,代码来源:RoomPieceDataConverter.cs

示例12: FromXml

 public void FromXml(string xml)
 {
     System.IO.StringReader sw = new System.IO.StringReader(xml);
     XmlReader xr = XmlReader.Create(sw);
     FromXml(ref xr);
     sw.Dispose();
     xr.Close();
 }
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:8,代码来源:ShippableItem.cs

示例13: FromXmlString

 public virtual bool FromXmlString(string x)
 {
     System.IO.StringReader sw = new System.IO.StringReader(x);
     XmlReader xr = XmlReader.Create(sw);
     bool result = FromXml(ref xr);
     sw.Dispose();
     xr.Close();
     return result;
 }
开发者ID:NightOwl888,项目名称:MerchantTribe,代码行数:9,代码来源:ContentColumn.cs

示例14: HexStringToByteArray

 public static byte[] HexStringToByteArray(String hexString)
 {
     int NumberChars = hexString.Length / 2;
     byte[] bytes = new byte[NumberChars];
     StringReader sr = new StringReader(hexString);
     for (int i = 0; i < NumberChars; i++)
         bytes[i] = Convert.ToByte(new string(new char[2] { (char)sr.Read(), (char)sr.Read() }), 16);
     sr.Dispose();
     return bytes;
 }
开发者ID:Kreyl,项目名称:nute,代码行数:10,代码来源:Command.cs

示例15: CheckFourCellsMatrix

 public void CheckFourCellsMatrix()
 {
     StringReader reader = new StringReader("2");
     StringWriter writer = new StringWriter();
     Console.SetIn(reader);
     Console.SetOut(writer);
     FillMatrix.Main();
     string expectedOutput = "Enter a positive number \r\n     1     4\r\n     3     2\r\n";
     Assert.AreEqual(expectedOutput, writer.ToString());
     reader.Dispose();
     writer.Dispose();
 }
开发者ID:AyrFX,项目名称:Telerik-Academy-2015-HQC-Homeworks,代码行数:12,代码来源:MatrixTests.cs


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