本文整理汇总了C#中System.IO.TextReader.Close方法的典型用法代码示例。如果您正苦于以下问题:C# TextReader.Close方法的具体用法?C# TextReader.Close怎么用?C# TextReader.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.TextReader
的用法示例。
在下文中一共展示了TextReader.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadDataFile
public void LoadDataFile()
{
fileReader = new StreamReader(filename);
if (System.IO.File.Exists(filename) == false)
{
throw new System.InvalidOperationException("Error: " + filename + " could not be found.");
}
saveData.Clear();
string line = "";
string read = "";
line = fileReader.ReadLine();
while (line != null)
{
for (int i = 0; i < line.Length; i++)
{
if (line[i] != '=')
{
read += line[i];
}
else
{
string status = line.Substring(i+1, (line.Length - (i+1) ));
saveData.Add(read, Convert.ToBoolean(status));
}
}
read = "";
line = fileReader.ReadLine();
}
fileReader.Close();
}
示例2: process
public List<Token> process(TextReader pTextReader)
{
D.isNull(pTextReader);
_tokens = new List<Token>();
_textReader = pTextReader;
_endOfFile = false;
readNextChar();
_currentLine = 1;
_currentPosition = 0;
_currentTokenStartPosition = 0;
Token t;
do {
t = readNextToken();
t.LineNr = _currentLine;
t.LinePosition = _currentTokenStartPosition;
_currentTokenStartPosition = _currentPosition;
_tokens.Add(t);
#if WRITE_DEBUG
Console.WriteLine(t.LineNr + ": " + t.getTokenType().ToString() + " " + t.getTokenString());
#endif
} while(t.getTokenType() != Token.TokenType.EOF);
_textReader.Close();
_textReader.Dispose();
return _tokens;
}
示例3: GenerateResult
public static void GenerateResult (TextReader sr, TextWriter sw, Uri baseUri)
{
while (sr.Peek () > 0) {
string uriString = sr.ReadLine ();
if (uriString.Length == 0 || uriString [0] == '#')
continue;
Uri uri = (baseUri == null) ?
new Uri (uriString) : new Uri (baseUri, uriString);
sw.WriteLine ("-------------------------");
sw.WriteLine (uriString);
sw.WriteLine (uri.ToString ());
sw.WriteLine (uri.AbsoluteUri);
sw.WriteLine (uri.Scheme);
sw.WriteLine (uri.Host);
sw.WriteLine (uri.LocalPath);
sw.WriteLine (uri.Query);
sw.WriteLine (uri.Port);
sw.WriteLine (uri.IsFile);
sw.WriteLine (uri.IsUnc);
sw.WriteLine (uri.IsLoopback);
sw.WriteLine (uri.UserEscaped);
sw.WriteLine (uri.HostNameType);
sw.WriteLine (uri.AbsolutePath);
sw.WriteLine (uri.PathAndQuery);
sw.WriteLine (uri.Authority);
sw.WriteLine (uri.Fragment);
sw.WriteLine (uri.UserInfo);
sw.Flush ();
}
sr.Close ();
sw.Close ();
}
示例4: MigrateUsingXslt
protected static void MigrateUsingXslt(TextReader xslStream, TextReader xmlStream, string destinationFilePath)
{
var transform = new XslCompiledTransform();
using (xslStream)
{
using (xmlStream)
{
using (var destinationStream = new StreamWriter(destinationFilePath))
{
var xslReader = XmlReader.Create(xslStream);
transform.Load(xslReader);
xslReader.Close();
xslStream.Close();
var reader = XmlReader.Create(xmlStream);
var settings = new XmlWriterSettings { Indent = true };
var writer = XmlWriter.Create(destinationStream, settings);
transform.Transform(reader, writer);
var tempfiles = transform.TemporaryFiles;
if (tempfiles != null) // tempfiles will be null when debugging is not enabled
{
tempfiles.Delete();
}
writer.Close();
reader.Close();
destinationStream.Close();
}
xmlStream.Close();
}
}
}
示例5: Deserialize
protected object Deserialize(TextReader reader, Type aType)
{
XmlSerializer xmlSerializer = new XmlSerializer(aType);
object local = xmlSerializer.Deserialize(reader);
reader.Close();
return local;
}
示例6: process
public List<Token> process(TextReader textReader)
{
Debug.Assert(textReader != null);
m_tokens = new List<Token>();
m_textReader = textReader;
m_endOfFile = false;
readNextChar();
m_currentLine = 1;
m_currentPosition = 0;
m_currentTokenStartPosition = 0;
Token t;
do {
t = readNextToken();
t.LineNr = m_currentLine;
t.LinePosition = m_currentTokenStartPosition;
m_currentTokenStartPosition = m_currentPosition;
m_tokens.Add(t);
//Console.WriteLine(t.LineNr + ": " + t.getTokenType().ToString() + " " + t.getTokenString());
} while(t.getTokenType() != Token.TokenType.EOF);
m_textReader.Close();
m_textReader.Dispose();
return m_tokens;
}
示例7: NormalizeLineEndings
static public TextReader NormalizeLineEndings(TextReader tr, bool maintainLineAccuracy)
{
string s = tr.ReadToEnd();
TextReader reader = NormalizeLineEndings(s, maintainLineAccuracy);
tr.Close();
return reader;
}
示例8: Normalize
public static TextReader Normalize(TextReader tr, ISerializationContext ctx)
{
string s = tr.ReadToEnd();
TextReader reader = Normalize(s, ctx);
tr.Close();
return reader;
}
示例9: NormalizeLineEndings
static public TextReader NormalizeLineEndings(TextReader tr)
{
string s = tr.ReadToEnd();
TextReader reader = NormalizeLineEndings(s);
tr.Close();
return reader;
}
示例10: Scanner
public Scanner(TextReader Input, string file = "main")
{
Result = new List<Token>();
this.file = file;
Line = 1;
Column = 1;
Scan(Input);
Input.Close();
}
示例11: ParseTypeName
public AssemblyQualifiedTypeName ParseTypeName(string text, string defaultNamespace, string defaultAssembly)
{
text = text.Trim();
StringBuilder type = new StringBuilder(text.Length);
string assembly = StringHelper.IsEmpty(defaultAssembly) ? null : defaultAssembly;
try
{
bool seenNamespace = false;
input = new StringReader(text);
int code;
while ((code = input.Peek()) != -1)
{
char ch = (char) code;
if (ch == '.')
{
seenNamespace = true;
}
if (ch == ',')
{
input.Read();
assembly = AssemblyName();
if (input.Peek() != -1)
{
throw new ParserException("Extra characters found at the end of the type name");
}
}
else if (ch == '[')
{
type.Append(BracketedPart());
}
else
{
type.Append(PossiblyEscapedCharacter());
}
}
input.Close();
if (!seenNamespace && StringHelper.IsNotEmpty(defaultNamespace))
{
type.Insert(0, '.')
.Insert(0, defaultNamespace);
}
return new AssemblyQualifiedTypeName(type.ToString(), assembly);
}
catch (Exception e)
{
throw new ArgumentException("Invalid fully-qualified type name: " + text, "text", e);
}
}
示例12: while
/* private void displayData(TextReader reader)
{
source.Text = "";
string line = reader.ReadLine();
while (line != null)
{
source.Text += line + '\n';
line = reader.ReadLine();
}
reader.Close();*/
private void displayData(TextReader reader)
{
source.Text = "";
for (string line = reader.ReadLine(); line != null; line = reader.ReadLine())
{
source.Text += line + '\n';
}
reader.Close();
}
示例13: Parse
public void Parse(TextReader reader)
{
while (true)
{
string str = reader.ReadLine();
if (str == null)
break;
ParseLine(str);
}
reader.Close();
}
示例14: AddingColumns
public void AddingColumns(DataTable table)
{
this.reader = new StreamReader(this.folderBrowserDialog.SelectedPath + @"\" + table.TableName + @"\main.txt");
string column = reader.ReadLine();
while (column != null)
{
table.Columns.Add(column);
column = reader.ReadLine();
}
reader.Close();
}
示例15: AddingData
public void AddingData(DataTable table)
{
this.reader = new StreamReader(this.folderBrowserDialog.SelectedPath + @"\" + table.TableName + @"\data.txt");
string data = reader.ReadLine();
while (data != null)
{
table.Rows.Add(data.Split(' '));
data = reader.ReadLine();
}
reader.Close();
}