• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IServiceProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IServiceProvider的典型用法代码示例。如果您正苦于以下问题:C# IServiceProvider类的具体用法?C# IServiceProvider怎么用?C# IServiceProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IServiceProvider类属于命名空间,在下文中一共展示了IServiceProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Initialize

        public void Initialize(Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSComponentMetaData100 dtsComponentMetadata, IServiceProvider serviceProvider)
        {
            this.serviceProvider = serviceProvider;
              this.metaData = dtsComponentMetadata;

              this.connectionService = (IDtsConnectionService)serviceProvider.GetService(typeof(IDtsConnectionService));
        }
开发者ID:WillByron,项目名称:SSISHDFS,代码行数:7,代码来源:HDFSDestinationUI.cs


示例2: RenameRuleObjectDialog

 public RenameRuleObjectDialog(IServiceProvider serviceProvider, string oldName, NameValidatorDelegate nameValidator, BasicBrowserDialog parent)
 {
     if (oldName == null)
     {
         throw new ArgumentNullException("oldName");
     }
     if (serviceProvider == null)
     {
         throw new ArgumentNullException("serviceProvider");
     }
     if (nameValidator == null)
     {
         throw new ArgumentNullException("nameValidator");
     }
     this.serviceProvider = serviceProvider;
     this.name = oldName;
     this.nameValidator = nameValidator;
     this.parent = parent;
     this.InitializeComponent();
     this.ruleNameTextBox.Text = oldName;
     this.Text = parent.RenameTitleText;
     this.newNamelabel.Text = parent.NewNameLabelText;
     base.Icon = null;
     IUIService service = (IUIService) this.serviceProvider.GetService(typeof(IUIService));
     if (service != null)
     {
         this.Font = (Font) service.Styles["DialogFont"];
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:RenameRuleObjectDialog.cs


示例3: CreateTestServices

        public static ServiceProvider CreateTestServices(
            IServiceProvider applicationServices,
            Project project,
            ReportingChannel channel)
        {
            var services = new ServiceProvider(applicationServices);

            var loggerFactory = new LoggerFactory();
            loggerFactory.AddProvider(new TestHostLoggerProvider(channel));
            services.Add(typeof(ILoggerFactory), loggerFactory);

            var libraryExporter = applicationServices.GetRequiredService<ILibraryExporter>();
            var export = libraryExporter.GetExport(project.Name);

            var projectReference = export.MetadataReferences
                .OfType<IMetadataProjectReference>()
                .Where(r => r.Name == project.Name)
                .FirstOrDefault();

            services.Add(
                typeof(ISourceInformationProvider),
                new SourceInformationProvider(projectReference, loggerFactory.CreateLogger<SourceInformationProvider>()));

            services.Add(typeof(ITestDiscoverySink), new TestDiscoverySink(channel));
            services.Add(typeof(ITestExecutionSink), new TestExecutionSink(channel));

            return services;
        }
开发者ID:krwq,项目名称:Testing,代码行数:28,代码来源:TestServices.cs


示例4: EditValue

 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     IntPtr focus = UnsafeNativeMethods.GetFocus();
     try
     {
         ICom2PropertyPageDisplayService service = (ICom2PropertyPageDisplayService) provider.GetService(typeof(ICom2PropertyPageDisplayService));
         if (service == null)
         {
             service = this;
         }
         object instance = context.Instance;
         if (!instance.GetType().IsArray)
         {
             instance = this.propDesc.TargetObject;
             if (instance is ICustomTypeDescriptor)
             {
                 instance = ((ICustomTypeDescriptor) instance).GetPropertyOwner(this.propDesc);
             }
         }
         service.ShowPropertyPage(this.propDesc.Name, instance, this.propDesc.DISPID, this.guid, focus);
     }
     catch (Exception exception)
     {
         if (provider != null)
         {
             IUIService service2 = (IUIService) provider.GetService(typeof(IUIService));
             if (service2 != null)
             {
                 service2.ShowError(exception, System.Windows.Forms.SR.GetString("ErrorTypeConverterFailed"));
             }
         }
     }
     return value;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:Com2PropertyPageUITypeEditor.cs


示例5: GetUIHierarchyWindow

        /// <summary>
        /// Get reference to IVsUIHierarchyWindow interface from guid persistence slot.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        /// <param name="persistenceSlot">Unique identifier for a tool window created using IVsUIShell::CreateToolWindow. 
        /// The caller of this method can use predefined identifiers that map to tool windows if those tool windows 
        /// are known to the caller. </param>
        /// <returns>A reference to an IVsUIHierarchyWindow interface.</returns>
        public static IVsUIHierarchyWindow GetUIHierarchyWindow(IServiceProvider serviceProvider, Guid persistenceSlot)
        {
            if(serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            IVsUIShell shell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell;

            Debug.Assert(shell != null, "Could not get the ui shell from the project");
            if(shell == null)
            {
                throw new InvalidOperationException();
            }

            object pvar = null;
            IVsWindowFrame frame = null;
            IVsUIHierarchyWindow uiHierarchyWindow = null;

            try
            {
                ErrorHandler.ThrowOnFailure(shell.FindToolWindow(0, ref persistenceSlot, out frame));
                ErrorHandler.ThrowOnFailure(frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocView, out pvar));
            }
            finally
            {
                if(pvar != null)
                {
                    uiHierarchyWindow = (IVsUIHierarchyWindow)pvar;
                }
            }

            return uiHierarchyWindow;
        }
开发者ID:zooba,项目名称:wix3,代码行数:42,代码来源:VSShellUtilities.cs


示例6: CreateStore

        private static IInMemoryDataStore CreateStore(IServiceProvider serviceProvider, bool persist)
        {
            var optionsBuilder = new EntityOptionsBuilder();
            optionsBuilder.UseInMemoryStore(persist: persist);

            return InMemoryTestHelpers.Instance.CreateContextServices(serviceProvider, optionsBuilder.Options).GetRequiredService<IInMemoryDataStore>();
        }
开发者ID:aishaloshik,项目名称:EntityFramework,代码行数:7,代码来源:InMemoryDataStoreCreatorTest.cs


示例7: AddOrchardLogging

        public static ILoggerFactory AddOrchardLogging(
            this ILoggerFactory loggingFactory, 
            IServiceProvider serviceProvider)
        {
            /* TODO (ngm): Abstract this logger stuff outta here! */
            var loader = serviceProvider.GetRequiredService<IExtensionLoader>();
            var manager = serviceProvider.GetRequiredService<IExtensionManager>();

            var descriptor = manager.GetExtension("Orchard.Logging.Console");
            var entry = loader.Load(descriptor);
            var loggingInitiatorTypes = entry
                .Assembly
                .ExportedTypes
                .Where(et => typeof(ILoggingInitiator).IsAssignableFrom(et));

            IServiceCollection loggerCollection = new ServiceCollection();
            foreach (var initiatorType in loggingInitiatorTypes) {
                loggerCollection.AddScoped(typeof(ILoggingInitiator), initiatorType);
            }
            var moduleServiceProvider = serviceProvider.CreateChildContainer(loggerCollection).BuildServiceProvider();
            foreach (var service in moduleServiceProvider.GetServices<ILoggingInitiator>()) {
                service.Initialize(loggingFactory);
            }

            return loggingFactory;
        }
开发者ID:SmartFire,项目名称:Orchard2,代码行数:26,代码来源:LoggerFactoryExtensions.cs


示例8: EditValue

        /// <summary>
        /// <para>Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>. This should be a <see cref="DpapiSettings"/> object.</para>
        /// </summary>
        /// <param name="context"><para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para></param>
        /// <param name="provider"><para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para></param>
        /// <param name="value"><para>The object to edit. This should be a <see cref="Password"/> object.</para></param>
        /// <returns><para>The new value of the <see cref="Password"/> object.</para></returns>
        /// <seealso cref="UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, object)"/>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Debug.Assert(provider != null, "No service provider; we cannot edit the value");
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
                if (edSvc != null)
                {
                    IWindowsFormsEditorService service =(IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    using (PasswordEditorUI dialog = new PasswordEditorUI())
                    {
                        if (DialogResult.OK == service.ShowDialog(dialog))
                        {
                            return new Password(dialog.Password);
                        }
                        else
                        {
                            return value;
                        }
                    }
                }
            }
            return value;
        }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:34,代码来源:PasswordEditor.cs


示例9: ProjectBindingOperation

        public ProjectBindingOperation(IServiceProvider serviceProvider, Project project, ISolutionRuleStore ruleStore)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (ruleStore == null)
            {
                throw new ArgumentNullException(nameof(ruleStore));
            }

            this.serviceProvider = serviceProvider;
            this.initializedProject = project;
            this.ruleStore = ruleStore;

            this.sourceControlledFileSystem = this.serviceProvider.GetService<ISourceControlledFileSystem>();
            this.sourceControlledFileSystem.AssertLocalServiceIsNotNull();

            this.ruleSetSerializer = this.serviceProvider.GetService<IRuleSetSerializer>();
            this.ruleSetSerializer.AssertLocalServiceIsNotNull();
        }
