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


C# IDocument类代码示例

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


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

示例1: SearchBracket

        public BracketSearchResult SearchBracket(IDocument document, int offset)
        {
            if (offset > 0)
            {
                char c = document.GetCharAt(offset - 1);
                int index = OpeningBrackets.IndexOf(c);
                int otherOffset = -1;
                if (index > -1)
                    otherOffset = SearchBracketForward(document, offset, OpeningBrackets[index], ClosingBrackets[index]);

                index = ClosingBrackets.IndexOf(c);
                if (index > -1)
                    otherOffset = SearchBracketBackward(document, offset - 2, OpeningBrackets[index], ClosingBrackets[index]);

                if (otherOffset > -1)
                {
                    var result = new BracketSearchResult(Math.Min(offset - 1, otherOffset), 1,
                                                         Math.Max(offset - 1, otherOffset), 1);
                    SearchDefinition(document, result);
                    return result;
                }
            }

            return null;
        }
开发者ID:123marvin123,项目名称:PawnPlus,代码行数:25,代码来源:BracketSearcher.cs

示例2: PrepareCompletionDocument

        private static IDocument PrepareCompletionDocument(IDocument document, ref int offset, string usings = null, string variables = null)
        {
            if (String.IsNullOrEmpty(document.FileName))
                return document;

            //if the code is just a script it it will contain no namestpace, class and method structure and so the code completion will not work properly
            // for it to work we have to suround the code with the appropriate code structure
            //we only process the file if its a .csx file
            var fileExtension = Path.GetExtension(document.FileName);
            var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(document.FileName);
            if (String.IsNullOrEmpty(fileExtension) || String.IsNullOrEmpty(fileNameWithoutExtension))
                return document;

            if (fileExtension.ToLower() == ".csx")
            {
                string classname = replaceRegex.Replace(fileNameWithoutExtension, "");
                classname = classname.TrimStart('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');

                string header = String.Empty;
                header += (usings ?? "") + Environment.NewLine;
                header += "public static class " + classname + " {" + Environment.NewLine;
                header += "public static void Main() {" + Environment.NewLine;
                header += (variables ?? "") + Environment.NewLine;

                string footer = "}" + Environment.NewLine + "}" + Environment.NewLine;

                string code = header + document.Text + Environment.NewLine + footer;

                offset += header.Length;

                return new ReadOnlyDocument(new StringTextSource(code), document.FileName);
            }
            return document;
        }
开发者ID:uQr,项目名称:NRefactory-Completion-Sample,代码行数:34,代码来源:CSharpCompletionContext.cs

