Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpParameter"/> class.
 /// </summary>
 /// <param name="name">The name of the parameter.</param>
 /// <param name="value">The value of the parameter.</param>
 /// <param name="parameterType">The type of the parameter.</param>
 /// <param name="contentType">The content-type of the parameter.</param>
 protected HttpParameter(HttpParameterType parameterType, string name, HttpParameterValue value, string contentType)
 {
   this.ParameterType = parameterType;
   this.Name = name;
   this.Value = value;
   this.ContentType = contentType;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpParameter"/> class.
 /// </summary>
 /// <param name="name">The name of the parameter.</param>
 /// <param name="value">The value of the parameter.</param>
 /// <param name="parameterType">The type of the parameter.</param>
 /// <param name="contentType">The content-type of the parameter.</param>
 protected HttpParameter(HttpParameterType parameterType, string name, HttpParameterValue value, string contentType)
 {
     this.ParameterType = parameterType;
     this.Name          = name;
     this.Value         = value;
     this.ContentType   = contentType;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds a <see cref="HttpParameter"/> to the end of the collection.
 /// </summary>
 /// <param name="parameterName">The name of the parameter.</param>
 /// <param name="parameterValue">The value of the parameter.</param>
 /// <param name="parameterType">The type of the parameter.</param>
 public void Add(HttpParameterType parameterType, string parameterName, string parameterValue)
 {
     if (parameterType == HttpParameterType.Form)
     {
         this.Add(new HttpFormParameter(parameterName, parameterValue));
     }
     else if (parameterType == HttpParameterType.Url)
     {
         this.Add(new HttpUrlParameter(parameterName, parameterValue));
     }
     else if (parameterType == HttpParameterType.RequestBody)
     {
         this.Add(new HttpRequestBody(this.Encoding.GetBytes(parameterValue)));
     }
     else if (parameterType == HttpParameterType.File)
     {
         this.Add(new HttpFile(parameterName, "file.dat", this.Encoding.GetBytes(parameterValue)));
     }
     else
     {
         this.Add(new HttpParameter(parameterName, parameterValue));
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a string of query parameters with a specified separator and encoding parameters.
        /// </summary>
        /// <param name="separator">The separator of query parameters.</param>
        /// <param name="encodingType">The type of the encoder.</param>
        /// <param name="parametersType">The types of parameters to be used.</param>
        public string ToStringParameters(string separator, UrlEncodingType encodingType, HttpParameterType parametersType)
        {
            string result = "";

            foreach (var itm in this)
            {
                // ignore files and request body
                if (itm.GetType() == typeof(HttpFile) || itm.GetType() == typeof(HttpRequestBody))
                {
                    continue;
                }
                // ignore common parameters, if specified in the rule
                // note: !parametersType.HasFlag(HttpParameterType.Unformed) is not supported in the .net framework 3.5
                if (itm.GetType() != typeof(HttpUrlParameter) && (parametersType & HttpParameterType.Unformed) != HttpParameterType.Unformed)
                {
                    continue;
                }
                if (result.Length > 0)
                {
                    result += "&";
                }
                result += String.Format("{0}={1}", itm.Name, itm.Value.ToEncodedString(encodingType));
            }
            return(result);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Returns a string of query parameters with a specified encoding parameters.
 /// </summary>
 public string ToStringParameters(string separator, HttpParameterType parametersTypee)
 {
     return(this.ToStringParameters(separator, UrlEncodingType.Default, parametersTypee));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns a string of query parameters with a specified encoding parameters.
 /// </summary>
 public string ToStringParameters(UrlEncodingType encodingType, HttpParameterType parametersType)
 {
     return(this.ToStringParameters("&", encodingType, parametersType));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Returns a string of query parameters with a specified encoding parameters.
 /// </summary>
 public string ToStringParameters(HttpParameterType parametersType)
 {
     return(this.ToStringParameters("&", UrlEncodingType.Default, parametersType));
 }