/// <summary>
        /// 获取依赖注入实例
        /// </summary>
        /// <param name="httpContext"></param>
        private void InitServices(HttpContext httpContext)
        {
            var serviceProveider = httpContext.RequestServices;  // Controller中,当前请求作用域内注册的Service

            _authentication = serviceProveider.GetRequiredService <AbstractAuthentication>();
            _memoryCache    = serviceProveider.GetRequiredService <IMemoryCache>();
            _userManager    = serviceProveider.GetRequiredService <UserManager <ApplicationUser> >();
        }
        public OperationBlock(SdkConfig config, Content content)
        {
            Transaction = config.Transaction;

            if (!String.IsNullOrWhiteSpace(config.SessionId))
            {
                Authentication = new SessionAuthentication(config);
            }
            else if (
                !String.IsNullOrWhiteSpace(config.CompanyId) &&
                !String.IsNullOrWhiteSpace(config.UserId) &&
                !String.IsNullOrWhiteSpace(config.UserPassword)
                )
            {
                Authentication = new LoginAuthentication(config);
            }
            else
            {
                throw new ArgumentException("Required CompanyId, UserId, and UserPassword, or SessionId, not supplied in params");
            }

            Content = content;
        }
示例#3
0
 public UserInfoManager(AbstractAuthentication authentication
                        , IHttpContextAccessor httpContextAccessor)
 {
     _authentication      = authentication;
     _httpContextAccessor = httpContextAccessor;
 }