本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}