Beispiel #1
0
        /// <summary>
        ///     Dispatches the specified entity
        /// </summary>
        /// <param name="dispatcher">The dispatcher in use</param>
        /// <param name="entity">The entity to dispatch</param>
        /// <param name="attributes">The attributes to send along with the message</param>
        /// <returns>A task that completes when the message has been acknowledged by the receiver</returns>
        public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, T entity, IEnumerable <KeyValuePair <string, string> > attributes)
        {
            var message = new ExtendedMessage <T> {
                Value = entity, Properties = attributes ?? Enumerable.Empty <KeyValuePair <string, string> >()
            };

            return(dispatcher.DispatchAsync(message, default));
        }
Beispiel #2
0
        /// <summary>
        ///     Dispatches the specified entity
        /// </summary>
        /// <param name="dispatcher">The dispatcher in use</param>
        /// <param name="entity">The entity to dispatch</param>
        /// <param name="id">The id to use for the message</param>
        /// <returns>A task that completes when the message has been acknowledged by the receiver</returns>
        public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, T entity, string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                Throw.ArgumentNullException(nameof(id));
            }

            var message = new ExtendedMessage <T> {
                Value = entity, Id = id
            };

            return(dispatcher.DispatchAsync(message, default));
        }
Beispiel #3
0
        /// <summary>
        ///     Dispatches the specified entity
        /// </summary>
        /// <param name="dispatcher">The dispatcher in use</param>
        /// <param name="entity">The entity to dispatch</param>
        /// <param name="attributes">The attributes to send along with the message</param>
        /// <param name="id">The id to use for the message</param>
        /// <returns>A task that completes when the message has been acknowledged by the receiver</returns>
        public static Task DispatchAsync <T>(this IDispatcher <T> dispatcher, T entity, IEnumerable <KeyValuePair <string, string> > attributes, string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                Throw.ArgumentNullException(nameof(id));
            }

            var message = new ExtendedMessage <T> {
                Value = entity, Properties = attributes ?? Enumerable.Empty <KeyValuePair <string, string> >(), Id = id
            };

            return(dispatcher.DispatchAsync(message, default));
        }