HttpErrorHandlerCollection Class

Namespace
Kampute.HttpClient
Assembly
  • Kampute.HttpClient.dll

Definition

Represents the error handlers of an HttpRestClient, in the order they were added.
public sealed class HttpErrorHandlerCollection : ICollection<IHttpErrorHandler>
Inheritance
  • object
  • HttpErrorHandlerCollection
Implements

Remarks

The client asks the handlers that GetHandlersFor(HttpStatusCode) returns for the status code of an error response, in order, until one of them retries. A handler can be added only once.

Properties

Count

Gets the number of handlers in the collection.
public int Count { get; }

Property Value

int
The number of handlers in the collection.

Methods

Add(IHttpErrorHandler)

Adds an IHttpErrorHandler to the collection.
public void Add(IHttpErrorHandler errorHandler)

Parameters

errorHandler IHttpErrorHandler
The IHttpErrorHandler to add.

Exceptions

ArgumentNullException
Thrown if errorHandler is null.
ArgumentException
Thrown if errorHandler is already in the collection.

Clear()

Removes all items from the collection.
public void Clear()

Contains(IHttpErrorHandler)

Determines whether the collection contains a specific IHttpErrorHandler.
public bool Contains(IHttpErrorHandler errorHandler)

Parameters

errorHandler IHttpErrorHandler
The IHttpErrorHandler to locate in the collection.

Returns

bool
true if errorHandler is found in the collection; otherwise, false.

GetEnumerator()

Returns an enumerator that iterates through the collection.
public IEnumerator<IHttpErrorHandler> GetEnumerator()

Returns

IEnumerator<IHttpErrorHandler>
A IEnumerator<T> for IHttpErrorHandler.

GetHandlersFor(HttpStatusCode)

Returns the handlers that can handle the specified status code, in the order they were added.
public IEnumerable<IHttpErrorHandler> GetHandlersFor(HttpStatusCode statusCode)

Parameters

statusCode HttpStatusCode
The status code of the error response.

Returns

IEnumerable<IHttpErrorHandler>
The handlers whose IHttpErrorHandler.CanHandle(HttpStatusCode) accepts statusCode.

Remove(IHttpErrorHandler)

Removes a handler from the collection.
public bool Remove(IHttpErrorHandler errorHandler)

Parameters

errorHandler IHttpErrorHandler
The IHttpErrorHandler to remove from the collection.

Returns

bool
true if errorHandler was successfully removed from the collection; otherwise, false.

Explicit Interface Implementations

ICollection<IHttpErrorHandler>.IsReadOnly

Gets a value indicating whether the collection is read-only.
bool ICollection<IHttpErrorHandler>.IsReadOnly { get; }

Property Value

bool
Always false.

ICollection<IHttpErrorHandler>.CopyTo(IHttpErrorHandler[], int)

Copies the elements of the collection to an array, starting at a particular array index.
void ICollection<IHttpErrorHandler>.CopyTo(IHttpErrorHandler[] array, int arrayIndex)

Parameters

array IHttpErrorHandler[]
The one-dimensional array that is the destination of the elements copied from the collection. The array must have zero-based indexing.
arrayIndex int
The zero-based index in array at which copying begins.

IEnumerable.GetEnumerator()

Returns an enumerator that iterates through a collection.
IEnumerator IEnumerable.GetEnumerator()

Returns

IEnumerator
An IEnumerator object that can be used to iterate through the collection.