internal Task <ListedResponse <T> > AccessJsonParameteredApiArrayAsync <T>(string url, object parameters, string[] jsonMap, CancellationToken cancellationToken, string jsonPath = "")
 {
     return(this.AccessJsonParameteredApiArrayAsyncImpl <T>(url, InternalUtils.ResolveObject(parameters), jsonMap, cancellationToken, jsonPath));
 }
示例#2
0
 internal void AccessApiNoResponse(string url, Expression <Func <string, object> >[] parameters)
 {
     this.AccessApiNoResponseImpl(url, InternalUtils.ExpressionsToDictionary(parameters));
 }
示例#3
0
 internal void AccessApiNoResponseImpl(string url, IEnumerable <KeyValuePair <string, object> > parameters)
 {
     this.SendRequestImpl(MethodType.Post, InternalUtils.GetUrl(url), parameters).Close();
 }
示例#4
0
 internal ListedResponse <T> AccessApiArray <T>(MethodType type, string url, Expression <Func <string, object> >[] parameters, string jsonPath = "")
 {
     return(this.AccessApiArrayImpl <T>(type, url, InternalUtils.ExpressionsToDictionary(parameters), jsonPath));
 }
示例#5
0
 internal DictionaryResponse <TKey, TValue> AccessApiDictionary <TKey, TValue>(MethodType type, string url, Expression <Func <string, object> >[] parameters, string jsonPath = "")
 {
     return(this.AccessApiDictionaryImpl <TKey, TValue>(type, url, InternalUtils.ExpressionsToDictionary(parameters), jsonPath));
 }
示例#6
0
 internal ListedResponse <T> AccessJsonParameteredApiArray <T>(string url, object parameters, string[] jsonMap, string jsonPath = "")
 {
     return(this.AccessJsonParameteredApiArrayImpl <T>(url, InternalUtils.ResolveObject(parameters), jsonMap, jsonPath));
 }
示例#7
0
 /// <summary>
 /// Sends a request to the specified url with the specified parameters.
 /// </summary>
 /// <param name="type">The type of HTTP request.</param>
 /// <param name="url">The URL.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>A stream.</returns>
 public HttpWebResponse SendRequest(MethodType type, string url, object parameters)
 {
     return(this.SendRequestImpl(type, url, InternalUtils.ResolveObject(parameters), this.ConnectionOptions));
 }
 internal Task <ListedResponse <T> > AccessApiArrayAsync <T>(MethodType type, string url, object parameters, CancellationToken cancellationToken, string jsonPath = "")
 {
     return(this.AccessApiArrayAsyncImpl <T>(type, url, InternalUtils.ResolveObject(parameters), cancellationToken, jsonPath));
 }
 internal Task <DictionaryResponse <TKey, TValue> > AccessApiDictionaryAsync <TKey, TValue>(MethodType type, string url, Expression <Func <string, object> >[] parameters, string jsonPath = "")
 {
     return(this.AccessApiDictionaryAsyncImpl <TKey, TValue>(type, url, InternalUtils.ExpressionsToDictionary(parameters), CancellationToken.None, jsonPath));
 }
示例#10
0
 /// <summary>
 /// Sends a request to the specified url with the specified parameters as an asynchronous operation.
 /// </summary>
 /// <param name="type">The type of HTTP request.</param>
 /// <param name="url">The URL.</param>
 /// <param name="parameters">The parameters.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>
 /// <para>The task object representing the asynchronous operation.</para>
 /// <para>The Result property on the task object returns a <see cref="AsyncResponse"/>.</para>
 /// </returns>
 public Task <AsyncResponse> SendRequestAsync(MethodType type, string url, object parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(this.SendRequestAsyncImpl(type, url, InternalUtils.ResolveObject(parameters), this.ConnectionOptions, cancellationToken));
 }
