async Task ConcreteMessage(IPipelineContext context)
 {
     #region InstancePublish
     MyEvent message = new MyEvent { SomeProperty = "Hello world" };
     await context.Publish(message);
     #endregion
 }
        async Task InterfaceMessage(IPipelineContext context)
        {
            #region InterfacePublish
            await context.Publish <IMyEvent>(m => { m.SomeProperty = "Hello world"; });

            #endregion
        }
        /// <summary>
        /// Instantiates a message of type T and publishes it.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="context">The instance of <see cref="IPipelineContext" /> to use for the action.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        public static Task Publish <T>(this IPipelineContext context, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(context), context);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            return(context.Publish(messageConstructor, new PublishOptions()));
        }
        /// <summary>
        /// Publish the message to subscribers.
        /// </summary>
        /// <param name="context">The instance of <see cref="IPipelineContext" /> to use for the action.</param>
        /// <param name="message">The message to publish.</param>
        public static Task Publish(this IPipelineContext context, object message)
        {
            Guard.AgainstNull(nameof(context), context);
            Guard.AgainstNull(nameof(message), message);

            return(context.Publish(message, new PublishOptions()));
        }
    public static Task PublishWithId(this IPipelineContext messageSession, object message, string id)
    {
        var options = new PublishOptions();

        options.SetMessageId(id);
        options.RequireImmediateDispatch();
        return(messageSession.Publish(message, options));
    }
        async Task ConcreteMessage(IPipelineContext context)
        {
            #region InstancePublish
            MyEvent message = new MyEvent {
                SomeProperty = "Hello world"
            };
            await context.Publish(message);

            #endregion
        }
Beispiel #7
0
        Task InterfaceMessage(IPipelineContext context)
        {
            #region InterfacePublish

            return(context.Publish <IMyEvent>(
                       messageConstructor: message =>
            {
                message.SomeProperty = "Hello world";
            }));

            #endregion
        }
 async Task InterfaceMessage(IPipelineContext context)
 {
     #region InterfacePublish
     await context.Publish<IMyEvent>(m => { m.SomeProperty = "Hello world"; });
     #endregion
 }
Beispiel #9
0
        public Task Publish(object message, PublishOptions options)
        {
            ThrowIfDisposed();

            return(pipelineContext.Publish(message, options));
        }
        /// <summary>
        /// Publish the message to subscribers.
        /// </summary>
        /// <param name="context">The instance of <see cref="IPipelineContext" /> to use for the action.</param>
        /// <typeparam name="T">The message type.</typeparam>
        public static Task Publish <T>(this IPipelineContext context)
        {
            Guard.AgainstNull(nameof(context), context);

            return(context.Publish <T>(_ => { }, new PublishOptions()));
        }
Beispiel #11
0
 public void Publish <T>(T @event)
 {
     context.Publish(@event).GetAwaiter().GetResult();
 }