當前位置: 首頁>>代碼示例>>C#>>正文


C# VisualStudioApp.WaitForMode方法代碼示例

本文整理匯總了C#中Microsoft.VisualStudioTools.VisualStudioApp.WaitForMode方法的典型用法代碼示例。如果您正苦於以下問題:C# VisualStudioApp.WaitForMode方法的具體用法?C# VisualStudioApp.WaitForMode怎麽用?C# VisualStudioApp.WaitForMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.VisualStudioTools.VisualStudioApp的用法示例。


在下文中一共展示了VisualStudioApp.WaitForMode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Breakpoint

        public void Breakpoint()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                TargetInfo ti = GetTargetInfo();

                // Wait for solution to load...
                for (int i = 0; i < 40 && app.Dte.Solution.Projects.Count == 0; i++)
                {
                    System.Threading.Thread.Sleep(250);
                }

                Assert.IsFalse(0 == app.Dte.Solution.Projects.Count);

                // Set platform
                foreach (SolutionConfiguration2 solConfiguration2 in app.Dte.Solution.SolutionBuild.SolutionConfigurations)
                {
                    if(String.Equals(solConfiguration2.PlatformName, ti.Plat, StringComparison.Ordinal))
                    {
                        solConfiguration2.Activate();
                        break;
                    }
                }

                // Open project properties
                var item = app.SolutionExplorerTreeView.WaitForItem(
                    "Solution '" + app.Dte.Solution.Projects.Item(1).Name + "' (1 project)",
                    app.Dte.Solution.Projects.Item(1).Name
                );
                AutomationWrapper.Select(item);

                app.Dte.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectReferencesItems.Properties");

                AutomationElement doc = null;
                for (int i = 0; i < 10; i++)
                {
                    doc = app.GetDocumentTab("HelloWorld.njsproj");
                    if (doc != null)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }

                Assert.IsNotNull(doc, "Failed to find project properties tab");

                // Enter IP address of target machine
                var debuggerMachineName = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_debuggerMachineName")
                );
                debuggerMachineName.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type(ti.IP);
                app.Dte.ExecuteCommand("File.SaveAll");

                // Build project
                app.Dte.Solution.SolutionBuild.Build(true);

                // Add breakpoint
                app.Dte.Debugger.Breakpoints.Add(String.Empty, "server.js", 3, 1, String.Empty,
                    dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, String.Empty,
                    String.Empty, 1, String.Empty, 1, dbgHitCountType.dbgHitCountTypeNone);

                // F5
                app.Dte.ExecuteCommand("Debug.Start");

                // Check that breakpoint is hit
                app.WaitForMode(dbgDebugMode.dbgBreakMode);
                Assert.IsTrue(app.Dte.ActiveDocument.Name.Contains("server.js"));
                Assert.IsTrue((app.Dte.ActiveDocument.Object("TextDocument") as TextDocument).Selection.ActivePoint.Line == 3);
            }
        }
開發者ID:sramos30,項目名稱:ntvsiot,代碼行數:75,代碼來源:DebugTests.cs


注:本文中的Microsoft.VisualStudioTools.VisualStudioApp.WaitForMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。