示例#11
0
        private Task <AsyncResponse> SendRequestAsyncImpl(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, ConnectionOptions options, CancellationToken cancellationToken, IProgress <UploadProgressInfo> progress = null)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                var tcs = new TaskCompletionSource <AsyncResponse>();
                tcs.SetCanceled();
                return(tcs.Task);
            }

            var prmArray = InternalUtils.FormatParameters(parameters);
            var uri      = CreateUri(type, url, prmArray);

            Task <AsyncResponse> task;

            switch (type)
            {
            case MethodType.Get:
                task = Request.HttpGetAsync(
                    uri,
                    CreateAuthorizationHeader(type, uri, null),
                    options,
                    cancellationToken
                    );
                break;

            case MethodType.Post:
                task = ContainsBinaryData(prmArray)
                        ? Request.HttpPostWithMultipartFormDataAsync(
                    uri,
                    prmArray,
                    CreateAuthorizationHeader(type, uri, null),
                    options,
                    cancellationToken,
                    progress
                    )
                        : Request.HttpPostAsync(
                    uri,
                    prmArray,
                    CreateAuthorizationHeader(type, uri, prmArray),
                    options,
                    cancellationToken,
                    progress
                    );
                break;

            case MethodType.Put:
                task = Request.HttpPutAsync(
                    uri,
                    prmArray,
                    CreateAuthorizationHeader(type, uri, prmArray),
                    options,
                    cancellationToken,
                    progress
                    );
                break;

            case MethodType.Delete:
                task = Request.HttpDeleteAsync(
                    uri,
                    CreateAuthorizationHeader(type, uri, null),
                    options,
                    cancellationToken
                    );
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type));
            }

            return(task.ResponseCallback(cancellationToken));
        }
示例#12
0
 /// <summary>
 /// Sends a request to the specified url with the specified parameters as an asynchronous operation.
 /// </summary>
 /// <param name="type">The type of HTTP request.</param>
 /// <param name="url">The URL.</param>
 /// <param name="parameters">The parameters.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>
 /// <para>The task object representing the asynchronous operation.</para>
 /// <para>The Result property on the task object returns a <see cref="AsyncResponse"/>.</para>
 /// </returns>
 public Task <AsyncResponse> SendRequestAsync(MethodType type, string url, CancellationToken cancellationToken = default(CancellationToken), params Expression <Func <string, object> >[] parameters)
 {
     return(this.SendRequestAsyncImpl(type, url, InternalUtils.ExpressionsToDictionary(parameters), this.ConnectionOptions, cancellationToken));
 }
示例#13
0
 internal Task <AsyncResponse> SendJsonRequestAsync(string fullUrl, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap, CancellationToken cancellationToken)
 {
     return(this.PostContentAsync(fullUrl, JsonContentType, InternalUtils.MapDictToJson(parameters, jsonMap), cancellationToken));
 }
示例#14
0
 internal Task <ListedResponse <T> > AccessJsonParameteredApiArrayAsyncImpl <T>(string url, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap, CancellationToken cancellationToken, string jsonPath)
 {
     return(this.SendJsonRequestAsync(InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, jsonMap, cancellationToken)
            .ReadResponse(s => new ListedResponse <T>(CoreBase.ConvertArray <T>(s, jsonPath)), cancellationToken));
 }
示例#15
0
 internal T AccessJsonParameteredApiImpl <T>(string url, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap, string jsonPath)
 {
     using (var response = this.SendJsonRequest(InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, jsonMap))
         return(InternalUtils.ReadResponse <T>(response, jsonPath));
 }
示例#16
0
 internal Task <DictionaryResponse <TKey, TValue> > AccessApiDictionaryAsync <TKey, TValue>(MethodType type, string url, object parameters, CancellationToken cancellationToken, string jsonPath = "")
 {
     return(this.AccessApiDictionaryAsyncImpl <TKey, TValue>(type, url, InternalUtils.ResolveObject(parameters), cancellationToken, jsonPath));
 }
示例#17
0
 internal ListedResponse <T> AccessJsonParameteredApiArray <T>(string url, Expression <Func <string, object> >[] parameters, string[] jsonMap, string jsonPath = "")
 {
     return(this.AccessJsonParameteredApiArrayImpl <T>(url, InternalUtils.ExpressionsToDictionary(parameters), jsonMap, jsonPath));
 }
