示例#1
0
 protected T AddEntity <T>(DSClient client, int userId, string token, ModelEntity entity) where T : ModelEntity
 {
     if (entity is Application)
     {
         return(client.AddApplication(userId, token, entity as Application) as T);
     }
     else if (entity is Role)
     {
         return(client.AddRole(userId, token, entity as Role) as T);
     }
     else if (entity is Command)
     {
         return(client.AddCommand(userId, token, entity as Command) as T);
     }
     else if (entity is RoleCommand)
     {
         return(client.AddRoleCommand(userId, token, entity as RoleCommand) as T);
     }
     else if (entity is RoleCommandView)
     {
         return(client.AddRoleCommand(userId, token, (entity as RoleCommandView).GetRoleCommand()) as T);
     }
     else if (entity is Image)
     {
         client.AddImage(userId, token, entity as Image);
         return(entity as T);
     }
     else if (entity is UserIdList)
     {
         return(client.AddUserIdList(userId, token, entity as UserIdList) as T);
     }
     else if (entity is Room)
     {
         return(client.AddRoom(userId, token, entity as Room) as T);
     }
     else if (entity is RoomGroup)
     {
         return(client.AddRoomGroup(userId, token, entity as RoomGroup) as T);
     }
     else if (entity is Gift)
     {
         return(client.AddGift(userId, token, entity as Gift) as T);
     }
     else if (entity is GiftGroup)
     {
         return(client.AddGiftGroup(userId, token, entity as GiftGroup) as T);
     }
     else if (entity is User)
     {
         return(client.AddUser(userId, token, entity as User) as T);
     }
     else if (entity is UserApplicationInfo)
     {
         return(client.AddUserInfo(userId, token, entity as UserApplicationInfo) as T);
     }
     else if (entity is BlockList)
     {
         return(client.AddBlockList(userId, token, entity as BlockList) as T);
     }
     else if (entity is BlockType)
     {
         return(client.AddBlockType(userId, token, entity as BlockType) as T);
     }
     else if (entity is ExchangeRate)
     {
         return(client.AddExchangeRate(userId, token, entity as ExchangeRate) as T);
     }
     else if (entity is RoomRole)
     {
         return(client.AddRoomRole(userId, token, entity as RoomRole) as T);
     }
     else if (entity is ExchangeHistory)
     {
         return(client.AddExchangeHistory(userId, token, entity as ExchangeHistory) as T);
     }
     else if (entity is RoomConfig)
     {
         return(client.AddRoomConfig(userId, token, entity as RoomConfig) as T);
     }
     return(null);
 }