Class DefaultConnection
The default implementation for the connection interface. Supports Pooling, and is thread safe.
Inherited Members
Namespace: Worldline.Connect.Sdk.Communication
Assembly: Worldline.Connect.Sdk.dll
Syntax
public class DefaultConnection : IPooledConnection, IConnection, IDisposable, ILoggingCapable, IObfuscationCapable
Constructors
DefaultConnection(Func<HttpClient>, Action)
Creates a new DefaultConnection
with a custom provider for HttpClient instances to use for each request.
This could be based on IHttpClientFactor
or something completely different.
This constructor will dispose provided HttpClient
instances after each request.
Declaration
public DefaultConnection(Func<HttpClient> httpClientProvider, Action disposeAction = null)
Parameters
Type | Name | Description |
---|---|---|
Func<HttpClient> | httpClientProvider | The custom provider for |
Action | disposeAction | An optional action to call from the |
See Also
DefaultConnection(Func<HttpClient>, Action<HttpClient>, Action)
Creates a new DefaultConnection
with a custom provider for HttpClient instances to use for each request.
This could be based on IHttpClientFactor
or something completely different.
Declaration
public DefaultConnection(Func<HttpClient> httpClientProvider, Action<HttpClient> postRequestAction, Action disposeAction = null)
Parameters
Type | Name | Description |
---|---|---|
Func<HttpClient> | httpClientProvider | The custom provider for |
Action<HttpClient> | postRequestAction | A mandatory action to call after each request, e.g. to dispose provided |
Action | disposeAction | An optional action to call from the |
DefaultConnection(TimeSpan?, int, Proxy, HttpClientHandler)
Declaration
public DefaultConnection(TimeSpan? socketTimeout, int maxConnections = 2, Proxy proxy = null, HttpClientHandler httpClientHandler = null)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan? | socketTimeout | |
int | maxConnections | |
Proxy | proxy | |
HttpClientHandler | httpClientHandler |
Properties
BodyObfuscator
The current non-null body obfuscator to use.
Declaration
public BodyObfuscator BodyObfuscator { set; }
Property Value
Type | Description |
---|---|
BodyObfuscator |
HeaderObfuscator
The current non-null header obfuscator to use.
Declaration
public HeaderObfuscator HeaderObfuscator { set; }
Property Value
Type | Description |
---|---|
HeaderObfuscator |
Methods
CloseExpiredConnections()
Closes all expired HTTP connections.
Declaration
public void CloseExpiredConnections()
CloseIdleConnections(TimeSpan)
Closes all HTTP connections that have been idle for the specified time. This should also include all expired HTTP connections. CloseExpiredConnections()
Declaration
public void CloseIdleConnections(TimeSpan timespan)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | timespan | Idle time. |
Delete<T>(Uri, IEnumerable<IRequestHeader>, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T>)
Send a DELETE request to the Worldline Global Collect platform.
Declaration
public Task<T> Delete<T>(Uri uri, IEnumerable<IRequestHeader> requestHeaders, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> responseHandler)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The URI to call, including any necessary query parameters. |
IEnumerable<IRequestHeader> | requestHeaders | An optional list of request headers. |
Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> | responseHandler | A callback that handles the stream from the response |
Returns
Type | Description |
---|---|
Task<T> | Returns the object that was returned from the callback |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
CommunicationException | when an exception occurred communicating with the Worldline Global Collect platform |
DisableLogging()
Turns off logging.
Declaration
public void DisableLogging()
Dispose()
Declaration
public void Dispose()
EnableLogging(ICommunicatorLogger)
Turns on logging using the given communicator logger.
Declaration
public void EnableLogging(ICommunicatorLogger communicatorLogger)
Parameters
Type | Name | Description |
---|---|---|
ICommunicatorLogger | communicatorLogger | The given communicator logger. |
Exceptions
Type | Condition |
---|---|
ArgumentException | If the given communicator logger is |
Get<T>(Uri, IEnumerable<IRequestHeader>, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T>)
Send a GET request to the Worldline Global Collect platform.
Declaration
public Task<T> Get<T>(Uri uri, IEnumerable<IRequestHeader> requestHeaders, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> responseHandler)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The URI to call, including any necessary query parameters. |
IEnumerable<IRequestHeader> | requestHeaders | An optional list of request headers. |
Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> | responseHandler | A callback that handles the stream from the response |
Returns
Type | Description |
---|---|
Task<T> | Returns the object that was returned from the callback |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
CommunicationException | when an exception occurred communicating with the Worldline Global Collect platform |
Post<T>(Uri, IEnumerable<IRequestHeader>, string, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T>)
Send a POST request to the Worldline Global Collect platform.
Declaration
public Task<T> Post<T>(Uri uri, IEnumerable<IRequestHeader> requestHeaders, string body, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> responseHandler)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The URI to call, including any necessary query parameters. |
IEnumerable<IRequestHeader> | requestHeaders | An optional list of request headers. |
string | body | The optional body to send. |
Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> | responseHandler | A callback that handles the stream from the response |
Returns
Type | Description |
---|---|
Task<T> | Returns the object that was returned from the callback |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
CommunicationException | when an exception occurred communicating with the Worldline Global Collect platform |
Post<T>(Uri, IEnumerable<IRequestHeader>, MultipartFormDataObject, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T>)
Send a multipart/form-data POST request to the Worldline Global Collect platform.
The content type of the request will be be part of the given request header list. If the connection creates its own content type, it should be multipart.getContentType(). Otherwise, authentication failures will occur.
Declaration
public Task<T> Post<T>(Uri uri, IEnumerable<IRequestHeader> requestHeaders, MultipartFormDataObject multipart, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> responseHandler)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The URI to call, including any necessary query parameters. |
IEnumerable<IRequestHeader> | requestHeaders | An optional list of request headers. |
MultipartFormDataObject | multipart | The multipart/form-data request to send. |
Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> | responseHandler | A callback that handles the stream from the response |
Returns
Type | Description |
---|---|
Task<T> | Returns the object that was returned from the callback |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
CommunicationException | when an exception occurred communicating with the Worldline Global Collect platform |
Put<T>(Uri, IEnumerable<IRequestHeader>, string, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T>)
Send a PUT request to the Worldline Global Collect platform.
Declaration
public Task<T> Put<T>(Uri uri, IEnumerable<IRequestHeader> requestHeaders, string body, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> responseHandler)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The URI to call, including any necessary query parameters. |
IEnumerable<IRequestHeader> | requestHeaders | An optional list of request headers. |
string | body | The optional body to send. |
Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> | responseHandler | A callback that handles the stream from the response |
Returns
Type | Description |
---|---|
Task<T> | Returns the object that was returned from the callback |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
CommunicationException | when an exception occurred communicating with the Worldline Global Collect platform |
Put<T>(Uri, IEnumerable<IRequestHeader>, MultipartFormDataObject, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T>)
Send a multipart/form-data PUT request to the Worldline Global Collect platform.
The content type of the request will be be part of the given request header list. If the connection creates its own content type, it should be multipart.getContentType(). Otherwise, authentication failures will occur.
Declaration
public Task<T> Put<T>(Uri uri, IEnumerable<IRequestHeader> requestHeaders, MultipartFormDataObject multipart, Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> responseHandler)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The URI to call, including any necessary query parameters. |
IEnumerable<IRequestHeader> | requestHeaders | An optional list of request headers. |
MultipartFormDataObject | multipart | The multipart/form-data request to send. |
Func<HttpStatusCode, Stream, IEnumerable<IResponseHeader>, T> | responseHandler | A callback that handles the stream from the response |
Returns
Type | Description |
---|---|
Task<T> | Returns the object that was returned from the callback |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
CommunicationException | when an exception occurred communicating with the Worldline Global Collect platform |