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


C# Document.Object方法代码示例

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


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

示例1: getDocumentText

        private string getDocumentText(Document document)
        {
            if (document == null) return null;

            var textDocument = (TextDocument)document.Object("TextDocument");
            EditPoint editPoint = textDocument.StartPoint.CreateEditPoint();
            var content = editPoint.GetText(textDocument.EndPoint);
            return content;
        }
开发者ID:stickleprojects,项目名称:ClassOutline,代码行数:9,代码来源:RegionParser.cs

示例2: InitialCleanup

 internal InitialCleanup(ITextDocument textDocument, _DTE ide, FileConfiguration settings)
 {
     _doc = ide.Documents.OfType<Document>()
         .FirstOrDefault(x => x.FullName == textDocument.FilePath);
     if (_doc != null)
         _textDoc = (TextDocument) _doc.Object("TextDocument");
     _ide = ide;
     _settings = settings;
     _eol = settings.EndOfLine();
 }
开发者ID:octoberclub,项目名称:editorconfig-visualstudio,代码行数:10,代码来源:InitialCleanup.cs

示例3: GetDocumentLanguage

        /// <summary>
        /// The get document language.
        /// </summary>
        /// <param name="doc">
        /// The doc.
        /// </param>
        /// <returns>
        /// The System.String.
        /// </returns>
        public static string GetDocumentLanguage(Document doc)
        {
            var textDoc = doc.Object("TextDocument") as TextDocument;

            if (textDoc == null)
            {
                return string.Empty;
            }

            return textDoc.Language.ToLower();
        }
开发者ID:ronaldbroens,项目名称:VSSonarQubeExtension,代码行数:20,代码来源:VSSonarUtils.cs

示例4: VisualStudioOpenDocumentReader

        public VisualStudioOpenDocumentReader(Document document)
        {
            try
            {
                //http://msdn.microsoft.com/en-us/library/ms228776.aspx
                _textDocument = (EnvDTE.TextDocument) (document.Object("TextDocument"));
            }
            catch (Exception e)
            {
                _log.Warn("Failed to create a TextDocument from Document: " + e.Message, e);
            }

            _classFileName = document.FullName.SafeToLower();
        }
开发者ID:prescottadam,项目名称:pMixins,代码行数:14,代码来源:VisualStudioOpenDocumentReader.cs

示例5: GetCurrentScenario

        private IScenarioBlock GetCurrentScenario(GherkinLanguageService languageService, Document activeDocument, out IGherkinFileScope fileScope)
        {
            var currentTextDocument = ((TextDocument)activeDocument.Object("TextDocument"));
            var currentLine = currentTextDocument.Selection.ActivePoint.Line;

            fileScope = languageService.GetFileScope();
            if (fileScope == null)
                return null;

            var block = fileScope.GetStepBlockFromStepPosition(currentLine) as IScenarioBlock;
            if (block != null && currentLine > block.KeywordLine + block.BlockRelativeContentEndLine)
                return null; // between two scenarios

            return block;
        }
开发者ID:richieallen,项目名称:SpecFlow,代码行数:15,代码来源:TestRunnerEngine.cs

示例6: RunCodeCleanupGeneric

        /// <summary>
        /// Attempts to run code cleanup on the specified generic document.
        /// </summary>
        /// <param name="document">The document for cleanup.</param>
        /// <param name="textBuffer">The text buffer for the document.</param>
        private void RunCodeCleanupGeneric(Document document, ITextBuffer textBuffer)
        {
            ITextDocument textDocument;

            var doc = (TextDocument)document.Object("TextDocument");
            textBuffer.Properties.TryGetProperty(typeof(ITextDocument), out textDocument);

            var path = doc.Parent.FullName;

            FileConfiguration settings;
            if (!ConfigLoader.TryLoad(path, out settings))
                return;

            using (ITextEdit edit = textBuffer.CreateEdit())
            {
                ITextSnapshot snapshot = edit.Snapshot;

                if (settings.Charset != null && textDocument != null)
                    FixDocumentCharset(textDocument, settings.Charset.Value);

                if (settings.TryKeyAsBool("trim_trailing_whitespace"))
                    TrimTrailingWhitespace(snapshot, edit);

                if (settings.TryKeyAsBool("insert_final_newline"))
                    InsertFinalNewline(snapshot, edit, settings.EndOfLine());

                var eol = settings.EndOfLine();
                FixLineEndings(snapshot, edit, eol);

                edit.Apply();
            }
        }
