public void SetHeader <THeader>(IMessageContextData <THeader> property, THeader value) where THeader : class { if (!_headers.ContainsKey(property.Name)) { _headers.Add(property.Name, value); } }
/// <summary> /// Returns data set by <see cref="SetHeader{THeader}"/> /// </summary> /// <typeparam name="THeader">data type</typeparam> /// <param name="itemData">The property.</param> /// <returns></returns> public THeader GetHeader <THeader>(IMessageContextData <THeader> itemData) where THeader : class { if (!Headers.ContainsKey(itemData.Name)) { Headers[itemData.Name] = itemData.Default; } return((THeader)Headers[itemData.Name]); }
/// <summary> /// Returns data set by <see cref="SetInternalHeader{THeader}" /> /// </summary> /// <typeparam name="THeader">data type</typeparam> /// <param name="itemData">The item data.</param> /// <returns></returns> public THeader GetInternalHeader <THeader>(IMessageContextData <THeader> itemData) where THeader : class { if (!_headersInternal.ContainsKey(itemData.Name)) { _headersInternal[itemData.Name] = itemData.Default; } return((THeader)_headersInternal[itemData.Name]); }
/// <summary> /// Returns typed data from the headers collection /// </summary> /// <typeparam name="THeader">data type</typeparam> /// <param name="property">The property.</param> /// <returns></returns> public THeader GetHeader <THeader>(IMessageContextData <THeader> property) where THeader : class { if (Headers.ContainsKey(property.Name)) { return((THeader)Headers[property.Name]); } return(property.Default); }
/// <summary> /// Returns data set by <see cref="Set{T}" /> /// </summary> /// <typeparam name="T">data type</typeparam> /// <param name="itemData">The item data.</param> /// <returns></returns> /// <remarks> /// If the data does not exist, it will be added with the default value and returned /// </remarks> public T Get <T>(IMessageContextData <T> itemData) where T : class { //code may obtain user items if we are in the middle of disposing, but have not cleared the items yet if (IsDisposed && _items.Count == 0) { ThrowIfDisposed(); } if (!_items.ContainsKey(itemData.Name)) { _items[itemData.Name] = itemData.Default; } return((T)_items[itemData.Name]); }
/// <summary> /// Sets an internal header for access by other parts of the queue. Will not be serialized by the transport. /// </summary> /// <typeparam name="THeader">data type</typeparam> /// <param name="itemData">The item data.</param> /// <param name="value">The value.</param> /// <remarks> /// Data that needs to be persistent should be set via <see cref="SetHeader{THeader}" /> /// </remarks> public void SetInternalHeader <THeader>(IMessageContextData <THeader> itemData, THeader value) where THeader : class { _headersInternal[itemData.Name] = value; }
/// <summary> /// Allows additional information to be attached to a message, that is not part of the message body. /// </summary> /// <typeparam name="THeader">data type</typeparam> /// <param name="itemData">The property.</param> /// <param name="value">The value.</param> public void SetHeader <THeader>(IMessageContextData <THeader> itemData, THeader value) where THeader : class { Headers[itemData.Name] = value; }
public THeader GetHeader <THeader>(IMessageContextData <THeader> property) where THeader : class { return(null); }
/// <summary> /// Allows the transport to attach data to the context. /// <remarks>For instance, data can be attached during de-queue, and then re-accessed during commit</remarks> /// </summary> /// <typeparam name="T">data type</typeparam> /// <param name="property">The property.</param> /// <param name="value">The value.</param> public void Set <T>(IMessageContextData <T> property, T value) where T : class { ThrowIfDisposed(); _items[property.Name] = value; }