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


C# TextReader类代码示例

本文整理汇总了C#中TextReader的典型用法代码示例。如果您正苦于以下问题:C# TextReader类的具体用法?C# TextReader怎么用?C# TextReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Generate

    /// <summary>Parse the input X# source code file and generate the matching target assembly
    /// language.</summary>
    /// <param name="aReader">X# source code reader.</param>
    /// <returns>The resulting target assembler content. The returned object contains
    /// a code and a data block.</returns>
    public Assembler Generate(TextReader aReader)
    {
      if (aReader == null)
      {
        throw new ArgumentNullException(nameof(aReader));
      }
      mPatterns.EmitUserComments = EmitUserComments;
      mLineNo = 0;
      var xResult = new Assembler();
      try
      {
        // Read one X# source code line at a time and process it.
        while (true)
        {
          mLineNo++;
          string xLine = aReader.ReadLine();
          if (xLine == null)
          {
            break;
          }

          ProcessLine(xLine, mLineNo);
        }
        AssertLastFunctionComplete();
        return xResult;
      }
      finally
      {
        Assembler.ClearCurrentInstance();
      }
    }
开发者ID:ChrisJamesSadler,项目名称:Cosmos,代码行数:36,代码来源:AsmGenerator.cs

示例2: Parse

 public static DataTable Parse(TextReader stream, CsvHeadersAction Headers, char delimiter)
 {
     DataTable table = new DataTable();
     CsvStream csv = new CsvStream(stream);
     string[] row = csv.GetNextRow(delimiter);
     if (row == null)
         return null;
     if (Headers == CsvHeadersAction.SkipHeaderLine)
     {
         row = csv.GetNextRow(delimiter);
     }
     if (Headers == CsvHeadersAction.UseAsColumnNames)
     {
         //foreach (string header in row)
         for (int i = 0;i<row.Length;i++)
         {
             if (row[i] != null && row[i].Length > 0 && !table.Columns.Contains(row[i]))
                 table.Columns.Add(row[i], typeof(string));
             else
                 table.Columns.Add(GetNextColumnHeader(table), typeof(string));
         }
         row = csv.GetNextRow(delimiter);
     }
     while (row != null)
     {
         while (row.Length > table.Columns.Count)
             table.Columns.Add(GetNextColumnHeader(table), typeof(string));
         table.Rows.Add(row);
         row = csv.GetNextRow(delimiter);
     }
     stream.Close();
     stream.Dispose();
     return table;
 }
开发者ID:pirzada,项目名称:sinapse,代码行数:34,代码来源:Parser.cs

示例3: BufferedCharReader

        public BufferedCharReader(TextReader reader, int bufferSize)
        {
            Debug.Assert(reader != null);

            _reader = reader;
            _bufferSize = Math.Max(256, bufferSize);
        }
开发者ID:ashou1986,项目名称:top4net,代码行数:7,代码来源:BufferedCharReader.cs

示例4: ThesaurusSpliter

 /// <summary>
 /// �ִʴ��������캯��
 /// </summary>
 /// <param name="input">�ı���ȡ��</param>
 public ThesaurusSpliter(TextReader input)
 {
     this.input = input;
     //����������.ģ�����뷨���������Ĺ���
     assoStream = new AssociateStream();
     ReadBuffer();
 }
开发者ID:sqzhuyi,项目名称:cnopenblog,代码行数:11,代码来源:ThesaurusSpliter.cs

