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


C# System.IServiceProvider類代碼示例

本文整理匯總了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;
 }
開發者ID:kageyamaginn,項目名稱:VSSDK-Extensibility-Samples,代碼行數:13,代碼來源:CompletionController.cs

示例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;
            }
        }
開發者ID:bryanhunter,項目名稱:VisualFSharpPowerTools,代碼行數:25,代碼來源:GotoDefinitionFilterProvider.cs

示例3: VisualStudioLogger

        public VisualStudioLogger(System.IServiceProvider serviceProvider)
        {
            if(serviceProvider==null)
                throw new ArgumentNullException();

            _serviceProvider = serviceProvider;
        }
開發者ID:pzielinski86,項目名稱:RuntimeTestCoverage,代碼行數:7,代碼來源:VisualStudioLogger.cs

示例4: VsKeyProcessorAdditional

 internal VsKeyProcessorAdditional(VsHost host, IVsTextView view,  System.IServiceProvider provider)
 {
     _host = host;
     _textView = view;
     _serviceProvider = provider;
     var hr = view.AddCommandFilter(this, out _nextTarget);
 }
開發者ID:joycode,項目名稱:LibNVim,代碼行數:7,代碼來源:VsKeyProcessorAdditional.cs

示例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;
        }
開發者ID:bnavarma,項目名稱:ScalaTools,代碼行數:30,代碼來源:Utilities.cs

示例6: VsCommandFilter

 internal VsCommandFilter(IVimBuffer buffer, IVsTextView view, IServiceProvider provider)
 {
     _buffer = buffer;
     _textView = view;
     _serviceProvider = provider;
     var hr = view.AddCommandFilter(this, out _nextTarget);
 }
開發者ID:ChrisMarinos,項目名稱:VsVim,代碼行數:7,代碼來源:VsCommandFilter.cs

示例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;
        }
開發者ID:Graham-Pedersen,項目名稱:IronPlot,代碼行數:65,代碼來源:VsShellUtilities.cs

示例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);
                }
            }
        }
開發者ID:Rfvgyhn,項目名稱:Boo-Plugin,代碼行數:66,代碼來源:DocumentManager.cs

示例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();
 }
開發者ID:hesam,項目名稱:SketchSharp,代碼行數:8,代碼來源:TaskItem.cs

示例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;
 }
開發者ID:Graham-Pedersen,項目名稱:IronPlot,代碼行數:12,代碼來源:ToolWindowPane.cs

示例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;
 }
開發者ID:koskedk,項目名稱:spring-net-vsnet,代碼行數:8,代碼來源:SpringQuickInfoSource.cs

示例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);
        }
開發者ID:Xtremrules,項目名稱:dot42,代碼行數:9,代碼來源:XmlResourceCompletionController.cs

示例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;
 }
開發者ID:Graham-Pedersen,項目名稱:IronPlot,代碼行數:13,代碼來源:OleMenuCommandService.cs

示例14: AdminCommandTarget

		public AdminCommandTarget(IServiceProvider provider) : base(provider)
		{
			_siteUrl =
				() =>
					provider
						.GetRequiredService<IWebConnectionService>()
						.GetConfig()
						.SiteUrl;
		}
開發者ID:rsdn,項目名稱:janus,代碼行數:9,代碼來源:AdminCommandTarget.cs

示例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;
        }
開發者ID:GloryChou,項目名稱:roslyn,代碼行數:9,代碼來源:AbstractObjectBrowserLibraryManager.cs


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