HttpContentDeserializerCollection Class
- Namespace
- Kampute.HttpClient
- Assembly
- Kampute.HttpClient.dll
Definition
public sealed class HttpContentDeserializerCollection : ICollection<IHttpContentDeserializer>, IReadOnlyCollection<IHttpContentDeserializer>- Inheritance
- object
- HttpContentDeserializerCollection
- Implements
Remarks
Constructors
HttpContentDeserializerCollection()
public HttpContentDeserializerCollection()Properties
Count
public int Count { get; }Property Value
- int
- The number of IHttpContentDeserializer instances contained in the collection.
Methods
Add(IHttpContentDeserializer)
public void Add(IHttpContentDeserializer deserializer)Parameters
deserializerIHttpContentDeserializer- The IHttpContentDeserializer to add.
Exceptions
- ArgumentNullException
- Thrown if
deserializerisnull. - ArgumentException
- Thrown if an instance of the same type already exists in the collection.
Clear()
public void Clear()Contains(IHttpContentDeserializer)
public bool Contains(IHttpContentDeserializer deserializer)Parameters
deserializerIHttpContentDeserializer- The IHttpContentDeserializer to locate in the collection.
Returns
Find<T>()
public T Find<T>()
where T : IHttpContentDeserializerType Parameters
T- The type of the deserializer to find.
Returns
- T
- The instance of IHttpContentDeserializer of the specified type, or
nullif not found.
GetAcceptableMediaTypes(Type)
public IEnumerable<string> GetAcceptableMediaTypes(Type modelType)Parameters
modelTypeType- The type of the model for which to retrieve supported media types.
Returns
- IEnumerable<string>
- An enumerable of strings that represent the media types supported for deserializing the specified model type.
Remarks
This method determines the supported media types for deserializing content based on the given model type.
If the model type is null, this method returns a collection containing only "*/*", signifying that all media types are acceptable.
For non-null model types, the method aggregates media types supported by the registered deserializers for that specific model type.
GetAcceptableMediaTypes(Type, Type)
public IEnumerable<string> GetAcceptableMediaTypes(Type modelType, Type errorType)Parameters
modelTypeType- The type of the model for which to retrieve supported media types.
errorTypeType- The type of the error for which to retrieve supported media types.
Returns
- IEnumerable<string>
- An enumerable of strings representing the supported media types for the specified types.
Remarks
This method determines the supported media types for deserializing content based on the given modelType and errorType.
If both modelType and errorType are provided, it aggregates and returns the media types that support deserializing either type.
If only modelType is provided and errorType is null, the result includes media types exclusively supporting the modelType.
Conversely, if modelType is null and errorType is provided, the result includes media types supporting the errorType, augmented by "*/*" to indicate that all media types are acceptable for the modelType.
If both parameters are null, the method defaults to returning "*/*" only, implying general acceptability of any media type.
GetDeserializerFor(string, Type)
public IHttpContentDeserializer GetDeserializerFor(string mediaType, Type modelType)Parameters
Returns
- IHttpContentDeserializer
- An instance of IHttpContentDeserializer that can deserialize the specified media type and model type, or
nullif none is found.
GetEnumerator()
public IEnumerator<IHttpContentDeserializer> GetEnumerator()Returns
Remove(IHttpContentDeserializer)
public bool Remove(IHttpContentDeserializer deserializer)Parameters
deserializerIHttpContentDeserializer- The IHttpContentDeserializer to remove from the collection.
Returns
Explicit Interface Implementations
ICollection<IHttpContentDeserializer>.IsReadOnly
false for this implementation.bool ICollection<IHttpContentDeserializer>.IsReadOnly { get; }Property Value
ICollection<IHttpContentDeserializer>.CopyTo(IHttpContentDeserializer[], int)
void ICollection<IHttpContentDeserializer>.CopyTo(IHttpContentDeserializer[] array, int arrayIndex)Parameters
arrayIHttpContentDeserializer[]- 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()
IEnumerator IEnumerable.GetEnumerator()Returns
- IEnumerator
- An IEnumerator object that can be used to iterate through the collection.
