Exemplo n.º 1
0
 private static void DoLoadNewsFeed(string methodName, Dictionary <string, string> paramDict, Action <BackendResult <NewsFeedData, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <NewsFeedData>(methodName, paramDict, callback, (Func <string, NewsFeedData>)(jsonStr =>
     {
         List <int> resultCounts1;
         jsonStr = VKRequestsDispatcher.GetArrayCountsAndRemove(jsonStr, "photos", out resultCounts1);
         List <int> resultCounts2;
         jsonStr = VKRequestsDispatcher.GetArrayCountsAndRemove(jsonStr, "photo_tags", out resultCounts2);
         NewsFeedData response = JsonConvert.DeserializeObject <GenericRoot <NewsFeedData> >(jsonStr).response;
         NewsFeedType result1;
         if (Enum.TryParse <NewsFeedType>(response.feed_type, out result1))
         {
             response.FeedType = new NewsFeedType?(result1);
         }
         VKList <UserNotification> notifications = response.notifications;
         if ((notifications != null ? notifications.items :  null) != null)
         {
             foreach (UserNotification userNotification in response.notifications.items)
             {
                 UserNotificationType result2;
                 if (Enum.TryParse <UserNotificationType>(userNotification.type, out result2))
                 {
                     userNotification.Type = result2;
                 }
             }
         }
         return(response);
     }), false, true, new CancellationToken?(), null);
 }
Exemplo n.º 2
0
        public void GetWallForManyUsers(List <WallService.WallRequestData> requestData, Action <BackendResult <List <WallData>, ResultCode> > callback)
        {
            StringBuilder stringBuilder1 = new StringBuilder().AppendFormat("var users =  API.users.get({{\"user_ids\":\"{0}\", \"fields\":\"wall_default\"}});", new object[1]
            {
                requestData.Select <WallService.WallRequestData, long>((Func <WallService.WallRequestData, long>)(r => r.UserId)).ToList <long>().GetCommaSeparated()
            }).Append(Environment.NewLine);

            for (int index = 0; index < requestData.Count; ++index)
            {
                WallService.WallRequestData wallRequestData = requestData[index];
                stringBuilder1 = stringBuilder1.AppendFormat("var wall{3} = API.wall.get({{\"owner_id\":{0}, \"offset\":{1}, \"count\":{2}, \"extended\":1, \"filter\":users[{3}].wall_default}});", wallRequestData.UserId, wallRequestData.Offset, wallRequestData.Count, index).AppendFormat(Environment.NewLine);
            }
            StringBuilder stringBuilder2 = stringBuilder1.Append("return {");

            for (int index = 0; index < requestData.Count; ++index)
            {
                if (index > 0)
                {
                    stringBuilder2 = stringBuilder2.Append(", ");
                }
                stringBuilder2 = stringBuilder2.AppendFormat("\"Wall{0}\":wall{0} ", new object[1]
                {
                    index
                });
            }
            VKRequestsDispatcher.Execute <List <WallData> >(stringBuilder2.Append("};").ToString(), callback, (Func <string, List <WallData> >)(jsonStr =>
            {
                List <WallData> wallDataList1 = new List <WallData>();
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "wall", false);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "profiles", false);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "groups", false);
                for (int index = 0; index < requestData.Count; ++index)
                {
                    jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Wall" + index, true);
                }
                List <int> resultCounts;
                jsonStr = VKRequestsDispatcher.GetArrayCountsAndRemove(jsonStr, "wall", out resultCounts);
                GenericRoot <Dictionary <string, WallData> > genericRoot = JsonConvert.DeserializeObject <GenericRoot <Dictionary <string, WallData> > >(jsonStr);
                List <WallData> wallDataList2 = new List <WallData>();
                foreach (KeyValuePair <string, WallData> keyValuePair in genericRoot.response)
                {
                    wallDataList2.Add(keyValuePair.Value);
                }
                return(wallDataList2);
            }), false, true, new CancellationToken?());
        }