Example #1
0
        public IDictionary <long, FriendStatus> AreFriends([NotNull] IEnumerable <long> uids)
        {
            if (uids == null)
            {
                throw new ArgumentNullException("uids");
            }

            var parameters = new VkParameters {
                { "uids", uids }
            };

            VkResponseArray ids = _vk.Call("friends.areFriends", parameters);

            return(ids.ToDictionary(r => (long)r["uid"], r => (FriendStatus)r["friend_status"]));
        }
Example #2
0
        [ApiVersion("5.44")]         // TODO IDictionary<long, FriendStatus>
        public IDictionary <long, ReadOnlyCollection <long> > GetRequests(FriendsGetRequestsParams @params)
        {
            VkResponseArray response = _vk.Call("friends.getRequests", @params);

            // Проверка возвращается ли список объектов или идентификаторы пользователя
            if (response.Count > 0 && response[0].ContainsKey("user_id"))
            {
                var dicResult = new Dictionary <long, ReadOnlyCollection <long> >();
                foreach (var item in response)
                {
                    VkResponseArray mutual = item["mutual"];
                    dicResult.Add(item["user_id"], mutual.ToReadOnlyCollectionOf(x => (long)x));
                }
                return(dicResult);
            }

            return(response.ToDictionary(x => (long)x, x => new ReadOnlyCollection <long>(new List <long>())));
        }