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


C# TextReader.Close方法代码示例

本文整理汇总了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();
        }
开发者ID:rodstrom,项目名称:soul,代码行数:33,代码来源:SaveData.cs

示例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;
        }
开发者ID:substans,项目名称:Grimm,代码行数:34,代码来源:Tokenizer.cs

示例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 ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:33,代码来源:uri-test-generator.cs

示例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();
				}
			}
		}
开发者ID:JohnThomson,项目名称:libpalaso,代码行数:34,代码来源:XslMigrationStrategy.cs

示例5: Deserialize

 protected object Deserialize(TextReader reader, Type aType)
 {
     XmlSerializer xmlSerializer = new XmlSerializer(aType);
     object local = xmlSerializer.Deserialize(reader);
     reader.Close();
     return local;
 }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:7,代码来源:ConfigurationUtility.cs

示例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;
        }
开发者ID:bloomingbridges,项目名称:hxSprak,代码行数:32,代码来源:Tokenizer.cs

示例7: NormalizeLineEndings

        static public TextReader NormalizeLineEndings(TextReader tr, bool maintainLineAccuracy)
        {
            string s = tr.ReadToEnd();
            TextReader reader = NormalizeLineEndings(s, maintainLineAccuracy);
            tr.Close();

            return reader;
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:8,代码来源:iCalObjectSerializer.cs

示例8: Normalize

        public static TextReader Normalize(TextReader tr, ISerializationContext ctx)
        {
            string s = tr.ReadToEnd();
            TextReader reader = Normalize(s, ctx);
            tr.Close();

            return reader;
        }
开发者ID:logikonline,项目名称:DDay.iCal,代码行数:8,代码来源:TextUtil.cs

示例9: NormalizeLineEndings

        static public TextReader NormalizeLineEndings(TextReader tr)
        {
            string s = tr.ReadToEnd();
            TextReader reader = NormalizeLineEndings(s);
            tr.Close();

            return reader;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:8,代码来源:iCalObjectSerializer.cs

示例10: Scanner

 public Scanner(TextReader Input, string file = "main")
 {
     Result = new List<Token>();
     this.file = file;
     Line = 1;
     Column = 1;
     Scan(Input);
     Input.Close();
 }
开发者ID:RoboLOGO,项目名称:IDE,代码行数:9,代码来源:Scanner.cs

示例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);
            }
        }
开发者ID:zibler,项目名称:zibler,代码行数:56,代码来源:TypeNameParser.cs

示例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();
        }
开发者ID:0utKast,项目名称:VisualCS,代码行数:20,代码来源:MainWindow.xaml.cs

示例13: Parse

 public void Parse(TextReader reader)
 {
     while (true)
     {
         string str = reader.ReadLine();
         if (str == null)
             break;
         ParseLine(str);
     }
     reader.Close();
 }
开发者ID:udiavr,项目名称:nativeclient-sdk,代码行数:11,代码来源:DependencyParser.cs

示例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();
 }
开发者ID:sharafutdinova,项目名称:HomeworksCSharp,代码行数:11,代码来源:Form1.cs

示例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();
 }
开发者ID:sharafutdinova,项目名称:HomeworksCSharp,代码行数:11,代码来源:Form1.cs


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