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


C# ITextSource.CreateReader方法代码示例

本文整理汇总了C#中ITextSource.CreateReader方法的典型用法代码示例。如果您正苦于以下问题:C# ITextSource.CreateReader方法的具体用法?C# ITextSource.CreateReader怎么用?C# ITextSource.CreateReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextSource的用法示例。


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

示例1: FindAllValidating

    public IEnumerable<ISearchResult> FindAllValidating(ITextSource document, int offset, int length)
    {
      using (var stream = document.CreateReader())
      {
        var doc = (IDocument)document;
        var xmlDoc = new XPathDocument(stream); ;
        var navigator = xmlDoc.CreateNavigator();

        XPathExpression expr = null;
        XPathNodeIterator iterator;
        try
        {
          expr = navigator.Compile(_xPath);
          iterator = navigator.Select(expr);
        }
        catch (System.Xml.XPath.XPathException)
        {
          yield break;
        }

        while (iterator.MoveNext())
        {
          var current = iterator.Current;
          var segment = XmlSegment(doc, ((IXmlLineInfo)current).LineNumber, ((IXmlLineInfo)current).LinePosition);
          if (segment != null && segment.Offset >= offset && segment.EndOffset <= (offset + length))
          {
            yield return new XPathSearchResult()
            {
              StartOffset = segment.Offset,
              Length = segment.Length
            };
          }
        }
      }
    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:35,代码来源:XPathSearchStrategy.cs

示例2: GetFolds

 public IList<FoldingRegion> GetFolds(ITextSource textSource)
 {
     try {
         GetFolds(textSource.CreateReader());
         return folds;
     } catch (XmlException) {
     }
     return null;
 }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:9,代码来源:XmlFoldParser.cs

示例3: Parse

 public void Parse(IProject project, string fileName, string source)
 {
     this.FileName = fileName;
     this.Content = new StringTextSource(source);
     this.Document = new StringBuilderDocument(this.Content);
     this.Project = project;
     CSharpParser p = project.CreateParser();
     this.SyntaxTree = p.Parse(Content.CreateReader(), fileName);
     this.ParsedFile = this.SyntaxTree.ToTypeSystem();
 }
开发者ID:jcd-as,项目名称:omnisharp-server,代码行数:10,代码来源:CSharpFile.cs

示例4: Parse

 private void Parse(IProject project, string fileName, string source)
 {
     Console.WriteLine("Loading " + fileName);
     this.FileName = fileName;
     this.Content = new StringTextSource(source);
     this.Document = new StringBuilderDocument(this.Content);
     this.Project = project;
     CSharpParser p = project.CreateParser();
     this.SyntaxTree = p.Parse(Content.CreateReader(), fileName);
     this.ParsedFile = this.SyntaxTree.ToTypeSystem();
     if(this.Project.ProjectContent != null)
         this.Project.ProjectContent.AddOrUpdateFiles(this.ParsedFile);
 }
开发者ID:kirtgoh,项目名称:vim-ycm-windows,代码行数:13,代码来源:CSharpFile.cs

示例5: Parse

 private void Parse(IProject project, string fileName, string source)
 {
     Console.WriteLine("Loading " + fileName);
     this.FileName = fileName;
     this.Content = new StringTextSource(source);
     this.Document = new ReadOnlyDocument(this.Content);
     this.Project = project;
     CSharpParser p = project.CreateParser();
     this.SyntaxTree = p.Parse(Content.CreateReader(), fileName);
     if (p.HasErrors)
     {
         Console.WriteLine("Error parsing " + fileName + ":");
         foreach (var error in p.Errors)
         {
             Console.WriteLine("  " + error.Region + " " + error.Message);
         }
     }
     this.ParsedFile = this.SyntaxTree.ToTypeSystem();
 }
开发者ID:CSRedRat,项目名称:Omnisharp,代码行数:19,代码来源:CSharpFile.cs

示例6: Parse

		public CompilationUnit Parse (ITextSource textSource, string fileName, int lineModifier = 0)
		{
			return Parse (textSource.CreateReader (), fileName, lineModifier);
		}
开发者ID:head-thrash,项目名称:monodevelop,代码行数:4,代码来源:CSharpParser.cs

示例7: CSharpFile

		public CSharpFile(CSharpProject project, string fileName)
		{
			this.Project = project;
			this.FileName = fileName;
			this.Content = new StringTextSource(File.ReadAllText(FileName));
			this.LinesOfCode = 1 + this.Content.Text.Count(c => c == '\n');
			
			CSharpParser p = new CSharpParser(project.CompilerSettings);
			this.CompilationUnit = p.Parse(Content.CreateReader(), fileName);
			if (p.HasErrors) {
				Console.WriteLine("Error parsing " + fileName + ":");
				foreach (var error in p.ErrorsAndWarnings) {
					Console.WriteLine("  " + error.Region + " " + error.Message);
				}
			}
			this.ParsedFile = this.CompilationUnit.ToTypeSystem();
		}
开发者ID:mono-soc-2012,项目名称:NRefactory,代码行数:17,代码来源:CSharpProject.cs

示例8: FindAllForwardOnly

    public IEnumerable<ISearchResult> FindAllForwardOnly(ITextSource document, int offset, int length)
    {
      var xc = new XPathCollection();
      try
      {
        xc.Add(_xPath);
      }
      catch (Exception)
      {
        yield break;
      }
      using (var reader = new XmlTextReader(document.CreateReader()))
      using (var xpathReader = new XPathReader(reader, xc))
      {
        var lineInfo = xpathReader as IXmlLineInfo;
        var doc = (IDocument)document;
        ISegment segment;

        while (Read(xpathReader))
        {
          if (xpathReader.Match(0) && xpathReader.NodeType != XmlNodeType.EndElement)
          {
            segment = null;
            try
            {
              segment = XmlSegment(doc, lineInfo.LineNumber, lineInfo.LinePosition);
            }
            catch (Exception) { }
            if (segment != null && segment.Offset >= offset && segment.EndOffset <= (offset + length))
            {
              yield return new XPathSearchResult()
              {
                StartOffset = segment.Offset,
                Length = segment.Length
              };
            }
          }
        }
      }
    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:40,代码来源:XPathSearchStrategy.cs

示例9: ParseTemplate

		ParserResults ParseTemplate(ITextSource textBuffer)
		{
			var host = new RazorEngineHost(new CSharpRazorCodeLanguage());
			var engine = new RazorTemplateEngine(host);
			return engine.ParseTemplate(textBuffer.CreateReader());
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:6,代码来源:RazorCSharpCompletionBinding.cs

示例10: WriteTextSource

 private async Task WriteTextSource(Stream stream, ITextSource data)
 {
   using (var writer = new StreamWriter(stream))
   using (var reader = data.CreateReader())
   {
     await reader.CopyToAsync(writer);
   }
 }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:8,代码来源:Settings.cs

示例11: ProcessFragment


//.........这里部分代码省略.........
                  else if (i + 8 < fragment.TextLength
                    && fragment.GetCharAt(i + 1) == '!'
                    && fragment.GetCharAt(i + 2) == '['
                    && fragment.GetCharAt(i + 3) == 'C'
                    && fragment.GetCharAt(i + 4) == 'D'
                    && fragment.GetCharAt(i + 5) == 'A'
                    && fragment.GetCharAt(i + 6) == 'T'
                    && fragment.GetCharAt(i + 7) == 'A'
                    && fragment.GetCharAt(i + 8) == '[')
                  {
                    i += 8;
                    state = XmlState.CData;
                  }
                  else
                  {
                    state = XmlState.Tag;
                    lastTag = new KeyValuePair<int, int>(line, i - lineOffsets.Last() + 2);
                  }
                }
                break;
            }
            break;
        }
      }

      const string __noName = "___NO_NAME___";
      const string __eof = "{`EOF`}";
      var suffix = string.Empty;

      switch (state)
      {
        case XmlState.Attribute:
          if (char.IsWhiteSpace(fragment.GetCharAt(fragment.TextLength - 1)))
          {
            state = XmlState.AttributeStart;
            suffix += ">";
          }
          else
          {
            suffix += "=\"\">";
          }
          break;
        case XmlState.AttributeValue:
          if (fragment.GetCharAt(fragment.TextLength - 1) == '=')
          {
            suffix += "''>";
          }
          else
          {
            suffix += attrValueQuote.ToString() + ">";
          }
          break;
        case XmlState.CData:
          suffix += "]]>";
          break;
        case XmlState.Comment:
          suffix += "-->";
          break;
        case XmlState.Tag:
          if (fragment.GetCharAt(fragment.TextLength - 1) == '<') suffix += __noName;
          suffix += ">";
          break;
      }
      suffix += "<!--" + __eof + "-->";

      var settings = new XmlReaderSettings() { ConformanceLevel = ConformanceLevel.Fragment };
      var textReader = new AugmentedReader(fragment.CreateReader(), suffix);
      var reader = XmlReader.Create(textReader, settings);
      var lineInfo = reader as IXmlLineInfo;

      try
      {
        bool keepGoing = true;
        while (keepGoing && reader.Read() && !(reader.NodeType == XmlNodeType.Comment && reader.Value == __eof))
        {
          if (reader.LocalName != __noName)
          {
            keepGoing = processor.Invoke(reader, lineOffsets[lineInfo.LineNumber - 1]
                                                + lineInfo.LinePosition
                                                - (reader.NodeType == XmlNodeType.Element ? 2 : 1), state);
            if (reader.NodeType == XmlNodeType.Element
              && lineInfo.LineNumber == lastTag.Key
              && lineInfo.LinePosition == lastTag.Value)
            {
              for (var i = 0; i < reader.AttributeCount; i++)
              {
                reader.MoveToAttribute(i);
                keepGoing = processor.Invoke(reader, lineOffsets[lineInfo.LineNumber - 1] + lineInfo.LinePosition - 1, state);
              }
            }
          }
        }
      }
      catch (XmlException)
      {
        // Do Nothing
      }

      return state;
    }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:101,代码来源:XmlUtils.cs


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