HttpErrorHandlerCollection Class
- Namespace
- Kampute.HttpClient
- Assembly
- Kampute.HttpClient.dll
Definition
Represents a specialized collection of IHttpErrorHandler instances.
public sealed class HttpErrorHandlerCollection : ICollection<IHttpErrorHandler>- Inheritance
- object
- HttpErrorHandlerCollection
- Implements
Remarks
This collection enables the management of IHttpErrorHandler instances for handling HTTP errors, with capabilities such as adding, removing, and querying error handlers based on HTTP status codes.
Constructors
HttpErrorHandlerCollection()
Initializes a new instance of HttpErrorHandlerCollection class.
public HttpErrorHandlerCollection()Properties
Count
Gets the number of IHttpErrorHandler instances contained in the collection.
public int Count { get; }Property Value
- int
- The number of IHttpErrorHandler instances contained in the collection.
Methods
Add(IHttpErrorHandler)
Adds an IHttpErrorHandler to the collection.
public void Add(IHttpErrorHandler errorHandler)Parameters
errorHandlerIHttpErrorHandler- The IHttpErrorHandler to add.
Exceptions
- ArgumentNullException
- Thrown if
errorHandlerisnull. - ArgumentException
- Thrown if
errorHandleris already present in the collection, as duplicates are not allowed.
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
errorHandlerIHttpErrorHandler- The IHttpErrorHandler to locate in the collection.
Returns
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<IHttpErrorHandler> GetEnumerator()Returns
GetHandlersFor(HttpStatusCode)
Retrieves all IHttpErrorHandler instances in the collection that support handling a specific HTTP status code.
public IEnumerable<IHttpErrorHandler> GetHandlersFor(HttpStatusCode statusCode)Parameters
statusCodeHttpStatusCode- The HTTP status code to query.
Returns
- IEnumerable<IHttpErrorHandler>
- An enumerable of IHttpErrorHandler that can handle the specified status code.
Remove(IHttpErrorHandler)
Removes the first occurrence of a specific IHttpErrorHandler from the collection.
public bool Remove(IHttpErrorHandler errorHandler)Parameters
errorHandlerIHttpErrorHandler- The IHttpErrorHandler to remove from the collection.
Returns
Explicit Interface Implementations
ICollection<IHttpErrorHandler>.IsReadOnly
Gets a value indicating whether the collection is read-only. Always returns
false for this implementation.bool ICollection<IHttpErrorHandler>.IsReadOnly { get; }Property Value
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
arrayIHttpErrorHandler[]- The one-dimensional array that is the destination of the elements copied from the collection. The array must have zero-based indexing.
arrayIndexint- 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.
