public static PNMemberships ExtractMemberships(Dictionary <string, object> objDataDict) { PNMemberships pnMemberships = new PNMemberships(); pnMemberships.ID = Utility.ReadMessageFromResponseDictionary(objDataDict, "id"); pnMemberships.Space = ObjectsHelpers.ExtractSpace(Utility.ReadDictionaryFromResponseDictionary(objDataDict, "space")); pnMemberships.Created = Utility.ReadMessageFromResponseDictionary(objDataDict, "created"); pnMemberships.Updated = Utility.ReadMessageFromResponseDictionary(objDataDict, "updated"); pnMemberships.ETag = Utility.ReadMessageFromResponseDictionary(objDataDict, "eTag"); pnMemberships.Custom = Utility.ReadDictionaryFromResponseDictionary(objDataDict, "custom"); return(pnMemberships); }
protected override void CreatePubNubResponse(object deSerializedResult, RequestState requestState) { PNMembershipsResult pnManageMembershipsResult = new PNMembershipsResult(); pnManageMembershipsResult.Data = new List <PNMemberships>(); 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) { PNMemberships pnMemberships = ObjectsHelpers.ExtractMemberships(objDataDict); pnManageMembershipsResult.Data.Add(pnMemberships); } 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); pnManageMembershipsResult.Next = next; pnManageMembershipsResult.Prev = prev; pnManageMembershipsResult.TotalCount = totalCount; } } catch (Exception ex) { pnManageMembershipsResult = null; pnStatus = base.CreateErrorResponseFromException(ex, requestState, PNStatusCategory.PNUnknownCategory); } Callback(pnManageMembershipsResult, pnStatus); }