开发者ID:editorconfig,项目名称:editorconfig-visualstudio,代码行数:37,代码来源:CodeCleanupManager.cs

示例7: Execute

        private void Execute(Document document)
        {
            if (!IsFormatableDocument(document))
            {
                return;
            }

            Properties xamlEditorProps = _dte.Properties["TextEditor", "XAML"];

            var stylerOptions = GetDialogPage(typeof (PackageOptions)).AutomationObject as IStylerOptions;

            stylerOptions.IndentSize = Int32.Parse(xamlEditorProps.Item("IndentSize").Value.ToString());
            stylerOptions.IndentWithTabs = (bool) xamlEditorProps.Item("InsertTabs").Value;

            StylerService styler = StylerService.CreateInstance(stylerOptions);

            var textDocument = (TextDocument) document.Object("TextDocument");

            TextPoint currentPoint = textDocument.Selection.ActivePoint;
            int originalLine = currentPoint.Line;
            int originalOffset = currentPoint.LineCharOffset;

            EditPoint startPoint = textDocument.StartPoint.CreateEditPoint();
            EditPoint endPoint = textDocument.EndPoint.CreateEditPoint();

            string xamlSource = startPoint.GetText(endPoint);
            xamlSource = styler.ManipulateTreeAndFormatInput(xamlSource);

            startPoint.ReplaceText(endPoint, xamlSource, 0);

            if (originalLine <= textDocument.EndPoint.Line)
            {
                textDocument.Selection.MoveToLineAndOffset(originalLine, originalOffset);
            }
            else
            {
                textDocument.Selection.GotoLine(textDocument.EndPoint.Line);
            }
        }
开发者ID:KSSDevelopment,项目名称:XamlStyler,代码行数:39,代码来源:StylerPackage.cs

示例8: GetCurrentLine

 private int GetCurrentLine(Document activeDocument)
 {
     var currentTextDocument = ((TextDocument) activeDocument.Object("TextDocument"));
     var currentLine = currentTextDocument.Selection.ActivePoint.Line;
     return currentLine;
 }
开发者ID:rdumont,项目名称:SpecFlow,代码行数:6,代码来源:TestRunnerEngine.cs

示例9: Execute

        public void Execute(Document document)
        {
            if (null == document)
            {
                throw new ArgumentNullException(nameof(document));
            }

            var textDocument = document.Object("TextDocument") as TextDocument;

            if (null == textDocument)
            {
                return;
            }

            output.WriteLine($"[XamlStyler] formatting document: {document.FullName}");

            var start = textDocument.StartPoint.CreateEditPoint();
            var end = textDocument.EndPoint.CreateEditPoint();

            var current = textDocument.Selection.ActivePoint;
            var linenumber = current.Line;
            var charoffset = current.LineCharOffset;

            using (var reader = new StringReader(start.GetText(end)))
            {
                var text = new StringBuilder();
                var node = XamlParser.Parse(reader);
                var visitor = new StylerNodeVisitor(text);

                visitor.Visit(node);

                start.ReplaceText(end, text.ToString(), 0);
            }

            if (linenumber <= textDocument.EndPoint.Line)
            {
                var position = start.CreateEditPoint();

                if (linenumber > 0)
                {
                    position.LineDown(linenumber - 1);
                }

                charoffset = Math.Min(charoffset, position.LineLength + 1);

                if (charoffset > 0)
                {
                    textDocument.Selection.MoveToLineAndOffset(linenumber, charoffset);
                }
                else
                {
                    textDocument.Selection.GotoLine(linenumber);
                }
            }
            else
            {
                var position = start.CreateEditPoint();

                position.EndOfDocument();
                textDocument.Selection.MoveToPoint(position);
            }
        }
