本文整理汇总了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;
});
}
示例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();
}
}
示例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;
});
}
示例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);
}
}
}