Show / Hide Table of Contents

    Class MessageHeaderCollection

    A modifiable collection of message headers.

    Inheritance
    System.Object
    MessageHeaderCollection
    Implements
    System.Collections.Generic.IReadOnlyList<MessageHeader>
    System.Collections.Generic.IReadOnlyCollection<MessageHeader>
    System.Collections.Generic.IEnumerable<MessageHeader>
    System.Collections.IEnumerable
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Silverback.Messaging.Messages
    Assembly: Silverback.Integration.dll
    Syntax
    public class MessageHeaderCollection : IReadOnlyList<MessageHeader>, IReadOnlyCollection<MessageHeader>, IEnumerable<MessageHeader>, IEnumerable

    Constructors

    | Improve this doc View source

    MessageHeaderCollection(IReadOnlyCollection<MessageHeader>)

    Initializes a new instance of the MessageHeaderCollection class.

    Declaration
    public MessageHeaderCollection(IReadOnlyCollection<MessageHeader> headers)
    Parameters
    Type Name Description
    System.Collections.Generic.IReadOnlyCollection<MessageHeader> headers

    The headers to be added to the collection.

    | Improve this doc View source

    MessageHeaderCollection(Int32)

    Initializes a new instance of the MessageHeaderCollection class.

    Declaration
    public MessageHeaderCollection(int capacity = 0)
    Parameters
    Type Name Description
    System.Int32 capacity

    The initial capacity of the backing System.Collections.Generic.List`1.

    Properties

    | Improve this doc View source

    Count

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this doc View source

    Item[Int32]

    Gets the header at the specified index in the collection.

    Declaration
    public MessageHeader this[int index] { get; }
    Parameters
    Type Name Description
    System.Int32 index

    The index in the collection.

    Property Value
    Type Description
    MessageHeader
    | Improve this doc View source

    Item[String]

    Gets or sets the value of the header with the specified name.

    Declaration
    public string this[string name] { get; set; }
    Parameters
    Type Name Description
    System.String name

    The header name.

    Property Value
    Type Description
    System.String

    Methods

    | Improve this doc View source

    Add(MessageHeader)

    Adds a new header.

    Declaration
    public void Add(MessageHeader header)
    Parameters
    Type Name Description
    MessageHeader header

    The header to be added.

    | Improve this doc View source

    Add(String, Object)

    Adds a new header.

    Declaration
    public void Add(string name, object value)
    Parameters
    Type Name Description
    System.String name

    The header name.

    System.Object value

    The header value.

    | Improve this doc View source

    Add(String, String)

    Adds a new header.

    Declaration
    public void Add(string name, string value)
    Parameters
    Type Name Description
    System.String name

    The header name.

    System.String value

    The header value.

    | Improve this doc View source

    AddIfNotExists(String, String)

    Adds a new header if no header with the same name is already set.

    Declaration
    public void AddIfNotExists(string name, string newValue)
    Parameters
    Type Name Description
    System.String name

    The header name.

    System.String newValue

    The new header value.

    | Improve this doc View source

    AddOrReplace(String, Object)

    Adds a new header or replaces the header with the same name.

    Declaration
    public void AddOrReplace(string name, object newValue)
    Parameters
    Type Name Description
    System.String name

    The header name.

    System.Object newValue

    The new header value.

    | Improve this doc View source

    AddOrReplace(String, String)

    Adds a new header or replaces the header with the same name.

    Declaration
    public void AddOrReplace(string name, string newValue)
    Parameters
    Type Name Description
    System.String name

    The header name.

    System.String newValue

    The new header value.

    | Improve this doc View source

    Contains(String)

    Returns a boolean value indicating whether an header with the specified name has already been added to the collection.

    Declaration
    public bool Contains(string name)
    Parameters
    Type Name Description
    System.String name

    The name to be checked.

    Returns
    Type Description
    System.Boolean

    A boolean value indicating whether the name was found in the existing headers.

    | Improve this doc View source

    GetEnumerator()

    Declaration
    public IEnumerator<MessageHeader> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<MessageHeader>
    | Improve this doc View source

    GetValue(String, Boolean)

    Returns the value of the header with the specified name.

    It will return null if no header with that name is found in the collection.

    Declaration
    public string GetValue(string name, bool throwIfNotFound = false)
    Parameters
    Type Name Description
    System.String name

    The name of the header to be retrieved.

    System.Boolean throwIfNotFound

    A boolean value specifying whether an exception must be thrown if the header with the specified name is not found (or the value cannot be converted to the specified type).

    Returns
    Type Description
    System.String

    The header value converted to the target type, or null if not found.

    | Improve this doc View source

    GetValue(String, Type, Boolean)

    Returns the value of the header with the specified name, casting it to the specified type.

    By default it will return null if no header with that name is found in the collection but this behavior can be changed setting the throwIfNotFound parameter to true.

    Declaration
    public object GetValue(string name, Type targetType, bool throwIfNotFound = false)
    Parameters
    Type Name Description
    System.String name

    The name of the header to be retrieved.

    System.Type targetType

    The type to convert the header value to.

    System.Boolean throwIfNotFound

    A boolean value specifying whether an exception must be thrown if the header with the specified name is not found (or the value cannot be converted to the specified type).

    Returns
    Type Description
    System.Object

    The header value converted to the target type, or null if not found.

    | Improve this doc View source

    GetValue<T>(String, Boolean)

    Returns the value of the header with the specified name, casting it to the specified type T.

    It will return null if no header with that name is found in the collection.

    Declaration
    public T? GetValue<T>(string name, bool throwIfNotFound = false)
        where T : struct
    Parameters
    Type Name Description
    System.String name

    The name of the header to be retrieved.

    System.Boolean throwIfNotFound

    A boolean value specifying whether an exception must be thrown if the header with the specified name is not found (or the value cannot be converted to the specified type).

    Returns
    Type Description
    System.Nullable<T>

    The header value converted to the target type, or null if not found.

    Type Parameters
    Name Description
    T

    The type to convert the header value to.

    | Improve this doc View source

    GetValueOrDefault(String, Type)

    Returns the value of the header with the specified name, casting it to the specified type.

    It will return the default value for the target type if no header with that name is found in the collection.

    Declaration
    public object GetValueOrDefault(string name, Type targetType)
    Parameters
    Type Name Description
    System.String name

    The name of the header to be retrieved.

    System.Type targetType

    The type to convert the header value to.

    Returns
    Type Description
    System.Object

    The header value converted to the target type, or null if not found.

    | Improve this doc View source

    GetValueOrDefault<T>(String)

    Returns the value of the header with the specified name, casting it to the specified type T.

    It will return the default value for the type T if no header with that name is found in the collection.

    Declaration
    public T GetValueOrDefault<T>(string name)
        where T : struct
    Parameters
    Type Name Description
    System.String name

    The name of the header to be retrieved.

    Returns
    Type Description
    T

    The header value converted to the target type, or null if not found.

    Type Parameters
    Name Description
    T

    The type to convert the header value to.

    | Improve this doc View source

    Remove(MessageHeader)

    Removes the specified header.

    Declaration
    public void Remove(MessageHeader header)
    Parameters
    Type Name Description
    MessageHeader header

    The header to remove.

    | Improve this doc View source

    Remove(String)

    Removes all headers with the specified name.

    Declaration
    public void Remove(string name)
    Parameters
    Type Name Description
    System.String name

    The header name.

    Explicit Interface Implementations

    | Improve this doc View source

    IEnumerable.GetEnumerator()

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    System.Collections.IEnumerator

    Implements

    System.Collections.Generic.IReadOnlyList<T>
    System.Collections.Generic.IReadOnlyCollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable

    Extension Methods

    MessageHeaderEnumerableExtensions.Contains(IEnumerable<MessageHeader>, String)
    MessageHeaderEnumerableExtensions.GetValue(IEnumerable<MessageHeader>, String, Boolean)
    MessageHeaderEnumerableExtensions.GetValue<T>(IEnumerable<MessageHeader>, String, Boolean)
    MessageHeaderEnumerableExtensions.GetValue(IEnumerable<MessageHeader>, String, Type, Boolean)
    MessageHeaderEnumerableExtensions.GetValueOrDefault<T>(IEnumerable<MessageHeader>, String)
    MessageHeaderEnumerableExtensions.GetValueOrDefault(IEnumerable<MessageHeader>, String, Type)
    • Improve this doc
    • View source
    GitHub E-Mail
    ↑ Back to top © 2020 Sergio Aquilini