示例#18
0
 internal Task <DictionaryResponse <TKey, TValue> > AccessApiDictionaryAsyncImpl <TKey, TValue>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, CancellationToken cancellationToken, string jsonPath)
 {
     return(this.SendRequestAsyncImpl(type, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters, cancellationToken)
            .ReadResponse(s => new DictionaryResponse <TKey, TValue>(CoreBase.Convert <Dictionary <TKey, TValue> >(s, jsonPath)), cancellationToken));
 }
示例#19
0
 internal HttpWebResponse SendJsonRequest(string fullUrl, IEnumerable <KeyValuePair <string, object> > parameters, string[] jsonMap)
 {
     return(this.PostContent(fullUrl, JsonContentType, InternalUtils.MapDictToJson(parameters, jsonMap)));
 }
示例#20
0
 internal Task AccessApiNoResponseAsync(MethodType type, string url, Expression <Func <string, object> >[] parameters)
 {
     return(this.AccessApiNoResponseAsyncImpl(type, url, InternalUtils.ExpressionsToDictionary(parameters), CancellationToken.None));
 }
示例#21
0
 internal T AccessApi <T, TV>(MethodType type, string url, TV parameters, string jsonPath = "")
 {
     return(this.AccessApiImpl <T>(type, url, InternalUtils.ResolveObject(parameters), jsonPath));
 }
示例#22
0
 internal T AccessApiImpl <T>(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters, string jsonPath)
 {
     using (var response = this.SendRequestImpl(type, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters))
         return(InternalUtils.ReadResponse <T>(response, jsonPath));
 }
示例#23
0
 internal ListedResponse <T> AccessApiArray <T, TV>(MethodType type, string url, TV parameters, string jsonPath = "")
 {
     return(this.AccessApiArrayImpl <T>(type, url, InternalUtils.ResolveObject(parameters), jsonPath));
 }
示例#24
0
 internal void AccessApiNoResponse(MethodType type, string url, object parameters)
 {
     this.AccessApiNoResponseImpl(type, url, InternalUtils.ResolveObject(parameters));
 }
示例#25
0
 internal DictionaryResponse <TKey, TValue> AccessApiDictionary <TKey, TValue, TV>(MethodType type, string url, TV parameters, string jsonPath = "")
 {
     return(this.AccessApiDictionaryImpl <TKey, TValue>(type, url, InternalUtils.ResolveObject(parameters), jsonPath));
 }
示例#26
0
 internal void AccessApiNoResponseImpl(MethodType type, string url, IEnumerable <KeyValuePair <string, object> > parameters)
 {
     this.SendRequestImpl(type, InternalUtils.GetUrl(this.ConnectionOptions, url), parameters).Close();
 }
示例#27
0
 internal void AccessApiNoResponse <TV>(string url, TV parameters)
 {
     this.AccessApiNoResponseImpl(url, InternalUtils.ResolveObject(parameters));
 }
示例#28
0
 internal T AccessJsonParameteredApi <T>(string url, object parameters, string[] jsonMap, string jsonPath = "")
 {
     return(this.AccessJsonParameteredApiImpl <T>(url, InternalUtils.ResolveObject(parameters), jsonMap, jsonPath));
 }
示例#29
0
 /// <summary>
 /// Sends a request to the specified url with the specified parameters.
 /// </summary>
 /// <param name="type">The type of HTTP request.</param>
 /// <param name="url">The URL.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>A stream.</returns>
 public HttpWebResponse SendRequest(MethodType type, string url, params Expression <Func <string, object> >[] parameters)
 {
     return(this.SendRequestImpl(type, url, InternalUtils.ExpressionsToDictionary(parameters), this.ConnectionOptions));
 }
示例#30
0
 internal Task <ListedResponse <T> > AccessJsonParameteredApiArrayAsync <T>(string url, Expression <Func <string, object> >[] parameters, string[] jsonMap, string jsonPath = "")
 {
     return(this.AccessJsonParameteredApiArrayAsyncImpl <T>(url, InternalUtils.ExpressionsToDictionary(parameters), jsonMap, CancellationToken.None, jsonPath));
 }