Exemplo n.º 1
0
        /// <inheritdoc/>
        public async Task <T> Put <T>(string relativePath, IEnumerable <IRequestHeader> requestHeaders, AbstractParamRequest requestParameters,
                                      object requestBody, CallContext context)
        {
            IEnumerable <RequestParam> requestParameterList = requestParameters?.ToRequestParameters();
            Uri uri = ToAbsoluteURI(relativePath, requestParameterList);

            requestHeaders = requestHeaders ?? new List <IRequestHeader>();

            string requestJson = null;
            IList <IRequestHeader> requestHeaderList = requestHeaders.ToList();

            if (requestBody != null)
            {
                requestHeaderList.Add(new EntityHeader("Content-Type", "application/json"));
                requestJson = Marshaller.Marshal(requestBody);
            }

            requestHeaders = AddGenericHeaders(HttpMethod.Put, uri, requestHeaderList, context);
            return(await Connection.Put <T>(uri, requestHeaders, requestJson, (status, body, headers) => {
                return ProcessResponse <T>(status, body, headers, relativePath, context);
            }).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public async Task <T> Delete <T>(string relativePath, IEnumerable <IRequestHeader> requestHeaders, AbstractParamRequest requestParameters,
                                         CallContext context)
        {
            IEnumerable <RequestParam> requestParameterList = requestParameters?.ToRequestParameters();
            Uri uri = ToAbsoluteURI(relativePath, requestParameterList);

            requestHeaders = requestHeaders ?? new List <IRequestHeader>();
            requestHeaders = AddGenericHeaders(HttpMethod.Delete, uri, requestHeaders, context);
            return(await Connection.Delete <T>(uri, requestHeaders, (status, body, headers) => {
                return ProcessResponse <T>(status, body, headers, relativePath, context);
            }).ConfigureAwait(false));
        }