示例3: ManageUsings

		public static void ManageUsings(Gui.IProgressMonitor progressMonitor, string fileName, IDocument document, bool sort, bool removedUnused)
		{
			ParseInformation info = ParserService.ParseFile(fileName, document.TextContent);
			if (info == null) return;
			ICompilationUnit cu = info.MostRecentCompilationUnit;
			
			List<IUsing> newUsings = new List<IUsing>(cu.UsingScope.Usings);
			if (sort) {
				newUsings.Sort(CompareUsings);
			}
			
			if (removedUnused) {
				IList<IUsing> decl = cu.ProjectContent.Language.RefactoringProvider.FindUnusedUsingDeclarations(Gui.DomProgressMonitor.Wrap(progressMonitor), fileName, document.TextContent, cu);
				if (decl != null && decl.Count > 0) {
					foreach (IUsing u in decl) {
						string ns = null;
						for (int i = 0; i < u.Usings.Count; i++) {
							ns = u.Usings[i];
							if (ns == "System") break;
						}
						if (ns != "System") { // never remove "using System;"
							newUsings.Remove(u);
						}
					}
				}
			}
			
			// put empty line after last System namespace
			if (sort) {
				PutEmptyLineAfterLastSystemNamespace(newUsings);
			}
			
			cu.ProjectContent.Language.CodeGenerator.ReplaceUsings(new TextEditorDocument(document), cu.UsingScope.Usings, newUsings);
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:34,代码来源:NamespaceRefactoringService.cs

示例4: TryExtendSelectionToComments

		static Selection TryExtendSelectionToComments(IDocument document, Selection selection, IList<ISpecial> commentsBlankLines)
		{
			var extendedToComments = ExtendSelectionToComments(document, selection, commentsBlankLines);
			if (extendedToComments != null)
				return extendedToComments;
			return selection;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:7,代码来源:CodeManipulation.cs

示例5: Initialize

		public void Initialize(IDocument document)
		{
			if (changeList != null && changeList.Any())
				return;
			
			this.document = document;
			this.textDocument = (TextDocument)document.GetService(typeof(TextDocument));
			this.changeList = new CompressingTreeList<LineChangeInfo>((x, y) => x.Equals(y));
			
			Stream baseFileStream = GetBaseVersion();
			
			// TODO : update baseDocument on VCS actions
			if (baseFileStream != null) {
				// ReadAll() is taking care of closing the stream
				baseDocument = DocumentUtilitites.LoadReadOnlyDocumentFromBuffer(new StringTextBuffer(ReadAll(baseFileStream)));
			} else {
				if (baseDocument == null) {
					// if the file is not under subversion, the document is the opened document
					var doc = new TextDocument(textDocument.Text);
					baseDocument = new AvalonEditDocumentAdapter(doc, null);
				}
			}
			
			SetupInitialFileState(false);
			
			this.textDocument.LineTrackers.Add(this);
			this.textDocument.UndoStack.PropertyChanged += UndoStackPropertyChanged;
		}
开发者ID:xiaochuwang,项目名称:SharpDevelop-master,代码行数:28,代码来源:DefaultChangeWatcher.cs

示例6: SearchBracketBackward

		static int SearchBracketBackward(IDocument document, int offset, char openBracket, char closingBracket)
		{
			bool inString  = false;
			char ch;
			int brackets = -1;
			for (int i = offset; i > 0; --i) {
				ch = document.GetCharAt(i);
				if (ch == openBracket && !inString) {
					++brackets;
					if (brackets == 0) return i;
				} else if (ch == closingBracket && !inString) {
					--brackets;
				} else if (ch == '"') {
					inString = !inString;
				} else if (ch == '\n') {
					int lineStart = ScanLineStart(document, i);
					if (lineStart >= 0) { // line could have a comment
						inString = false;
						for (int j = lineStart; j < i; ++j) {
							ch = document.GetCharAt(j);
							if (ch == '"') inString = !inString;
							if (ch == '\'' && !inString) {
								// comment found!
								// Skip searching in the comment:
								i = j;
								break;
							}
						}
					}
					inString = false;
				}
			}
			return -1;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:34,代码来源:VBNetBracketSearcher.cs

示例7: Row

        /// <summary>
        /// Initializes a new instance of the <see cref="Row"/> class.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="node">The node.</param>
        public Row(IDocument document, XmlNode node)
        {
            this.Document					= document;
            this.Node						= node;

            this.InitStandards();
        }
开发者ID:stuzzicadenti,项目名称:aodl,代码行数:12,代码来源:Row.cs

示例8: TableEditor

        /// <summary>
        /// Constructs and initializes editor.
        /// </summary>        
        /// <param name="document">Reference to document object.</param>
        public TableEditor(IDocument document)
            : base(document)
        {
            if (!(document is TableDocument))
                throw new ArgumentException(
                    Resources.Error_UnsupportedDocument,
                    "document");

            InitializeComponent();

            // Set columns grid databindings
            InitializeColumnsGridDatabindings();

            // Change advanced columns grid properties
            AdjustColumnsGridStyle();

            // Initialize column details tab
            InitColumnDetails();

            // Initialize foreign keys tab
            foreignKeysEdit.Document = Document;

            // Initialize indexes tab
            indexesEdit.Document = Document;
        }
开发者ID:tdhieu,项目名称:openvss,代码行数:29,代码来源:TableEditor.cs

示例9: FixSpellingCodeAction

 public FixSpellingCodeAction(IDocument document, CommonSyntaxNode syntaxNode, string oldIdentifier, string newIdentifier)
 {
     this.Document = document;
     this.Node = syntaxNode;
     this.OldIdentifier = oldIdentifier;
     this.NewIdentifier = newIdentifier;
 }
开发者ID:PashaPash,项目名称:Refactorings,代码行数:7,代码来源:FixSpellingCodeAction.cs

示例10: ClassifyNode

        public IEnumerable<SyntaxClassification> ClassifyNode(IDocument document, CommonSyntaxNode syntax, CancellationToken cancellationToken)
        {
            // If this node is a field declaration, return syntax classifications for the
            // identifier token of each field name.
            //
            // For example, "x" and "y" would be classified in the following code:
            // 
            // class C
            // {
            //     int x, y;
            // }
            if (syntax is FieldDeclarationSyntax)
            {
                var field = (FieldDeclarationSyntax)syntax;

                return from v in field.Declaration.Variables
                       select new SyntaxClassification(v.Identifier.Span, fieldClassification);
            }

            // If this node is an identifier, use the binding API to retrieve its symbol and return a 
            // syntax classification for the node if that symbol is a field.
            if (syntax is IdentifierNameSyntax)
            {
                var semanticModel = document.GetSemanticModel(cancellationToken);
                var symbol = semanticModel.GetSemanticInfo(syntax).Symbol;

                if (symbol != null && symbol.Kind == CommonSymbolKind.Field)
                {
                    return new[] { new SyntaxClassification(syntax.Span, fieldClassification) };
                }
            }

            return null;
        }
开发者ID:jjrdk,项目名称:CqrsMessagingTools,代码行数:34,代码来源:FieldSyntaxClassifier.cs

示例11: Paste

		/// <exception cref="ArgumentNullException">
		/// <paramref name="document"/> is null.
		/// </exception>
		public static void Paste(IDocument document)
		{
			if (document == null)
				throw new ArgumentNullException("document");

			item.Paste(document);
		}
开发者ID:gbaychev,项目名称:NClass,代码行数:10,代码来源:Clipboard.cs

示例12: CreateHtmlFragment

		/// <summary>
		/// Creates a HTML fragment from a part of a document.
		/// </summary>
		/// <param name="document">The document to create HTML from.</param>
		/// <param name="highlighter">The highlighter used to highlight the document. <c>null</c> is valid and will create HTML without any highlighting.</param>
		/// <param name="segment">The part of the document to create HTML for. You can pass <c>null</c> to create HTML for the whole document.</param>
		/// <param name="options">The options for the HTML creation.</param>
		/// <returns>HTML code for the document part.</returns>
		public static string CreateHtmlFragment(IDocument document, IHighlighter highlighter, ISegment segment, HtmlOptions options)
		{
			if (document == null)
				throw new ArgumentNullException("document");
			if (options == null)
				throw new ArgumentNullException("options");
			if (highlighter != null && highlighter.Document != document)
				throw new ArgumentException("Highlighter does not belong to the specified document.");
			if (segment == null)
				segment = new SimpleSegment(0, document.TextLength);
			
			StringBuilder html = new StringBuilder();
			int segmentEndOffset = segment.EndOffset;
			IDocumentLine line = document.GetLineByOffset(segment.Offset);
			while (line != null && line.Offset < segmentEndOffset) {
				HighlightedLine highlightedLine;
				if (highlighter != null)
					highlightedLine = highlighter.HighlightLine(line.LineNumber);
				else
					highlightedLine = new HighlightedLine(document, line);
				SimpleSegment s = SimpleSegment.GetOverlap(segment, line);
				if (html.Length > 0)
					html.AppendLine("<br>");
				html.Append(highlightedLine.ToHtml(s.Offset, s.EndOffset, options));
				line = line.NextLine;
			}
			return html.ToString();
		}
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:36,代码来源:HtmlClipboard.cs

示例13: CheckCondition

            protected override ICodeIssueComputer CheckCondition(IDocument before, IDocument after,
                                                                 IManualExtractMethodRefactoring input)
            {
                // Calculate the outflow data
                IEnumerable<ISymbol> flowOuts;
                if (input.ExtractedStatements != null)
                    flowOuts = GetFlowOutData(input.ExtractedStatements, before);
                else
                    flowOuts = GetFlowOutData(input.ExtractedExpression, before);

                // Get the returning data of the return statements.
                var delaration = input.ExtractedMethodDeclaration;
                var methodAnalyzer = AnalyzerFactory.GetMethodDeclarationAnalyzer();
                methodAnalyzer.SetMethodDeclaration(delaration);

                // Get the returning data in the return statements of the extracted method, also log them.
                var returningData = GetMethodReturningData(methodAnalyzer, after);

                // Missing symbols that are in the flow out before but not in the returning data.
                // Remove this symbol.
                var missing = ConditionCheckersUtils.RemoveThisSymbol(
                    ConditionCheckersUtils.GetSymbolListExceptByName(flowOuts, returningData));

                if (missing.Any())
                {
                    return new ReturnTypeCheckingResult(input.ExtractedMethodDeclaration,
                        ConditionCheckersUtils.GetTypeNameTuples(missing));
                }
                return new NullCodeIssueComputer();
            }
开发者ID:nkcsgexi,项目名称:ghostfactor1,代码行数:30,代码来源:ReturnTypeChecker.cs

示例14: ProcessResponseAsync

 protected override async Task ProcessResponseAsync(IResponse response)
 {
     var context = new BrowsingContext(_parentDocument.Context, Sandboxes.None);
     var options = new CreateDocumentOptions(response, _configuration, _parentDocument);
     var factory = _configuration.GetFactory<IDocumentFactory>();
     ChildDocument = await factory.CreateAsync(context, options, CancellationToken.None).ConfigureAwait(false);
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:7,代码来源:DocumentRequestProcessor.cs

示例15: Render

 public RenderInfo Render(IDocument document)
 {
     return new RenderInfo {
         PartialViewName = "Body",
         Model = document.Body
     };
 }
开发者ID:thoemmi,项目名称:ViewComposition,代码行数:7,代码来源:BodyRenderer.cs


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