Table of Contents

Class HeaderDictionaryDecoratorExtensions

Namespace
Cuemon.AspNetCore.Http
Assembly
Cuemon.AspNetCore.dll

Extension methods for the Microsoft.AspNetCore.Http.IHeaderDictionary interface hidden behind the IDecorator<T> interface.

public static class HeaderDictionaryDecoratorExtensions
Inheritance
Object
HeaderDictionaryDecoratorExtensions

Methods

AddOrUpdateHeader(IDecorator<IHeaderDictionary>, String, StringValues, Boolean)

Attempts to add or update an existing element with the provided key and value to the enclosed Microsoft.AspNetCore.Http.IHeaderDictionary of the decorator.

public static void AddOrUpdateHeader(this IDecorator<IHeaderDictionary> decorator, string key, StringValues value, bool useAsciiEncodingConversion = true)

Parameters

decorator IDecorator<IHeaderDictionary>

The IDecorator<T> to extend.

key String

The string to use as the key of the element to add.

value StringValues

The string to use as the value of the element to add.

useAsciiEncodingConversion Boolean

if set to true an ASCII encoding conversion is applied to the value.

Exceptions

System.ArgumentNullException

decorator cannot be null.

AddOrUpdateHeaders(IDecorator<IHeaderDictionary>, HttpResponseHeaders)

Attempts to add or update one or more elements from the provided collection of responseHeaders to the enclosed Microsoft.AspNetCore.Http.IHeaderDictionary of the decorator.

public static void AddOrUpdateHeaders(this IDecorator<IHeaderDictionary> decorator, HttpResponseHeaders responseHeaders)

Parameters

decorator IDecorator<IHeaderDictionary>

The IDecorator<T> to extend.

responseHeaders HttpResponseHeaders

The System.Net.Http.Headers.HttpResponseHeaders to copy.

AddRange(IDecorator<IHeaderDictionary>, IHeaderDictionary, Func<KeyValuePair<String, StringValues>, IHeaderDictionary, Boolean>)

Adds a range of headers to the enclosed Microsoft.AspNetCore.Http.IHeaderDictionary.

public static IHeaderDictionary AddRange(this IDecorator<IHeaderDictionary> decorator, IHeaderDictionary headers, Func<KeyValuePair<string, StringValues>, IHeaderDictionary, bool> predicate = null)

Parameters

decorator IDecorator<IHeaderDictionary>

The IDecorator<T> to extend.

headers IHeaderDictionary

The Microsoft.AspNetCore.Http.IHeaderDictionary to populate.

predicate Func<KeyValuePair<String, StringValues>, IHeaderDictionary, Boolean>

The function delegate that specifies what elements to populate from headers. Default is only non-existing headers.

Returns

IHeaderDictionary

A reference to decorator.Inner.Inner so that additional calls can be chained.

Remarks

When predicate is null, only new headers are added to the enclosed Microsoft.AspNetCore.Http.IHeaderDictionary.

See Also