HttpHandler
class EosSharp::HttpHandler
: public IHttpHandlerHttp Handler implementation using System.Net.Http.HttpClient.
Summary
private Dictionary< string, object > ResponseCache
public void ClearResponseCache()
Clear cached responses from requests called with Post/GetWithCacheAsync.
public async Task< TResponseData > PostJsonAsync< TResponseData >(string url, object data)
Make post request with data converted to json asynchronously.
public async Task< TResponseData > PostJsonAsync< TResponseData >(string url, object data, CancellationToken cancellationToken)
Make post request with data converted to json asynchronously.
public async Task< TResponseData > PostJsonWithCacheAsync< TResponseData >(string url, object data, bool reload)
Make post request with data converted to json asynchronously. Response is cached based on input (url, data)
public async Task< TResponseData > PostJsonWithCacheAsync< TResponseData >(string url, object data, CancellationToken cancellationToken, bool reload)
Make post request with data converted to json asynchronously. Response is cached based on input (url, data)
public async Task< TResponseData > GetJsonAsync< TResponseData >(string url)
Make get request asynchronously.
public async Task< TResponseData > GetJsonAsync< TResponseData >(string url, CancellationToken cancellationToken)
Make get request asynchronously.
public async Task< Stream > SendAsync(HttpRequestMessage request)
Generic http request sent asynchronously.
public async Task< Stream > SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Generic http request sent asynchronously.
public void UpdateResponseDataCache< TResponseData >(string hashKey, TResponseData responseData)
Upsert response data in the data store.
public string GetRequestHashKey(string url, object data)
Calculate request unique hash key.
public async Task< Stream > BuildSendResponse(HttpResponseMessage response)
Convert response to stream.
public async Task< string > StreamToStringAsync(Stream stream)
Convert stream to a string.
public TData DeserializeJsonFromStream< TData >(Stream stream)
Generic method to convert a stream with json data to any type.
public HttpRequestMessage BuildJsonRequestMessage(string url, object data)
Build json request data from object data.
Members
private Dictionary< string, object > ResponseCache
public void ClearResponseCache()
Clear cached responses from requests called with Post/GetWithCacheAsync.
public async Task< TResponseData > PostJsonAsync< TResponseData >(string url, object data)
Make post request with data converted to json asynchronously.
Parameters
TResponseDataResponse type
Parameters
urlUrl to send the requestdatadata sent in the body
Returns
Response data deserialized to type TResponseData
public async Task< TResponseData > PostJsonAsync< TResponseData >(string url, object data, CancellationToken cancellationToken)
Make post request with data converted to json asynchronously.
Parameters
TResponseDataResponse type
Parameters
urlUrl to send the requestdatadata sent in the bodycancellationTokenNotification that operation should be canceled
Returns
Response data deserialized to type TResponseData
public async Task< TResponseData > PostJsonWithCacheAsync< TResponseData >(string url, object data, bool reload)
Make post request with data converted to json asynchronously. Response is cached based on input (url, data)
Parameters
TResponseDataResponse type
Parameters
urlUrl to send the requestdatadata sent in the bodyreloadignore cached value and make a request caching the result
Returns
Response data deserialized to type TResponseData
public async Task< TResponseData > PostJsonWithCacheAsync< TResponseData >(string url, object data, CancellationToken cancellationToken, bool reload)
Make post request with data converted to json asynchronously. Response is cached based on input (url, data)
Parameters
TResponseDataResponse type
Parameters
urlUrl to send the requestdatadata sent in the bodycancellationTokenNotification that operation should be canceledreloadignore cached value and make a request caching the result
Returns
Response data deserialized to type TResponseData
public async Task< TResponseData > GetJsonAsync< TResponseData >(string url)
Make get request asynchronously.
Parameters
TResponseDataResponse type
Parameters
urlUrl to send the request
Returns
Response data deserialized to type TResponseData
public async Task< TResponseData > GetJsonAsync< TResponseData >(string url, CancellationToken cancellationToken)
Make get request asynchronously.
Parameters
TResponseDataResponse type
Parameters
urlUrl to send the requestcancellationTokenNotification that operation should be canceled
Returns
Response data deserialized to type TResponseData
public async Task< Stream > SendAsync(HttpRequestMessage request)
Generic http request sent asynchronously.
Parameters
requestrequest body
Returns
Stream with response
public async Task< Stream > SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Generic http request sent asynchronously.
Parameters
requestrequest body
///
Parameters
cancellationTokenNotification that operation should be canceled
Returns
Stream with response
public void UpdateResponseDataCache< TResponseData >(string hashKey, TResponseData responseData)
Upsert response data in the data store.
Parameters
TResponseDataresponse data type
Parameters
hashKeydata keyresponseDataresponse data
public string GetRequestHashKey(string url, object data)
Calculate request unique hash key.
Parameters
urlUrl to send the requestdatadata sent in the body
Returns
public async Task< Stream > BuildSendResponse(HttpResponseMessage response)
Convert response to stream.
Parameters
responseresponse object
Returns
Stream with response
public async Task< string > StreamToStringAsync(Stream stream)
Convert stream to a string.
Parameters
stream
Returns
public TData DeserializeJsonFromStream< TData >(Stream stream)
Generic method to convert a stream with json data to any type.
Parameters
TDatatype to convert
Parameters
streamstream with json content
Returns
TData object
public HttpRequestMessage BuildJsonRequestMessage(string url, object data)
Build json request data from object data.
Parameters
urlUrl to send the requestdataobject data
Returns
request message
Last updated