コード例 #1
0
        internal bool InitRoleEntity()
        {
            if (_IsFailure)
            {
                return(false);
            }
            if (RoleEntity != null)
            {
                return(true);
            }
            RouteData   routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));
            EntityRoute route     = routeData.Route as EntityRoute;

            if (route == null)
            {
                _IsFailure = true;
                return(false);
            }
            RoleEntity = Resolve(route.UserType, Identity.Name);
            if (RoleEntity == null)
            {
                _IsFailure = true;
                return(false);
            }
            return(true);
        }
コード例 #2
0
        public async Task SaveAsync(IRoleEntity roleEntity)
        {
            if (!(roleEntity is RoleEntity role))
            {
                role = (RoleEntity) await GetAsync(roleEntity.RowKey) ?? new RoleEntity();

                role.ETag      = roleEntity.ETag;
                role.Name      = roleEntity.Name;
                role.KeyValues = roleEntity.KeyValues;
            }
            role.PartitionKey = RoleEntity.GeneratePartitionKey();
            role.RowKey       = roleEntity.RowKey;
            await _tableStorage.InsertOrMergeAsync(role);
        }
コード例 #3
0
ファイル: ComBoostPrincipal.cs プロジェクト: liny4cn/ComBoost
 internal bool InitRoleEntity()
 {
     if (_IsFailure)
         return false;
     if (RoleEntity != null)
         return true;
     RouteData routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));
     EntityRoute route = routeData.Route as EntityRoute;
     if (route == null)
     {
         _IsFailure = true;
         return false;
     }
     RoleEntity = Resolve(route.UserType, Identity.Name);
     if (RoleEntity == null)
     {
         _IsFailure = true;
         return false;
     }
     return true;
 }
コード例 #4
0
        public async Task SaveAsync(IRoleEntity roleEntity)
        {
            if (roleEntity is RoleEntity role)
            {
                role.PartitionKey = RoleEntity.GeneratePartitionKey();
                role.RowKey       = roleEntity.RoleId;
            }
            else
            {
                var pk = RoleEntity.GeneratePartitionKey();
                var rk = RoleEntity.GenerateRowKey(roleEntity.RoleId);
                role = await _tableStorage.GetDataAsync(pk, rk)
                       ?? new RoleEntity
                {
                    PartitionKey = pk, RowKey = rk
                };

                role.RoleId    = roleEntity.RoleId;
                role.Name      = roleEntity.Name;
                role.KeyValues = roleEntity.KeyValues;
            }

            await _tableStorage.InsertOrMergeAsync(role);
        }