コード例 #1
0
        /// 根据环境生成声明
        /// 具体生成服务通过静态键值对注册,键为生成器名称
        /// 该方法将调用对应名称的生成服务来完成
        public async Task <ClaimsIdentity> Generate(EnvironmentClaimGenerator generator)
        {
            if (!_environmentClaimGeneratorServiceFactories.TryGetValue(generator.Type, out IFactory <IEnvironmentClaimGeneratorService> generatorServiceFactory))
            {
                var fragment = new TextFragment()
                {
                    Code = TextCodes.NotFoundEnvironmentClaimGeneratorServiceByType,
                    DefaultFormatting = "找不到类型为{0}的环境声明生成服务,发生位置:{1}",
                    ReplaceParameters = new List <object>()
                    {
                        generator.Type, $"{this.GetType().FullName}.EnvironmentClaimGeneratorServiceFactories"
                    }
                };

                throw new UtilityException((int)Errors.NotFoundEnvironmentClaimGeneratorServiceByType, fragment);
            }

            return(await generatorServiceFactory.Create().Do());
        }
コード例 #2
0
 public async Task Update(EnvironmentClaimGenerator generator)
 {
     await _environmentClaimGeneratorStore.Update(generator);
 }
コード例 #3
0
 public async Task Delete(EnvironmentClaimGenerator generator)
 {
     await _environmentClaimGeneratorStore.Delete(generator.ID);
 }
コード例 #4
0
 public async Task Add(EnvironmentClaimGenerator generator)
 {
     await _environmentClaimGeneratorStore.Add(generator);
 }