开发者ID:duncanpMS,项目名称:sonarlint-visualstudio,代码行数:27,代码来源:ProjectBindingOperation.cs


示例10: Execute

        public static async Task<int> Execute(
            IServiceProvider services, 
            Project project,
            string command,
            string[] args)
        {
            var environment = (IApplicationEnvironment)services.GetService(typeof(IApplicationEnvironment));
            var commandText = project.Commands[command];
            var replacementArgs = CommandGrammar.Process(
                commandText, 
                (key) => GetVariable(environment, key),
                preserveSurroundingQuotes: false)
                .ToArray();

            var entryPoint = replacementArgs[0];
            args = replacementArgs.Skip(1).Concat(args).ToArray();

            if (string.IsNullOrEmpty(entryPoint) ||
                string.Equals(entryPoint, "run", StringComparison.Ordinal))
            {
                entryPoint = project.EntryPoint ?? project.Name;
            }

            CallContextServiceLocator.Locator.ServiceProvider = services;
            return await ExecuteMain(services, entryPoint, args);
        }
开发者ID:israelito3000,项目名称:Testing,代码行数:26,代码来源:ProjectCommand.cs


示例11: EditValue

        /// <include file='doc\QueuePathEditor.uex' path='docs/doc[@for="QueuePathEditor.EditValue"]/*' />
        /// <devdoc>
        ///      Edits the given object value using the editor style provided by
        ///      GetEditorStyle.  A service provider is provided so that any
        ///      required editing services can be obtained.
        /// </devdoc>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    QueuePathDialog dialog = new QueuePathDialog(provider);
                    MessageQueue queue = null;
                    if (value is MessageQueue)
                        queue = (MessageQueue)value;
                    else if (value is string)
                        queue = new MessageQueue((string)value);
                    else if (value != null)
                        return value;

                    if (queue != null)
                        dialog.SelectQueue(queue);

                    IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
                    DesignerTransaction trans = null;
                    if (host != null)
                        trans = host.CreateTransaction();

                    try
                    {
                        if ((context == null || context.OnComponentChanging()) && edSvc.ShowDialog(dialog) == DialogResult.OK)
                        {
                            if (dialog.Path != String.Empty)
                            {
                                if (context.Instance is MessageQueue || context.Instance is MessageQueueInstaller)
                                    value = dialog.Path;
                                else
                                {
                                    value = MessageQueueConverter.GetFromCache(dialog.Path);
                                    if (value == null)
                                    {
                                        value = new MessageQueue(dialog.Path);
                                        MessageQueueConverter.AddToCache((MessageQueue)value);
                                        if (context != null)
                                            context.Container.Add((IComponent)value);
                                    }
                                }

                                context.OnComponentChanged();
                            }
                        }
                    }
                    finally
                    {
                        if (trans != null)
                        {
                            trans.Commit();
                        }
                    }
                }
            }

            return value;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:66,代码来源:QueuePathEditor.cs