示例5: WsdlParser

        // Main parser
        internal WsdlParser(TextReader input, String outputDir, ArrayList outCodeStreamList, String locationURL, bool bWrappedProxy, String proxyNamespace)
        {
            Util.Log("WsdlParser.WsdlParser outputDir "+outputDir+" locationURL "+locationURL+" bWrappedProxy "+bWrappedProxy+" proxyNamespace "+proxyNamespace);
            // Initialize member variables
            _XMLReader = null;
            _readerStreamsWsdl = new ReaderStream(locationURL);
            _readerStreamsWsdl.InputStream = input;
            _writerStreams = null;
            _outputDir = outputDir;
            _outCodeStreamList = outCodeStreamList;
            _bWrappedProxy = bWrappedProxy;
            if (proxyNamespace == null || proxyNamespace.Length == 0)
                _proxyNamespace = "InteropNS";
            else
                _proxyNamespace = proxyNamespace;
            if (outputDir == null)
                outputDir = ".";

            int length = outputDir.Length;
            if (length > 0)
            {
                char endChar = outputDir[length-1];
                if (endChar != '\\' && endChar != '/')
                    _outputDir = _outputDir + '\\';
            }
            //_namespaceStack = null;
            _URTNamespaces = new ArrayList();
            _blockDefault = SchemaBlockType.ALL;
            _primedNametable = CreatePrimedNametable();
            
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:32,代码来源:WsdlParser.cs

示例6: AccumulatePartial

 private string AccumulatePartial(TextReader reader)
 {
     StringBuilder buffer = new StringBuilder();
     buffer.Append(">");
     do
     {
         reader.Read();
     }
     while(char.IsWhiteSpace((char)reader.Peek()));
     while(true)
     {
         var peek = (char)reader.Peek();
         if (peek == '}' || peek == '~' || char.IsWhiteSpace(peek))
         {
             break;
         }
         var node = reader.Read();
         if (node == -1)
         {
             throw new InvalidOperationException("Reached end of template before the expression was closed.");
         }
         else
         {
             buffer.Append((char)node);
         }
     }
     return buffer.ToString();
 }
开发者ID:jamisliao,项目名称:Handlebars.Net,代码行数:28,代码来源:PartialParser.cs

示例7: OperatorScanner

        internal OperatorScanner(TextReader reader, ErrorReporter reporter)
            : base(reader, reporter)
        {
            twoCharacterOperators = new Dictionary<char, IDictionary<char, Type>>();
            twoCharacterOperators[':'] = new Dictionary<char, Type>();
            twoCharacterOperators[':']['='] = typeof(AssignmentToken);

            twoCharacterOperators['.'] = new Dictionary<char, Type>();
            twoCharacterOperators['.']['.'] = typeof(RangeToken);

            singleCharacterOperators = new Dictionary<char, Type>();

            singleCharacterOperators.Add('+', typeof(PlusToken));
            singleCharacterOperators.Add('-', typeof(MinusToken));
            singleCharacterOperators.Add('*', typeof(MultiplyToken));
            singleCharacterOperators.Add('/', typeof(DivideToken));
            singleCharacterOperators.Add('<', typeof(LessThanToken));
            singleCharacterOperators.Add('=', typeof(ComparisonToken));
            singleCharacterOperators.Add('&', typeof(AndToken));
            singleCharacterOperators.Add('!', typeof(NotToken));
            singleCharacterOperators.Add(';', typeof(SemicolonToken));
            singleCharacterOperators.Add(':', typeof(ColonToken));
            singleCharacterOperators.Add('(', typeof(LParenToken));
            singleCharacterOperators.Add(')', typeof(RParenToken));
        }
开发者ID:Valtis,项目名称:CompilerCourseProject,代码行数:25,代码来源:OperatorScanner.cs

示例8: RunCommand

        public int RunCommand(TextReader input, TextWriter output, string tenant, string[] args, Dictionary<string, string> switches)
        {
            try {
                tenant = tenant ?? "Default";

                var env = FindOrCreateTenant(tenant);

                var parameters = new CommandParameters {
                    Arguments = args,
                    Switches = switches,
                    Input = input,
                    Output = output
                };

                env.Resolve<ICommandManager>().Execute(parameters);

                return 0;
            }
            catch (Exception e) {
                for (int i = 0; e != null; e = e.InnerException, i++) {
                    if (i > 0) {
                        output.WriteLine("-------------------------------------------------------------------");
                    }
                    output.WriteLine("Error: {0}", e.Message);
                    output.WriteLine("{0}", e.StackTrace);
                }
                return 5;
            }
        }
开发者ID:mofashi2011,项目名称:orchardcms,代码行数:29,代码来源:CommandHostAgent.cs

示例9: TemplateParser

		public TemplateParser (string filename, TextReader input)
		{
			this.filename = filename;
			fileText = input.ReadToEnd ();
			StringReader reader = new StringReader (fileText);
			tokenizer = new TemplateTokenizer (reader);
		}
开发者ID:apakian,项目名称:fluorinefx,代码行数:7,代码来源:TemplateParser.cs

示例10: Initialize

        private void Initialize(TextReader input)
        {
            rand = new Random();
            fortunes = new List<string>();

            StringBuilder sb = new StringBuilder();
            string line = input.ReadLine();
            while (line != null)
            {
                if (line == "%")
                {
                    if (sb.Length > 0)
                    {
                        fortunes.Add(sb.ToString());
                        sb.Clear();
                    }
                }
                else
                {
                    if (sb.Length > 0)
                    {
                        sb.Append(' ');
                    }
                    sb.Append(line);
                }
                line = input.ReadLine();
            }
            if (sb.Length > 0)
            {
                fortunes.Add(sb.ToString());
            }
        }
开发者ID:Rejendo,项目名称:orleans,代码行数:32,代码来源:Fortune.cs

示例11: XsvReader

 public XsvReader(TextReader reader, string commentString = null)
 {
     if (reader == null)
     { throw new ArgumentNullException("reader"); }
     this.BaseReader = reader;
     this.CommentString = commentString;
 }
开发者ID:pierre3,项目名称:HandyUtilities.Xsv,代码行数:7,代码来源:XsvReader.cs

示例12: DoOpen

		protected override void DoOpen (FileInfo info)
		{
			if (Extension == ".gz" || Extension == ".bz2" || Extension == ".lzma")
				GetCompressedInfoReader ();
			else
				reader = base.TextReader;
		}
开发者ID:ArsenShnurkov,项目名称:beagle-1,代码行数:7,代码来源:FilterInfo.cs

示例13: Parse

        public override Sector Parse(TextReader reader)
        {
            Sector sector = new Sector();

            StringBuilder accum = new StringBuilder();
            while (true)
            {
                string line = reader.ReadLine();
                if (line == null)
                    break;
                if (Regex.IsMatch(line, @"^\s*$"))
                    continue;
                if (Regex.IsMatch(line, @"^\s*#"))
                    continue;
                if (Char.IsWhiteSpace(line[0]))
                {
                    accum.Append(" ");
                    accum.Append(Regex.Replace(line, @"^\s+", ""));
                    continue;
                }

                if (accum.Length > 0)
                    Apply(accum.ToString(), sector);

                accum.Clear();
                accum.Append(line);
            }
            if (accum.Length > 0)
            {
                Apply(accum.ToString(), sector);
            }

            return sector;
        }
开发者ID:Matt--,项目名称:travellermap,代码行数:34,代码来源:MSECParser.cs

示例14: Parse

 public Instruction[] Parse(TextReader reader)
 {
     Token token;
     mReader = reader;
     mScratchpad = new List<Instruction>();
     mState = Idle;
     while(mState != null && ReadNextToken(out token)) {
         mState = mState(token);
         if (mState == null) {
             mReader = null;
             mBuilder.Length = 0;
             mScratchpad.Clear();
             mBlock.Clear();
             return null;
         }
     }
     mReader = null;
     var result = mScratchpad.ToArray();
     mBuilder.Length = 0;
     mScratchpad.Clear();
     if (mBlock.Count > 0) {
         mBlock.Clear();
         return null;
     }
     return result;
 }
开发者ID:maxattack,项目名称:ROBOLOGO,代码行数:26,代码来源:InstructionParser.cs

示例15: XmlConverter

  public XmlConverter(TextReader rdr, XmlWriter writer, IPlatform platform)
  {
      this.rdr = rdr;
      this.writer = writer;
      this.platform = platform;
      this.parserState = new ParserState();
 }
开发者ID:uxmal,项目名称:reko,代码行数:7,代码来源:XmlConverter.cs


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