示例#1
0
 public static IRequestConfiguration WithJsonBody(this IRequestConfiguration configuration, object body, Formatting formatting, JsonSerializerSettings settings)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     return(configuration
            .ConfigureRequest(r => r.ContentType = ContentType)
            .WithBodyBuilder(new JsonBodyBuilder(body, formatting, settings)));
 }
示例#2
0
 public static IRequestConfiguration WithJsonBody(this IRequestConfiguration configuration, object body)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     return(configuration
            .ConfigureRequest(r => r.ContentType = ContentType)
            .WithBodyBuilder(new JsonBodyBuilder(body)));
 }
示例#3
0
        public static IRequestConfiguration WithUrlEncodedBody(this IRequestConfiguration configuration, object parameters)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            NameValueCollection collection = NameValueCollectionExtensions.CreateNameValueCollection(parameters);

            return(configuration
                   .ConfigureRequest(r => r.ContentType = ContentType)
                   .WithBodyBuilder(new UrlEncodedBodyBuilder(collection)));
        }
示例#4
0
 public static IRequestConfiguration WithUrlEncodedBody(this IRequestConfiguration configuration, Action <IUrlEncodedBodyBuilder> formBuilder)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (formBuilder == null)
     {
         throw new ArgumentNullException("formBuilder");
     }
     return(configuration
            .ConfigureRequest(r => r.ContentType = ContentType)
            .WithBodyBuilder(new UrlEncodedBodyBuilder(formBuilder)));
 }
示例#5
0
 public static IRequestConfiguration WithUrlEncodedBody(this IRequestConfiguration configuration, NameValueCollection collection)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (collection == null)
     {
         throw new ArgumentNullException("collection");
     }
     return(configuration
            .ConfigureRequest(r => r.ContentType = ContentType)
            .WithBodyBuilder(new UrlEncodedBodyBuilder(collection)));
 }
示例#6
0
 public static IRequestConfiguration WithMultiPartBody(this IRequestConfiguration configuration, Action <IMultiPartBodyBuilder> multiPartBuilder)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     if (multiPartBuilder == null)
     {
         throw new ArgumentNullException("multiPartBuilder");
     }
     return(configuration
            .ConfigureRequest(r => r.ContentType = "multipart/form-data; boundary=" + MultiPartBodyBuilder.Boundary)
            .WithBodyBuilder(new MultiPartBodyBuilder(multiPartBuilder)));
 }