示例12: JsonRpcDispatcher

        public JsonRpcDispatcher(IService service, IServiceProvider serviceProvider)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            _service = service;

            if (serviceProvider == null)
            {
                //
                // No service provider supplied so check if the RPC service
                // itself is our service provider.
                //

                serviceProvider = service as IServiceProvider;

                //
                // If no service provider found so far, then create a default
                // one.
                //

                if (serviceProvider == null)
                    serviceProvider = new ServiceContainer();
            }

            _serviceProvider = serviceProvider;
        }
开发者ID:BackupTheBerlios,项目名称:tamjb,代码行数:27,代码来源:JsonRpcDispatcher.cs


示例13: CreateInstance

		public virtual object CreateInstance (IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
		{
			if (_parent != null)
				return _parent.CreateInstance (provider, objectType, argTypes, args);
			
			return System.Activator.CreateInstance (objectType, args);
		}
开发者ID:stabbylambda,项目名称:mono,代码行数:7,代码来源:TypeDescriptionProvider.cs


示例14: EditValue

        /// <summary>
        /// This describes how to launch the form etc.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _context = context;

            IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            SQLExpressionDialog dlgExpression = new SQLExpressionDialog();
            string original = (string)value;
            dlgExpression.Expression = (string)value;

            // Try to find the Table
            IFeatureCategory category = context.Instance as IFeatureCategory;
            if (category != null)
            {
                IFeatureScheme scheme = category.GetParentItem() as IFeatureScheme;
                if (scheme != null)
                {
                    IFeatureLayer layer = scheme.GetParentItem() as IFeatureLayer;
                    if (layer != null)
                    {
                        dlgExpression.Table = layer.DataSet.DataTable;
                    }
                }
                else
                {
                    IFeatureLayer layer = category.GetParentItem() as IFeatureLayer;
                    if (layer != null)
                    {
                        dlgExpression.Table = layer.DataSet.DataTable;
                    }
                }
            }

            dlgExpression.ChangesApplied += DlgExpressionChangesApplied;
            return dialogProvider.ShowDialog(dlgExpression) != DialogResult.OK ? original : dlgExpression.Expression;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:42,代码来源:ExpressionEditor.cs


示例15: ImportWizard

        public ImportWizard(IServiceProvider serviceProvider, string sourcePath, string projectPath) {
            var interpreterService = serviceProvider.GetComponentModel().GetService<IInterpreterOptionsService>();
            _site = serviceProvider;
            ImportSettings = new ImportSettings(serviceProvider, interpreterService);

            _pageSequence = new CollectionViewSource {
                Source = new ObservableCollection<Page>(new Page[] {
                    new FileSourcePage { DataContext = ImportSettings },
                    new InterpreterPage { DataContext = ImportSettings },
                    new SaveProjectPage { DataContext = ImportSettings }
                })
            };
            PageCount = _pageSequence.View.OfType<object>().Count();

            PageSequence = _pageSequence.View;
            PageSequence.CurrentChanged += PageSequence_CurrentChanged;
            PageSequence.MoveCurrentToFirst();

            if (!string.IsNullOrEmpty(sourcePath)) {
                ImportSettings.SetInitialSourcePath(sourcePath);
                Loaded += ImportWizard_Loaded;
            }
            if (!string.IsNullOrEmpty(projectPath)) {
                ImportSettings.SetInitialProjectPath(projectPath);
            }
            ImportSettings.UpdateIsValid();

            DataContext = this;

            InitializeComponent();
        }
开发者ID:smallwave,项目名称:PTVS,代码行数:31,代码来源:ImportWizard.xaml.cs


示例16: Initialize

        public void Initialize(ConnectionManager connectionManager, IServiceProvider serviceProvider)
        {
            this._connectionManager = connectionManager;
            this._serviceProvider = serviceProvider;

            ConfigureControlsFromConnectionManager();
        }
开发者ID:nkuebler000,项目名称:SSIS_SSH_Components,代码行数:7,代码来源:SSHConnectionManagerUIForm.cs


示例17: EditValue

 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     object result = base.EditValue(context, provider, value);
     TreeListView owner = this.Context.Instance as TreeListView;
     owner.Invalidate();
     return result;
 }
