Exemplo n.º 1
0
        private async Task <PNResult <PNGetAllUuidMetadataResult> > GetUuidMetadataList(PNPageObject page, int limit, bool includeCount, bool includeCustom, string filter, List <string> sort, Dictionary <string, object> externalQueryParam)
        {
            PNResult <PNGetAllUuidMetadataResult> ret = new PNResult <PNGetAllUuidMetadataResult>();

            PNPageObject internalPage;

            if (page == null)
            {
                internalPage = new PNPageObject();
            }
            else
            {
                internalPage = page;
            }

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null) ? PubnubInstance.InstanceId : "");
            Uri request = urlBuilder.BuildGetAllUuidMetadataRequest("GET", "", internalPage.Next, internalPage.Prev, limit, includeCount, includeCustom, filter, sort, externalQueryParam);

            RequestState <PNGetAllUuidMetadataResult> requestState = new RequestState <PNGetAllUuidMetadataResult>();

            requestState.ResponseType      = PNOperationType.PNGetAllUuidMetadataOperation;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            requestState.UsePostMethod = false;
            Tuple <string, PNStatus> JsonAndStatusTuple = await UrlProcessRequest(request, requestState, false).ConfigureAwait(false);

            ret.Status = JsonAndStatusTuple.Item2;
            string json = JsonAndStatusTuple.Item1;

            if (!string.IsNullOrEmpty(json))
            {
                List <object>              resultList      = ProcessJsonResponse(requestState, json);
                ResponseBuilder            responseBuilder = new ResponseBuilder(config, jsonLibrary, pubnubLog);
                PNGetAllUuidMetadataResult responseResult  = responseBuilder.JsonToObject <PNGetAllUuidMetadataResult>(resultList, true);
                if (responseResult != null)
                {
                    ret.Result = responseResult;
                }
            }

            return(ret);
        }
Exemplo n.º 2
0
        private void GetUuidMetadataList(PNPageObject page, int limit, bool includeCount, bool includeCustom, string filter, List <string> sort, Dictionary <string, object> externalQueryParam, PNCallback <PNGetAllUuidMetadataResult> callback)
        {
            if (callback == null)
            {
                throw new ArgumentException("Missing callback");
            }
            PNPageObject internalPage;

            if (page == null)
            {
                internalPage = new PNPageObject();
            }
            else
            {
                internalPage = page;
            }

            IUrlRequestBuilder urlBuilder = new UrlRequestBuilder(config, jsonLibrary, unit, pubnubLog, pubnubTelemetryMgr, (PubnubInstance != null) ? PubnubInstance.InstanceId : "");
            Uri request = urlBuilder.BuildGetAllUuidMetadataRequest("GET", "", internalPage.Next, internalPage.Prev, limit, includeCount, includeCustom, filter, sort, externalQueryParam);

            RequestState <PNGetAllUuidMetadataResult> requestState = new RequestState <PNGetAllUuidMetadataResult>();

            requestState.ResponseType      = PNOperationType.PNGetAllUuidMetadataOperation;
            requestState.PubnubCallback    = callback;
            requestState.Reconnect         = false;
            requestState.EndPointOperation = this;

            requestState.UsePostMethod = false;
            UrlProcessRequest(request, requestState, false).ContinueWith(r =>
            {
                string json = r.Result.Item1;
                if (!string.IsNullOrEmpty(json))
                {
                    List <object> result = ProcessJsonResponse(requestState, json);
                    ProcessResponseCallbacks(result, requestState);
                }
            }, TaskContinuationOptions.ExecuteSynchronously).Wait();
        }