Esempio n. 1
0
        /// <summary>
        /// Makes a GET request to the service for a resource returned as an array of bytes.
        /// </summary>
        /// <param name="uri">The request URI.</param>
        /// <param name="securityToken">A security token used by the server to validate the client, or null if making the call anonymously.</param>
        /// <param name="parameters">Optional parameters to pass as part of the query string for the URI.</param>
        /// <returns>The result of the GET request.</returns>
        protected Task <ServiceResult <byte[]> > GetResourceAsync(string uri, string securityToken, params RequestParameter[] parameters)
        {
            this.ThrowIfDisposed();

            string             fullUri = uri + HttpServiceClient.BuildQuery(parameters);
            HttpRequestMessage request = HttpServiceClient.CreateGetRequest(fullUri, securityToken);

            return(this.MakeServiceRequestWithBinaryResponse(request));
        }
Esempio n. 2
0
        /// <summary>
        /// Makes a GET request to the service with an expected Json response.
        /// </summary>
        /// <param name="uri">The request URI.</param>
        /// <param name="securityToken">A security token used by the server to validate the client, or null if making the call anonymously.</param>
        /// <param name="serializerSettings">Serializer settings used when deserializing the response content from the server.</param>
        /// <param name="convertFromDTO">Converts a received DTO into the expected response type.</param>
        /// <param name="parameters">Optional parameters to pass as part of the query string for the URI.</param>
        /// <returns>The result of the GET request.</returns>
        protected Task <ServiceResult <TResponse> > GetFromJsonAsync <TResponse, TDTO>(
            string uri,
            string securityToken,
            JsonSerializerSettings serializerSettings,
            Func <TDTO, TResponse> convertFromDTO,
            params RequestParameter[] parameters)
        {
            this.ThrowIfDisposed();

            string             fullUri = uri + HttpServiceClient.BuildQuery(parameters);
            HttpRequestMessage request = HttpServiceClient.CreateGetRequest(fullUri, securityToken);

            return(this.MakeServiceRequestWithJsonResponse <TResponse, TDTO>(request, serializerSettings, convertFromDTO));
        }