本文整理汇总了C#中System.IServiceProvider类的典型用法代码示例。如果您正苦于以下问题:C# IServiceProvider类的具体用法?C# IServiceProvider怎么用?C# IServiceProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IServiceProvider类属于System命名空间,在下文中一共展示了IServiceProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompletionController
/// <summary>
/// Attaches events for invoking Statement completion
/// </summary>
/// <param name="subjectBuffers"></param>
/// <param name="textView"></param>
/// <param name="completionBrokerMap"></param>
internal CompletionController(IList<ITextBuffer> subjectBuffers, ITextView textView, ICompletionBroker completionBrokerMap, System.IServiceProvider serviceProvider)
{
this.subjectBuffers = subjectBuffers;
this.textView = textView;
this.completionBrokerMap = completionBrokerMap;
this.serviceProvider = serviceProvider;
}
示例2: GoToDefinitionFilterProvider
public GoToDefinitionFilterProvider(
[Import(typeof(SVsServiceProvider))] System.IServiceProvider serviceProvider,
IVsEditorAdaptersFactoryService editorFactory,
IEditorOptionsFactoryService editorOptionsFactory,
ITextDocumentFactoryService textDocumentFactoryService,
[Import(typeof(DotNetReferenceSourceProvider))] ReferenceSourceProvider referenceSourceProvider,
VSLanguageService fsharpVsLanguageService,
ProjectFactory projectFactory)
{
_serviceProvider = serviceProvider;
_editorFactory = editorFactory;
_editorOptionsFactory = editorOptionsFactory;
_textDocumentFactoryService = textDocumentFactoryService;
_referenceSourceProvider = referenceSourceProvider;
_fsharpVsLanguageService = fsharpVsLanguageService;
_projectFactory = projectFactory;
var dte = serviceProvider.GetService(typeof(SDTE)) as DTE;
var events = dte.Events as Events2;
if (events != null)
{
_solutionEvents = events.SolutionEvents;
_solutionEvents.AfterClosing += Cleanup;
}
}
示例3: VisualStudioLogger
public VisualStudioLogger(System.IServiceProvider serviceProvider)
{
if(serviceProvider==null)
throw new ArgumentNullException();
_serviceProvider = serviceProvider;
}
示例4: VsKeyProcessorAdditional
internal VsKeyProcessorAdditional(VsHost host, IVsTextView view, System.IServiceProvider provider)
{
_host = host;
_textView = view;
_serviceProvider = provider;
var hr = view.AddCommandFilter(this, out _nextTarget);
}
示例5: ShowMessageBox
/// <summary>
/// Use this instead of VsShellUtilities.ShowMessageBox because VSU uses ThreadHelper which
/// uses a private interface that can't be mocked AND goes to the global service provider.
/// </summary>
public static int ShowMessageBox(IServiceProvider serviceProvider, string message, string title, OLEMSGICON icon, OLEMSGBUTTON msgButton, OLEMSGDEFBUTTON defaultButton) {
IVsUIShell uiShell = serviceProvider.GetService(typeof(IVsUIShell)) as IVsUIShell;
Debug.Assert(uiShell != null, "Could not get the IVsUIShell object from the services exposed by this serviceprovider");
if (uiShell == null) {
throw new InvalidOperationException();
}
Guid emptyGuid = Guid.Empty;
int result = 0;
serviceProvider.GetUIThread().Invoke(() => {
ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(
0,
ref emptyGuid,
title,
message,
null,
0,
msgButton,
defaultButton,
icon,
0,
out result));
});
return result;
}
示例6: VsCommandFilter
internal VsCommandFilter(IVimBuffer buffer, IVsTextView view, IServiceProvider provider)
{
_buffer = buffer;
_textView = view;
_serviceProvider = provider;
var hr = view.AddCommandFilter(this, out _nextTarget);
}
示例7: EmptyTaskList
/// <include file='doc\VsShellUtilities.uex' path='docs/doc[@for="VsShellUtilities.EmptyTaskList"]/*' />
/// <devdoc>
/// Empty the task list.
/// </devdoc>
/// <param name="serviceProvider">The service provider.</param>
/// <returns>If the method succeeds, it returns S_OK. If it fails, it returns an error code. </returns>
public static int EmptyTaskList(IServiceProvider serviceProvider)
{
if (serviceProvider == null)
{
throw new ArgumentException("serviceProvider");
}
IVsTaskList taskList = serviceProvider.GetService(typeof(IVsTaskList)) as IVsTaskList;
if (taskList == null)
{
throw new InvalidOperationException();
}
IVsEnumTaskItems enumTaskItems;
int result = VSConstants.S_OK;
try
{
ErrorHandler.ThrowOnFailure(taskList.EnumTaskItems(out enumTaskItems));
if (enumTaskItems == null)
{
throw new InvalidOperationException();
}
// Retrieve the task item text and check whether it is equal with one that supposed to be thrown.
uint[] fetched = new uint[1];
do
{
IVsTaskItem[] taskItems = new IVsTaskItem[1];
result = enumTaskItems.Next(1, taskItems, fetched);
if (fetched[0] == 1)
{
IVsTaskItem2 taskItem = taskItems[0] as IVsTaskItem2;
if (taskItem != null)
{
int canDelete;
ErrorHandler.ThrowOnFailure(taskItem.CanDelete(out canDelete));
if (canDelete == 1)
{
ErrorHandler.ThrowOnFailure(taskItem.OnDeleteTask());
}
}
}
} while (result == VSConstants.S_OK && fetched[0] == 1);
}
catch (COMException e)
{
Trace.WriteLine("Exception : " + e.Message);
result = e.ErrorCode;
}
return result;
}
示例8: RenameDocument
/// <summary>
/// Rename document in the running document table from oldName to newName.
/// </summary>
/// <param name="provider">The service provider.</param>
/// <param name="oldName">Full path to the old name of the document.</param>
/// <param name="newName">Full path to the new name of the document.</param>
/// <param name="newItemId">The new item id of the document</param>
public static void RenameDocument(IServiceProvider site, string oldName, string newName, uint newItemId)
{
if(site == null)
{
throw new ArgumentNullException("site");
}
if(String.IsNullOrEmpty(oldName))
{
throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "oldName");
}
if(String.IsNullOrEmpty(newName))
{
throw new ArgumentException(SR.GetString(SR.ParameterCannotBeNullOrEmpty, CultureInfo.CurrentUICulture), "newName");
}
if(newItemId == VSConstants.VSITEMID_NIL)
{
throw new ArgumentNullException("newItemId");
}
IVsRunningDocumentTable pRDT = site.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
IVsUIShellOpenDocument doc = site.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;
if(pRDT == null || doc == null) return;
IVsHierarchy pIVsHierarchy;
uint itemId;
IntPtr docData;
uint uiVsDocCookie;
ErrorHandler.ThrowOnFailure(pRDT.FindAndLockDocument((uint)_VSRDTFLAGS.RDT_NoLock, oldName, out pIVsHierarchy, out itemId, out docData, out uiVsDocCookie));
if(docData != IntPtr.Zero)
{
try
{
IntPtr pUnk = Marshal.GetIUnknownForObject(pIVsHierarchy);
Guid iid = typeof(IVsHierarchy).GUID;
IntPtr pHier;
Marshal.QueryInterface(pUnk, ref iid, out pHier);
try
{
ErrorHandler.ThrowOnFailure(pRDT.RenameDocument(oldName, newName, pHier, newItemId));
}
finally
{
if(pHier != IntPtr.Zero)
Marshal.Release(pHier);
if(pUnk != IntPtr.Zero)
Marshal.Release(pUnk);
}
}
finally
{
Marshal.Release(docData);
}
}
}
示例9: TaskProvider
public TaskProvider(IServiceProvider site){
this.site = site;
this.taskList = (IVsTaskList)this.site.GetService(typeof(SVsTaskList));
items = new ArrayList();
RegisterProvider();
taskTokens = new TaskTokens(site);
taskTokens.Refresh();
}
示例10: ToolWindowPane
/// <include file='doc\ToolWindowPane.uex' path='docs/doc[@for="ToolWindowPane.ToolWindowPane"]/*' />
/// <summary>
/// Constructor
/// </summary>
protected ToolWindowPane(IServiceProvider provider)
: base(provider)
{
toolClsid = Guid.Empty;
bitmapIndex = -1;
bitmapResourceID = -1;
toolBarLocation = VSTWT_LOCATION.VSTWT_TOP;
}
示例11: SpringQuickInfoSource
public SpringQuickInfoSource(ITextBuffer textBuffer, ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService,
IVsEditorAdaptersFactoryService vsEditorAdaptersFactoryService, System.IServiceProvider serviceProvider)
{
this.textBuffer = textBuffer;
this.textStructureNavigatorSelectorService = textStructureNavigatorSelectorService;
this.vsEditorAdaptersFactoryService = vsEditorAdaptersFactoryService;
this.serviceProvider = serviceProvider;
}
示例12: XmlResourceCompletionController
internal XmlResourceCompletionController(System.IServiceProvider serviceProvider, IVsTextView vsTextView, ITextView textView, ICompletionBroker completionBroker, ITextStructureNavigatorSelectorService textStructureNavigatorSelectorService)
{
this.serviceProvider = serviceProvider;
this.textView = textView;
this.completionBroker = completionBroker;
//add the command to the command chain
vsTextView.AddCommandFilter(this, out nextCommandTarget);
}
示例13: OleMenuCommandService
/// <include file='doc\OleMenuCommandService.uex' path='docs/doc[@for="OleMenuCommandService.OleMenuCommandService1"]/*' />
/// <devdoc>
/// Creates a new menu command service.
/// </devdoc>
public OleMenuCommandService(IServiceProvider serviceProvider, IOleCommandTarget parentCommandTarget)
: base(serviceProvider)
{
if (parentCommandTarget == null) {
throw new ArgumentNullException("parentCommandTarget");
}
_parentTarget = parentCommandTarget;
_provider = serviceProvider;
}
示例14: AdminCommandTarget
public AdminCommandTarget(IServiceProvider provider) : base(provider)
{
_siteUrl =
() =>
provider
.GetRequiredService<IWebConnectionService>()
.GetConfig()
.SiteUrl;
}
示例15: AbstractObjectBrowserLibraryManager
protected AbstractObjectBrowserLibraryManager(string languageName, Guid libraryGuid, IServiceProvider serviceProvider)
: base(libraryGuid, serviceProvider)
{
_languageName = languageName;
var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
this.Workspace = componentModel.GetService<VisualStudioWorkspace>();
this.Workspace.WorkspaceChanged += OnWorkspaceChanged;
}