开发者ID:VlaTo,项目名称:Libra-Xaml-Styler,代码行数:62,代码来源:FormatDocumentCommand.cs

示例10: Execute

        private void Execute(Document document)
        {
            if (!IsFormatableDocument(document))
            {
                return;
            }

            Properties xamlEditorProps = _dte.Properties["TextEditor", "XAML"];

            var stylerOptions = GetDialogPage(typeof(PackageOptions)).AutomationObject as IStylerOptions;

            var solutionPath = String.IsNullOrEmpty(_dte.Solution?.FullName)
                ? String.Empty
                : Path.GetDirectoryName(_dte.Solution.FullName);
            var configPath = GetConfigPathForItem(document.Path, solutionPath);

            if (configPath != null)
            {
                stylerOptions = ((StylerOptions)stylerOptions).Clone();
                stylerOptions.ConfigPath = configPath;
            }

            if (stylerOptions.UseVisualStudioIndentSize)
            {
                int outIndentSize;
                if (Int32.TryParse(xamlEditorProps.Item("IndentSize").Value.ToString(), out outIndentSize)
                    && (outIndentSize > 0))
                {
                    stylerOptions.IndentSize = outIndentSize;
                }
            }

            stylerOptions.IndentWithTabs = (bool)xamlEditorProps.Item("InsertTabs").Value;

            StylerService styler = new StylerService(stylerOptions);

            var textDocument = (TextDocument)document.Object("TextDocument");

            TextPoint currentPoint = textDocument.Selection.ActivePoint;
            int originalLine = currentPoint.Line;
            int originalOffset = currentPoint.LineCharOffset;

            EditPoint startPoint = textDocument.StartPoint.CreateEditPoint();
            EditPoint endPoint = textDocument.EndPoint.CreateEditPoint();

            string xamlSource = startPoint.GetText(endPoint);
            xamlSource = styler.StyleDocument(xamlSource);

            startPoint.ReplaceText(endPoint, xamlSource, 0);

            if (originalLine <= textDocument.EndPoint.Line)
            {
                textDocument.Selection.MoveToLineAndOffset(originalLine, originalOffset);
            }
            else
            {
                textDocument.Selection.GotoLine(textDocument.EndPoint.Line);
            }
        }
开发者ID:tmatz,项目名称:XamlStyler,代码行数:59,代码来源:StylerPackage.cs

示例11: set_doc

 internal query_window set_doc(Document doc)
 {
     _doc = doc;
     _tdoc = (TextDocument)_doc.Object("TextDocument");
     return this;
 }
开发者ID:leendek,项目名称:SSMS_OpenFile,代码行数:6,代码来源:SSMSW08.cs

示例12: Post

        internal List<object> Post(string query, bool returnCount, out int count, int batchSize, Dictionary<string, object> bindVars)
        {
            var request = new Request(RequestType.Cursor, HttpMethod.Post);
            request.RelativeUri = _apiUri;

            var bodyDocument = new Document();

            // set AQL string
            bodyDocument.String("query", query);

            // (optional) set number of found documents
            if (returnCount)
            {
                bodyDocument.Bool("count", returnCount);
            }

            // (optional) set how much documents should be returned
            if (batchSize > 0)
            {
                bodyDocument.Int("batchSize", batchSize);
            }

            // (optional) set list of bind parameters
            if ((bindVars != null) && (bindVars.Count > 0))
            {
                var bindVarsDocument = new Document();

                foreach (KeyValuePair<string, object> item in bindVars)
                {
                    bindVarsDocument.Object(item.Key, item.Value);
                }

                bodyDocument.Object("bindVars", bindVarsDocument);
            }

            request.Body = bodyDocument.Serialize();

            var response = _connection.Process(request);
            var items = new List<object>();
            count = 0;

            switch (response.StatusCode)
            {
                case HttpStatusCode.Created:
                    items.AddRange(response.Document.List<object>("result"));

                    // get count of returned document if present
                    if (returnCount)
                    {
                        count = response.Document.Int("count");
                    }

                    // get more results if present
                    if (response.Document.Bool("hasMore"))
                    {
                        long cursorId = response.Document.Long("id");

                        items.AddRange(Put(cursorId));
                    }
                    break;
                default:
                    items = null;

                    if (response.IsException)
                    {
                        throw new ArangoException(
                            response.StatusCode,
                            response.Document.String("driverErrorMessage"),
                            response.Document.String("driverExceptionMessage"),
                            response.Document.Object<Exception>("driverInnerException")
                        );
                    }
                    break;
            }

            return items;
        }
