當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。