开发者ID:moisesiq,项目名称:aupaga,代码行数:7,代码来源:TreeListColumn.Design.cs


示例18: EditValue

        /// <summary>
        /// This should launch an open file dialog instead of the usual thing.
        /// </summary>
        /// <param name="context">System.ComponentModel.ITypeDescriptorContext</param>
        /// <param name="provider">IServiceProvider</param>
        /// <param name="value">The object being displayed</param>
        /// <returns>A new version of the object if the dialog was ok.</returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            object _backup;
            ICloneable parent = value as ICloneable;
            if (parent != null)
            {
                _backup = parent.Clone();
            }
            else
            {
                _backup = value;
            }

            IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            PropertyDialog frm = new PropertyDialog(dialogProvider);
            frm.PropertyGrid.SelectedObject = value;
            if (dialogProvider.ShowDialog(frm) == System.Windows.Forms.DialogResult.OK)
            {
                return value;
            }
            else
            {
                return _backup;
            }
            
        }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:33,代码来源:PropertyGridEditor.cs


示例19: EnsureReplWindow

        internal static IVsInteractiveWindow/*!*/ EnsureReplWindow(IServiceProvider serviceProvider, IPythonInterpreterFactory factory, PythonProjectNode project) {
            var compModel = serviceProvider.GetComponentModel();
            var provider = compModel.GetService<InteractiveWindowProvider>();

            string replId = PythonReplEvaluatorProvider.GetReplId(factory, project);
            var window = provider.FindReplWindow(replId);
            if (window == null) {
                window = provider.CreateInteractiveWindow(
                    serviceProvider.GetPythonContentType(),
                    factory.Description + " Interactive",
                    typeof(PythonLanguageInfo).GUID,
                    replId
                );

                var toolWindow = window as ToolWindowPane;
                if (toolWindow != null) {
                    toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow;
                }

                var pyService = serviceProvider.GetPythonToolsService();
                window.InteractiveWindow.SetSmartUpDown(pyService.GetInteractiveOptions(factory).ReplSmartHistory);
            }

            if (project != null && project.Interpreters.IsProjectSpecific(factory)) {
                project.AddActionOnClose(window, BasePythonReplEvaluator.CloseReplWindow);
            }

            return window;
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:29,代码来源:ExecuteInReplCommand.cs


示例20: ImageAdornmentManager

        internal ImageAdornmentManager(IServiceProvider serviceProvider, IWpfTextView view, IEditorFormatMap editorFormatMap)
        {
            View = view;
            this.serviceProvider = serviceProvider;
            AdornmentLayer = View.GetAdornmentLayer(ImageAdornmentLayerName);

            ImagesAdornmentsRepository = new ImageAdornmentRepositoryService(view.TextBuffer);

            // Create the highlight line adornment
            HighlightLineAdornment = new HighlightLineAdornment(view, editorFormatMap);
            AdornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, HighlightLineAdornment,
                                        HighlightLineAdornment.VisualElement, null);

            // Create the preview image adornment
            PreviewImageAdornment = new PreviewImageAdornment();
            AdornmentLayer.AddAdornment(AdornmentPositioningBehavior.OwnerControlled, null, this,
                                        PreviewImageAdornment.VisualElement, null);

            // Attach to the view events
            View.LayoutChanged += OnLayoutChanged;
            View.TextBuffer.Changed += OnBufferChanged;
            View.Closed += OnViewClosed;

            // Load and initialize the image adornments repository
            ImagesAdornmentsRepository.Load();
            ImagesAdornmentsRepository.Images.ToList().ForEach(image => InitializeImageAdornment(image));
        }
开发者ID:dangilkerson,项目名称:ApprovalTestsVS2010,代码行数:27,代码来源:ImageAdornmentManager.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IServiceRegistry类代码示例发布时间:2022-05-24
下一篇:
C# IServiceManagement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap