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


C# IServiceProvider.?.GetService方法代码示例

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


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

示例1: KeyRingProvider

 public KeyRingProvider(IKeyManager keyManager, KeyManagementOptions keyManagementOptions, IServiceProvider services)
 {
     _keyManagementOptions = new KeyManagementOptions(keyManagementOptions); // clone so new instance is immutable
     _keyManager = keyManager;
     _cacheableKeyRingProvider = services?.GetService<ICacheableKeyRingProvider>() ?? this;
     _logger = services?.GetLogger<KeyRingProvider>();
     _defaultKeyResolver = services?.GetService<IDefaultKeyResolver>()
         ?? new DefaultKeyResolver(_keyManagementOptions.KeyPropagationWindow, _keyManagementOptions.MaxServerClockSkew, services);
 }
开发者ID:yonglehou,项目名称:DataProtection,代码行数:9,代码来源:KeyRingProvider.cs

示例2: GetCheckpointerSettings

        public ICheckpointerSettings GetCheckpointerSettings(IProviderConfiguration providerConfig, IServiceProvider serviceProvider)
        {
            // if no checkpointer settings type is provided, use EventHubCheckpointerSettings and get populate settings from providerConfig
            if (CheckpointerSettingsType == null)
            {
                CheckpointerSettingsType = typeof(EventHubCheckpointerSettings);
            }

            var checkpointerSettings = (ICheckpointerSettings)(serviceProvider?.GetService(CheckpointerSettingsType) ?? Activator.CreateInstance(CheckpointerSettingsType));
            if (checkpointerSettings == null)
            {
                throw new ArgumentOutOfRangeException(nameof(providerConfig), "CheckpointerSettingsType not valid.");
            }

            // if settings is an EventHubCheckpointerSettings class, populate settings from providerConfig
            var settings = checkpointerSettings as EventHubCheckpointerSettings;
            if (settings != null)
            {
                settings.PopulateFromProviderConfig(providerConfig);
            }

            return checkpointerSettings;
        }
开发者ID:MikeHardman,项目名称:orleans,代码行数:23,代码来源:EventHubStreamProviderConfig.cs

示例3: EncryptedXmlDecryptor

 /// <summary>
 /// Creates a new instance of an <see cref="EncryptedXmlDecryptor"/>.
 /// </summary>
 /// <param name="services">An optional <see cref="IServiceProvider"/> to provide ancillary services.</param>
 public EncryptedXmlDecryptor(IServiceProvider services)
 {
     _decryptor = services?.GetService<IInternalEncryptedXmlDecryptor>() ?? this;
 }
开发者ID:hishamco,项目名称:DataProtection,代码行数:8,代码来源:EncryptedXmlDecryptor.cs

示例4: CertificateXmlEncryptor

 internal CertificateXmlEncryptor(IServiceProvider services)
 {
     _encryptor = services?.GetService<IInternalCertificateXmlEncryptor>() ?? this;
     _logger = services.GetLogger<CertificateXmlEncryptor>();
 }
开发者ID:hishamco,项目名称:DataProtection,代码行数:5,代码来源:CertificateXmlEncryptor.cs

示例5: GetEventHubSettings

        /// <summary>
        /// Aquire configured IEventHubSettings class
        /// </summary>
        /// <param name="providerConfig"></param>
        /// <param name="serviceProvider"></param>
        /// <returns></returns>
        public IEventHubSettings GetEventHubSettings(IProviderConfiguration providerConfig, IServiceProvider serviceProvider)
        {
            // if no event hub settings type is provided, use EventHubSettings and get populate settings from providerConfig
            if (EventHubSettingsType == null)
            {
                EventHubSettingsType = typeof(EventHubSettings);
            }

            var hubSettings = (IEventHubSettings)(serviceProvider?.GetService(EventHubSettingsType) ?? Activator.CreateInstance(EventHubSettingsType));
            if (hubSettings == null)
            {
                throw new ArgumentOutOfRangeException(nameof(providerConfig), "EventHubSettingsType not valid.");
            }

            // if settings is an EventHubSettings class, populate settings from providerConfig
            var settings = hubSettings as EventHubSettings;
            settings?.PopulateFromProviderConfig(providerConfig);

            return hubSettings;
        }
开发者ID:osjimenez,项目名称:orleans,代码行数:26,代码来源:EventHubStreamProviderSettings.cs

示例6: GetUIThread

 private static UIThreadBase GetUIThread(IServiceProvider provider) {
     var uiThread = (UIThreadBase)provider?.GetService(typeof(UIThreadBase));
     return uiThread ?? new NoOpUIThread();
 }
开发者ID:jsschultz,项目名称:PTVS,代码行数:4,代码来源:OutputWindowRedirector.cs

示例7: OpenAt

        internal static void OpenAt(IServiceProvider site, IPythonInterpreterFactory interpreter, Type extension = null) {
            var wnd = (site?.GetService(typeof(IPythonToolsToolWindowService)) as IPythonToolsToolWindowService)
                ?.GetWindowPane(typeof(InterpreterListToolWindow), true) as InterpreterListToolWindow;
            var envs = wnd?.Content as ToolWindow;
            if (envs == null) {
                Debug.Fail("Failed to get environment list window");
                return;
            }

            ErrorHandler.ThrowOnFailure((wnd.Frame as IVsWindowFrame)?.Show() ?? 0);

            if (extension == null) {
                SelectEnv(envs, interpreter, 3);
            } else {
                SelectEnvAndExt(envs, interpreter, extension, 3);
            }
        }
开发者ID:jsschultz,项目名称:PTVS,代码行数:17,代码来源:InterpreterListToolWindow.cs

示例8: CreateInstance

        /// <summary>
        ///     This method will search internal tables within TypeDescriptor for 
        ///     a TypeDescriptionProvider object that is associated with the given 
        ///     data type.  If it finds one, it will delegate the call to that object.  
        /// </summary>
        public static object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
        {
            if (objectType == null)
            {
                throw new ArgumentNullException(nameof(objectType));
            }

            if (argTypes != null)
            {
                if (args == null)
                {
                    throw new ArgumentNullException(nameof(args));
                }

                if (argTypes.Length != args.Length)
                {
                    throw new ArgumentException(SR.TypeDescriptorArgsCountMismatch);
                }
            }

            object instance = null;

            // See if the provider wants to offer a TypeDescriptionProvider to delegate to.  This allows
            // a caller to have complete control over all object instantiation.
            TypeDescriptionProvider p = provider?.GetService(typeof(TypeDescriptionProvider)) as TypeDescriptionProvider;
            if (p != null)
            {
                instance = p.CreateInstance(provider, objectType, argTypes, args);
            }

            return instance ?? NodeFor(objectType).CreateInstance(provider, objectType, argTypes, args);
        }
开发者ID:chcosta,项目名称:corefx,代码行数:37,代码来源:TypeDescriptor.cs


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