C# Класс PortableRest.RestRequest

Specifies the parameters for the HTTP request that will be executed against a given resource.
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
CombineUriParts string
GetContentType string
GetRequestBody string
Transform void

Открытые методы

Метод Описание
AddFileParameter ( string key, System.Stream fileStream, string filename ) : void

AddHeader ( string key, object value ) : void

Adds an Header to only this specific request.

Use this if you have an authentication token that times out on a regular basis.

AddParameter ( object value ) : void

Adds an unnamed parameter to the body of the request.

Use this method if you're not using UrlFormEncoded requests.

AddParameter ( string key, object value, ParameterEncoding encoding = ParameterEncoding.UriEncoded ) : void

Adds a parameter to the body of the request, to be encoded with the specified format.

Note: If the ContentType is anything other than UrlFormEncoded, only the first Parameter will be serialzed to the request body.

AddQueryString ( string key, object value ) : void

Appends a key/value pair to the end of the existing QueryString in a URI.

AddQueryString ( string key, string value ) : void

Appends a key/value pair to the end of the existing QueryString in a URI.

AddUrlSegment ( string key, string value ) : void

Replaces tokenized segments of the URL with a desired value.

GetResourceUri ( string baseUrl ) : Uri

RestRequest ( ) : System

Creates a new RestRequest instance, assuming the request will be an HTTP GET.

RestRequest ( string resource ) : System

Creates a new RestRequest instance for a given Resource.

RestRequest ( string resource, ContentTypes contentType ) : System

Creates a new RestRequest instance for a given Resource and Method, specifying whether or not to ignore the root object in the response.

RestRequest ( string resource, HttpMethod method ) : System

Creates a new RestRequest instance for a given Resource and Method.

RestRequest ( string resource, HttpMethod method, ContentTypes contentType ) : System

Creates a new RestRequest instance for a given Resource and Method, specifying whether or not to ignore the root object in the response.

RestRequest ( string resource, HttpMethod method, bool ignoreRoot ) : System

Creates a new RestRequest instance for a given Resource and Method, specifying whether or not to ignore the root object in the response.

Приватные методы

Метод Описание
CombineUriParts ( ) : string

Combines URI parts, taking care of trailing and starting slashes. See http://stackoverflow.com/a/6704287

GetContentType ( ) : string

GetRequestBody ( ) : string

Transform ( XNode node, Type type ) : void

Technique from http://blogs.msdn.com/b/ericwhite/archive/2009/07/20/a-tutorial-in-the-recursive-approach-to-pure-functional-transformations-of-xml.aspx

Описание методов

AddFileParameter() публичный Метод

public AddFileParameter ( string key, System.Stream fileStream, string filename ) : void
key string
fileStream System.Stream
filename string
Результат void

AddHeader() публичный Метод

Adds an Header to only this specific request.
Use this if you have an authentication token that times out on a regular basis.
public AddHeader ( string key, object value ) : void
key string
value object
Результат void

AddParameter() публичный Метод

Adds an unnamed parameter to the body of the request.
Use this method if you're not using UrlFormEncoded requests.
public AddParameter ( object value ) : void
value object
Результат void

AddParameter() публичный Метод

Adds a parameter to the body of the request, to be encoded with the specified format.
Note: If the ContentType is anything other than UrlFormEncoded, only the first Parameter will be serialzed to the request body.
public AddParameter ( string key, object value, ParameterEncoding encoding = ParameterEncoding.UriEncoded ) : void
key string
value object /// For ByteArrays or Base64, this needs to be a Stream, or an exception will be thrown when the request is executed. ///
encoding ParameterEncoding
Результат void

AddQueryString() публичный Метод

Appends a key/value pair to the end of the existing QueryString in a URI.
public AddQueryString ( string key, object value ) : void
key string The string key to append to the QueryString.
value object The value to append to the QueryString (we will call .ToString() for you).
Результат void

AddQueryString() публичный Метод

Appends a key/value pair to the end of the existing QueryString in a URI.
public AddQueryString ( string key, string value ) : void
key string The string key to append to the QueryString.
value string The string value to append to the QueryString.
Результат void

AddUrlSegment() публичный Метод

Replaces tokenized segments of the URL with a desired value.
public AddUrlSegment ( string key, string value ) : void
key string
value string
Результат void

GetResourceUri() публичный Метод

public GetResourceUri ( string baseUrl ) : Uri
baseUrl string
Результат System.Uri

RestRequest() публичный Метод

Creates a new RestRequest instance, assuming the request will be an HTTP GET.
public RestRequest ( ) : System
Результат System

RestRequest() публичный Метод

Creates a new RestRequest instance for a given Resource.
public RestRequest ( string resource ) : System
resource string The specific resource to access.
Результат System

RestRequest() публичный Метод

Creates a new RestRequest instance for a given Resource and Method, specifying whether or not to ignore the root object in the response.
public RestRequest ( string resource, ContentTypes contentType ) : System
resource string The URL format string of the resource to request.
contentType ContentTypes The Content Type for the request.
Результат System

RestRequest() публичный Метод

Creates a new RestRequest instance for a given Resource and Method.
public RestRequest ( string resource, HttpMethod method ) : System
resource string The specific resource to access.
method HttpMethod The HTTP method to use for the request.
Результат System

RestRequest() публичный Метод

Creates a new RestRequest instance for a given Resource and Method, specifying whether or not to ignore the root object in the response.
public RestRequest ( string resource, HttpMethod method, ContentTypes contentType ) : System
resource string The URL format string of the resource to request.
method HttpMethod The for the request.
contentType ContentTypes The Content Type for the request.
Результат System

RestRequest() публичный Метод

Creates a new RestRequest instance for a given Resource and Method, specifying whether or not to ignore the root object in the response.
public RestRequest ( string resource, HttpMethod method, bool ignoreRoot ) : System
resource string The URL format string of the resource to request.
method HttpMethod The for the request.
ignoreRoot bool Whether or not the root object from the response should be ignored.
Результат System