Пример #1
0
        /// <summary>
        /// 解析指定类型的服务实例
        /// </summary>
        public T GetService <T>()
        {
            _services.CheckNotNull(nameof(_services));
            _provider.CheckNotNull(nameof(_provider));

            IScopedServiceResolver scopedResolver = _provider.GetService <IScopedServiceResolver>();

            if (scopedResolver != null && scopedResolver.ResolveEnabled)
            {
                return(scopedResolver.GetService <T>());
            }
            return(_provider.GetService <T>());
        }
 /// <summary>
 /// 初始化一个<see cref="OsharpAuthorizationServerProvider"/>类型的新实例
 /// </summary>
 public OsharpAuthorizationServerProvider(IServiceProvider serviceProvider)
 {
     serviceProvider.CheckNotNull("serviceProvider");
     _clientValidator = serviceProvider.GetService<IClientValidator>();
     if (_clientValidator == null)
     {
         throw new InvalidOperationException(Resources.ClientValidatorIsNull);
     }
     _passwordValidator = serviceProvider.GetService<IPasswordValidator>();
     if (_passwordValidator == null)
     {
         throw new InvalidOperationException(Resources.PasswordValidatorIsNull);
     }
 }
Пример #3
0
 /// <summary>
 /// 初始化一个<see cref="OsharpAuthorizationServerProvider"/>类型的新实例
 /// </summary>
 public OsharpAuthorizationServerProvider(IServiceProvider serviceProvider)
 {
     serviceProvider.CheckNotNull("serviceProvider");
     _ioAuthClientValidator = serviceProvider.GetService <IOAuthClientValidator>();
     if (_ioAuthClientValidator == null)
     {
         throw new InvalidOperationException(Resources.ClientValidatorIsNull);
     }
     _passwordValidator = serviceProvider.GetService <IPasswordValidator>();
     if (_passwordValidator == null)
     {
         throw new InvalidOperationException(Resources.PasswordValidatorIsNull);
     }
 }
Пример #4
0
 /// <summary>
 /// 设置应用程序服务提供者
 /// </summary>
 internal void SetApplicationServiceProvider(IServiceProvider provider)
 {
     provider.CheckNotNull(nameof(provider));
     _provider = provider;
 }