开发者ID:jocull,项目名称:ArangoDB-NET,代码行数:77,代码来源:CursorOperation.cs

示例13: getDocumentText

        private string getDocumentText(Document document, int startline, int startLineOfCodeOffset, int endline)
        {
            if (document == null) return null;
            try
            {
                var textDocument = (TextDocument) document.Object("TextDocument");
                EditPoint editPoint = null;
                if (startline >= 0)
                {
                    editPoint = textDocument.CreateEditPoint();
                    return editPoint.GetLines(startline, endline);
                }

                editPoint = textDocument.StartPoint.CreateEditPoint();
                
                return editPoint.GetText(textDocument.EndPoint);
            }
            catch (Exception e )
            {
                return null;
            }
        }
开发者ID:stickleprojects,项目名称:ClassOutline,代码行数:22,代码来源:ViewParser.cs

示例14: getCodeElementFromLine

        private CodeElement getCodeElementFromLine(Document document, int startline, int startLineOfCodeOffset)
        {
            var textDocument = (TextDocument) document.Object("TextDocument");
            EditPoint editPoint = null;
            if (startline >= 0)
            {
                try
                {
                    editPoint = textDocument.CreateEditPoint();
                    editPoint.MoveToLineAndOffset(startline,Math.Max(1, startLineOfCodeOffset));

                    return editPoint.CodeElement[vsCMElement.vsCMElementClass];
                }
                catch (COMException e)
                {
                    _log.Error("Failed to getCodeElementFromLine", e );
                }

            }
            return null;
        }
开发者ID:stickleprojects,项目名称:ClassOutline,代码行数:21,代码来源:ViewParser.cs

示例15: BeautifyDocument

        /// <summary>
        /// Beautifies a document.
        /// </summary>
        /// <param name="document">The document to beautify.</param>
        private void BeautifyDocument(Document document)
        {
            if (!IsFormattableDocument(document))
            {
                return;
            }

            var xamlEditorProps = DTE.get_Properties("TextEditor", "XAML");
            var insertTabs = (bool)xamlEditorProps.Item("InsertTabs").Value;

            var styler = new Styler()
            {
                IndentCharacter = insertTabs ? '\t' : ' ',
                IndentSize = Int32.Parse(xamlEditorProps.Item("IndentSize").Value.ToString()),
                Options = StylerOptions
            };

            var textDocument = document.Object("TextDocument") as TextDocument;

            var currentPoint = textDocument.Selection.ActivePoint;
            int originalLine = currentPoint.Line;
            int originalOffset = currentPoint.LineCharOffset;

            var startPoint = textDocument.StartPoint.CreateEditPoint();
            var endPoint = textDocument.EndPoint.CreateEditPoint();

            var xamlSource = styler.Format(startPoint.GetText(endPoint));

            startPoint.ReplaceText(endPoint, xamlSource, 0);

            if (originalLine <= textDocument.EndPoint.Line)
                textDocument.Selection.MoveToLineAndOffset(originalLine, originalOffset, false);
            else
                textDocument.Selection.GotoLine(textDocument.EndPoint.Line);
        }
开发者ID:jeffboulanger,项目名称:xaml-styler-2012,代码行数:39,代码来源:XamlStylerVSPackage.cs


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