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


C# VisualStudioApp.GetService方法代码示例

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


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

示例1: InteractiveWindow

        public InteractiveWindow(string title, AutomationElement element, VisualStudioApp app)
            : base(null, element) {
            _app = app;
            _title = title;

            var compModel = _app.GetService<IComponentModel>(typeof(SComponentModel));
            var replWindowProvider = compModel.GetService<InteractiveWindowProvider>();
            _replWindow = replWindowProvider
#if DEV14_OR_LATER
                .GetReplToolWindows()
#else
                .GetReplWindows()
#endif
                .OfType<ToolWindowPane>()
                .FirstOrDefault(p => p.Caption.Equals(title, StringComparison.CurrentCulture));
#if DEV14_OR_LATER
            _interactive = ((IVsInteractiveWindow)_replWindow).InteractiveWindow;
#else
            _interactive = (IReplWindow)_replWindow;
#endif

            _replWindowInfo = _replWindows.GetValue(_replWindow, window => {
                var info = new InteractiveWindowInfo();
                _interactive.ReadyForInput += new Action(info.OnReadyForInput);
                return info;
            });
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:27,代码来源:InteractiveWindow.cs

示例2: CloseAll

 public static void CloseAll(VisualStudioApp app = null) {
     IComponentModel compModel;
     if (app != null) {
         compModel = app.GetService<IComponentModel>(typeof(SComponentModel));
     } else {
         compModel = (IComponentModel)VSTestContext.ServiceProvider.GetService(typeof(SComponentModel));
     }
     var replWindowProvider = compModel.GetService<IReplWindowProvider>();
     foreach (var frame in replWindowProvider.GetReplWindows()
         .OfType<ReplWindow>()
         .Select(r => r.Frame)
         .OfType<IVsWindowFrame>()) {
         frame.Hide();
     }
 }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:15,代码来源:InteractiveWindow.cs

示例3: InteractiveWindow

        public InteractiveWindow(string title, AutomationElement element, VisualStudioApp app)
            : base(null, element) {
            _app = app;
            _title = title;

            var compModel = _app.GetService<IComponentModel>(typeof(SComponentModel));
            var replWindowProvider = compModel.GetService<IReplWindowProvider>();
            _replWindow = replWindowProvider.GetReplWindows()
                .OfType<ReplWindow>()
                .FirstOrDefault(p => p.Title.Equals(title, StringComparison.CurrentCulture));

            _replWindowInfo = _replWindows.GetValue(_replWindow, window => {
                var info = new ReplWindowInfo();
                window.ReadyForInput += new Action(info.OnReadyForInput);
                return info;
            });
        }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:17,代码来源:InteractiveWindow.cs

示例4: TestPublishFilesImpersonateCancelCredentials

        public void TestPublishFilesImpersonateCancelCredentials() {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            using (var app = new VisualStudioApp()) {
                try {
                    var project = app.OpenProject(@"TestData\HelloWorld.sln");
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePrivate, subDir);

                    app.OpenSolutionExplorer().SelectProject(project);

                    using (var creds = CredentialsDialog.PublishSelection(app)) {
                        creds.UserName = PrivateShareUser;
                        creds.Password = PrivateSharePasswordIncorrect;
                        creds.Cancel();
                    }

                    var statusBar = app.GetService<IVsStatusbar>(typeof(SVsStatusbar));
                    string text = null;
                    const string expected = "Publish failed: Access to the path";

                    for (int i = 0; i < 10; i++) {
                        ErrorHandler.ThrowOnFailure(statusBar.GetText(out text));

                        if (text.StartsWith(expected)) {
                            break;
                        }
                        System.Threading.Thread.Sleep(1000);
                    }

                    Assert.IsTrue(text.StartsWith(expected), "Expected '{0}', got '{1}'", expected, text);
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
开发者ID:wenh123,项目名称:PTVS,代码行数:37,代码来源:PublishTest.cs


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