Table of Contents

Class MessageHeaders

Namespace
Steeltoe.Messaging
Assembly
Steeltoe.Messaging.MessagingBase.dll
public class MessageHeaders : IMessageHeaders, IDictionary, ICollection, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable
Inheritance
MessageHeaders
Implements
Derived
Inherited Members

Constructors

MessageHeaders(MessageHeaders)

protected MessageHeaders(MessageHeaders other)

Parameters

other MessageHeaders

MessageHeaders(IDictionary<string, object>)

public MessageHeaders(IDictionary<string, object> headers = null)

Parameters

headers IDictionary<string, object>

MessageHeaders(IDictionary<string, object>, string, long?)

public MessageHeaders(IDictionary<string, object> headers, string id, long? timestamp)

Parameters

headers IDictionary<string, object>
id string
timestamp long?

Fields

CONTENT_TYPE

public const string CONTENT_TYPE = "contentType"

Field Value

string

CONTENT_TYPE_BYTES

public const string CONTENT_TYPE_BYTES = "application/octet-stream"

Field Value

string

CONTENT_TYPE_DOTNET_SERIALIZED_OBJECT

public const string CONTENT_TYPE_DOTNET_SERIALIZED_OBJECT = "application/x-dotnet-serialized-object"

Field Value

string

CONTENT_TYPE_ID

public const string CONTENT_TYPE_ID = "__ContentTypeId__"

Field Value

string

CONTENT_TYPE_JAVA_SERIALIZED_OBJECT

public const string CONTENT_TYPE_JAVA_SERIALIZED_OBJECT = "application/x-java-serialized-object"

Field Value

string

CONTENT_TYPE_JSON

public const string CONTENT_TYPE_JSON = "application/json"

Field Value

string

CONTENT_TYPE_JSON_ALT

public const string CONTENT_TYPE_JSON_ALT = "text/x-json"

Field Value

string

CONTENT_TYPE_TEXT_PLAIN

public const string CONTENT_TYPE_TEXT_PLAIN = "text/plain"

Field Value

string

CONTENT_TYPE_XML

public const string CONTENT_TYPE_XML = "application/xml"

Field Value

string

ERROR_CHANNEL

public const string ERROR_CHANNEL = "errorChannel"

Field Value

string

ID

public const string ID = "id"

Field Value

string

ID_VALUE_NONE

public static readonly string ID_VALUE_NONE

Field Value

string

INFERRED_ARGUMENT_TYPE

public const string INFERRED_ARGUMENT_TYPE = "internal_InferredArgumentType"

Field Value

string

INTERNAL

public const string INTERNAL = "internal_"

Field Value

string

KEY_TYPE_ID

public const string KEY_TYPE_ID = "__KeyTypeId__"

Field Value

string

REPLY_CHANNEL

public const string REPLY_CHANNEL = "replyChannel"

Field Value

string

TIMESTAMP

public const string TIMESTAMP = "timestamp"

Field Value

string

TYPE_ID

public const string TYPE_ID = "__TypeId__"

Field Value

string

headers

protected readonly IDictionary<string, object> headers

Field Value

IDictionary<string, object>

Properties

Count

public virtual int Count { get; }

Property Value

int

ErrorChannel

Gets the error channel the message is for

public virtual object ErrorChannel { get; }

Property Value

object

Id

Gets the ID header value

public virtual string Id { get; }

Property Value

string

IsFixedSize

public virtual bool IsFixedSize { get; }

Property Value

bool

IsReadOnly

Gets a value indicating whether the IDictionary object is read-only.

public virtual bool IsReadOnly { get; }

Property Value

bool

true if the IDictionary object is read-only; otherwise, false.

IsSynchronized

public virtual bool IsSynchronized { get; }

Property Value

bool

this[object]

public virtual object this[object key] { get; set; }

Parameters

key object

Property Value

object

this[string]

Gets or sets the element with the specified key.

public virtual object this[string key] { get; set; }

Parameters

key string

The key of the element to get or set.

Property Value

object

The element with the specified key.

Exceptions

ArgumentNullException

key is null.

KeyNotFoundException

The property is retrieved and key is not found.

NotSupportedException

The property is set and the IDictionary<TKey, TValue> is read-only.

Keys

