protected override void CreatePubNubResponse(object deSerializedResult, RequestState requestState)
        {
            PNGetAllUUIDMetadataResult pnUserResultList = new PNGetAllUUIDMetadataResult();

            pnUserResultList.Data = new List <PNUUIDMetadataResult>();
            PNStatus pnStatus = new PNStatus();

            try{
                Dictionary <string, object> dictionary = deSerializedResult as Dictionary <string, object>;

                if (dictionary != null)
                {
                    object objData;
                    dictionary.TryGetValue("data", out objData);
                    if (objData != null)
                    {
                        object[] objArr = objData as object[];
                        foreach (object data in objArr)
                        {
                            Dictionary <string, object> objDataDict = data as Dictionary <string, object>;
                            if (objDataDict != null)
                            {
                                PNUUIDMetadataResult pnUserResult = ObjectsHelpers.ExtractUUIDMetadata(objDataDict);
                                pnUserResultList.Data.Add(pnUserResult);
                            }
                            else
                            {
                                pnStatus = base.CreateErrorResponseFromException(new PubNubException("objDataDict null"), requestState, PNStatusCategory.PNUnknownCategory);
                            }
                        }
                    }
                    else
                    {
                        pnStatus = base.CreateErrorResponseFromException(new PubNubException("objData null"), requestState, PNStatusCategory.PNUnknownCategory);
                    }
                    int    totalCount;
                    string next;
                    string prev;
                    ObjectsHelpers.ExtractPagingParamsAndTotalCount(dictionary, "totalCount", "next", "prev", out totalCount, out next, out prev);
                    pnUserResultList.Next       = next;
                    pnUserResultList.Prev       = prev;
                    pnUserResultList.TotalCount = totalCount;
                }
            } catch (Exception ex) {
                pnUserResultList = null;
                pnStatus         = base.CreateErrorResponseFromException(ex, requestState, PNStatusCategory.PNUnknownCategory);
            }
            Callback(pnUserResultList, pnStatus);
        }
Beispiel #2
0
        public static PNUUIDMetadataResult ExtractUUIDMetadata(Dictionary <string, object> objDataDict)
        {
            PNUUIDMetadataResult pnUserResult = new PNUUIDMetadataResult();

            pnUserResult.ID         = Utility.ReadMessageFromResponseDictionary(objDataDict, "id");
            pnUserResult.Name       = Utility.ReadMessageFromResponseDictionary(objDataDict, "name");
            pnUserResult.ExternalID = Utility.ReadMessageFromResponseDictionary(objDataDict, "externalId");
            pnUserResult.ProfileURL = Utility.ReadMessageFromResponseDictionary(objDataDict, "profileUrl");
            pnUserResult.Email      = Utility.ReadMessageFromResponseDictionary(objDataDict, "email");
            pnUserResult.Updated    = Utility.ReadMessageFromResponseDictionary(objDataDict, "updated");
            pnUserResult.ETag       = Utility.ReadMessageFromResponseDictionary(objDataDict, "eTag");
            pnUserResult.Custom     = Utility.ReadDictionaryFromResponseDictionary(objDataDict, "custom");

            return(pnUserResult);
        }