示例#1
0
        public T ProcessActionResult(string responseJson, Enum theAction)
        {
            JsonData friendJson = JsonMapper.ToObject(responseJson);

            switch ((FriendshipAction)theAction)
            {
            case FriendshipAction.Create:
            case FriendshipAction.Destroy:
                var user = new User(friendJson);
                return(user.ItemCast(default(T)));

            case FriendshipAction.Update:
                var friendship = new Friendship(friendJson.GetValue <JsonData>("relationship"));
                return(friendship.ItemCast(default(T)));

            default:
                throw new InvalidOperationException("Unknown Action.");
            }
        }
示例#2
0
        public T?ProcessActionResult(string responseJson, Enum theAction)
        {
            JsonElement friendJson = JsonDocument.Parse(responseJson).RootElement;

            switch ((FriendshipAction)theAction)
            {
            case FriendshipAction.Create:
            case FriendshipAction.Destroy:
                var user = new User(friendJson);
                return(user.ItemCast(default(T)));

            case FriendshipAction.Update:
                var friendship = new Friendship(friendJson.GetProperty("relationship"));
                return(friendship.ItemCast(default(T)));

            default:
                throw new InvalidOperationException("Unknown Action.");
            }
        }