コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FacebookFeedParser"/> class.
 /// </summary>
 /// <param name="parser">A JSON parser.</param>
 internal FacebookFeedParser(IHttpContentConverter parser, IPhotoUriProvider provider)
 {
     ExceptionHelper.CheckArgumentNull(parser, nameof(parser));
     ExceptionHelper.CheckArgumentNull(provider, nameof(provider));
     this.converter        = parser;
     this.photoUriProvider = provider;
 }
コード例 #2
0
 public WebApiProxy(
     HttpClient client,
     string routePrefix,
     IHttpResponseMessageParser messageParser,
     IHttpContentConverter converter)
     : this(new RoutePrefixedHttpClientWrapper(client, routePrefix), messageParser, converter)
 {
 }
コード例 #3
0
 public Task <HttpResponseMessage> PutModelAsync(
     string relativeRequestUri,
     object content = null,
     IHttpContentConverter converter = null,
     IEnumerable <KeyValuePair <string, IEnumerable <string> > > additionalHeaders = null,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(this.Client.PutModelAsync(this.RoutePrefix, relativeRequestUri, content, converter, additionalHeaders, cancellationToken));
 }
コード例 #4
0
        /// <summary>
        /// Gets the HttpContent representation of the model, safely
        /// </summary>
        /// <param name="model">
        /// The model to convert. If the model is null, then null
        /// is returned.
        /// </param>
        /// <param name="converter">
        /// The converter used to convert the content when the model
        /// is not null
        /// </param>
        /// <returns>
        /// The HttpContent represetnation of the model.  If null is
        /// supplied as the model, the null is returned.
        /// </returns>
        private static HttpContent GetHttpContent(object model, IHttpContentConverter converter)
        {
            if (model == null)
            {
                return(null);
            }

            if (converter == null)
            {
                throw new ArgumentNullException(nameof(converter), "Converter cannot be null when model is not null.");
            }

            return(converter.ToHttpContent(model));
        }
コード例 #5
0
 public AbsoluteRouteWebApiProxy(HttpClient client, IHttpResponseMessageParser messageParser, IHttpContentConverter converter)
 {
     this.Client           = client;
     this.ResponseParser   = messageParser;
     this.ContentConverter = converter;
 }
コード例 #6
0
ファイル: TwitterParser.cs プロジェクト: user9035/webApiNew
 /// <summary>
 /// Initializes a new instance of the <see cref="TwitterParser"/> class.
 /// </summary>
 /// <param name="converter">A Json converter.</param>
 internal TwitterParser(IHttpContentConverter converter)
 {
     ExceptionHelper.CheckArgumentNull(converter, nameof(converter));
     this.converter = converter;
 }
コード例 #7
0
 public WebApiProxy(RoutePrefixedHttpClientWrapper client, IHttpResponseMessageParser messageParser, IHttpContentConverter converter)
 {
     this.Client           = client;
     this.ResponseParser   = messageParser;
     this.ContentConverter = converter;
 }
コード例 #8
0
        public static Task <HttpResponseMessage> PutModelAsync(this HttpClient client, string routePrefix, string relativeRequestUri, object content = null, IHttpContentConverter converter = null, IEnumerable <KeyValuePair <string, IEnumerable <string> > > additionalHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            Uri relativeUri = UriHelpers.RelativeEndpointUri(routePrefix, relativeRequestUri);

            return(client.PutModelAsync(relativeUri, content, converter, additionalHeaders, cancellationToken));
        }
コード例 #9
0
 /// <summary>
 /// Puts content as JSON to an endpoint as an asynchronous operation
 /// </summary>
 /// <param name="client">
 /// The <see cref="HttpClient"/> used to put the JSON content
 /// </param>
 /// <param name="requestUri">
 /// The uri to which to send the request
 /// </param>
 /// <param name="content">
 /// The request content sent to the server
 /// </param>
 /// <param name="converter">
 /// Converter used when serializing the body content
 /// </param>
 /// <param name="additionalHeaders">
 /// Additional request headers to be sent with this request
 /// </param>
 /// <param name="cancellationToken">
 /// A cancellation token that can be used by other objects or threads to receive
 /// notice of cancellation.
 /// </param>
 public static Task <HttpResponseMessage> PutModelAsync(this HttpClient client, Uri requestUri, object content = null, IHttpContentConverter converter = null, IEnumerable <KeyValuePair <string, IEnumerable <string> > > additionalHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(client.PutAsync(requestUri, GetHttpContent(content, converter), additionalHeaders, cancellationToken));
 }