public virtual ICollection<string> Keys { get; }

Property Value

ICollection<string>

RawHeaders

protected virtual IDictionary<string, object> RawHeaders { get; }

Property Value

IDictionary<string, object>

ReplyChannel

Gets the reply channel the message is for

public virtual object ReplyChannel { get; }

Property Value

object

SyncRoot

public virtual object SyncRoot { get; }

Property Value

object

Timestamp

Gets the timestamp header value

public virtual long? Timestamp { get; }

Property Value

long?

Values

public virtual ICollection<object> Values { get; }

Property Value

ICollection<object>

Methods

Add(KeyValuePair<string, object>)

Adds an item to the ICollection<T>.

public virtual void Add(KeyValuePair<string, object> item)

Parameters

item KeyValuePair<string, object>

The object to add to the ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Add(object, object)

public virtual void Add(object key, object value)

Parameters

key object
value object

Add(string, object)

Adds an element with the provided key and value to the IDictionary<TKey, TValue>.

public virtual void Add(string key, object value)

Parameters

key string

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

value object

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

Exceptions

ArgumentNullException

key is null.

ArgumentException

An element with the same key already exists in the IDictionary<TKey, TValue>.

NotSupportedException

The IDictionary<TKey, TValue> is read-only.

Clear()

Removes all elements from the IDictionary object.

public virtual void Clear()

Exceptions

NotSupportedException

The IDictionary object is read-only.

Contains(KeyValuePair<string, object>)

Determines whether the ICollection<T> contains a specific value.

public virtual bool Contains(KeyValuePair<string, object> item)

Parameters

item KeyValuePair<string, object>

The object to locate in the ICollection<T>.

Returns

bool

true if item is found in the ICollection<T>; otherwise, false.

Contains(object)

public virtual bool Contains(object key)

Parameters

key object

Returns

bool

ContainsKey(string)

Determines whether the IDictionary<TKey, TValue> contains an element with the specified key.

public virtual bool ContainsKey(string key)

Parameters

key string

The key to locate in the IDictionary<TKey, TValue>.

Returns

bool

true if the IDictionary<TKey, TValue> contains an element with the key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

CopyTo(Array, int)

public virtual void CopyTo(Array array, int index)

Parameters

array Array
index int

CopyTo(KeyValuePair<string, object>[], int)

Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

public virtual void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)

Parameters

array KeyValuePair<string, object>[]

The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Exceptions

ArgumentNullException

array is null.

ArgumentOutOfRangeException

arrayIndex is less than 0.

ArgumentException

The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

From(MessageHeaders)

public static MessageHeaders From(MessageHeaders other)

Parameters

other MessageHeaders

Returns

MessageHeaders

GetEnumerator()

public virtual IEnumerator<KeyValuePair<string, object>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<string, object>>

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Get<T>(string)

Gets a header value given its key

public virtual T Get<T>(string key)

Parameters

key string

the name of the header

Returns

T

the value or null if not found

Type Parameters

T

the type of the value returned

Remove(KeyValuePair<string, object>)

Removes the first occurrence of a specific object from the ICollection<T>.

public virtual bool Remove(KeyValuePair<string, object> item)

Parameters

item KeyValuePair<string, object>

The object to remove from the ICollection<T>.

Returns

bool

true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

Exceptions

NotSupportedException

The ICollection<T> is read-only.

Remove(object)

public virtual void Remove(object key)

Parameters

key object

Remove(string)

Removes the element with the specified key from the IDictionary<TKey, TValue>.

public virtual bool Remove(string key)

Parameters

key string

The key of the element to remove.

Returns

bool

true if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original IDictionary<TKey, TValue>.

Exceptions

ArgumentNullException

key is null.

NotSupportedException

The IDictionary<TKey, TValue> is read-only.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryGetValue(string, out object)

Gets the value associated with the specified key.

public virtual bool TryGetValue(string key, out object value)

Parameters

key string

The key whose value to get.

value object

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool

true if the object that implements IDictionary<TKey, TValue> contains an element with the specified key; otherwise, false.

Exceptions

ArgumentNullException

key is null.

UpdateHeaders(string, long?)

protected void UpdateHeaders(string id, long? timestamp)

Parameters

id string
timestamp long?