Exemplo n.º 1
0
        /// <summary>
        /// Publish the message to subscribers.
        /// </summary>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="message">The message to publish.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
        public static Task Publish(this IUniformSession session, object message, CancellationToken cancellationToken = default)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(message), message);

            return(session.Publish(message, new PublishOptions(), cancellationToken));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Instantiates a message of type T and publishes it.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        public static Task Publish <T>(this IUniformSession session, Action <T> messageConstructor)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

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

            return(session.Publish(message, new PublishOptions()));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Instantiates a message of type T and publishes it.
        /// </summary>
        /// <typeparam name="T">The type of message, usually an interface.</typeparam>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="messageConstructor">An action which initializes properties of the message.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
        public static Task Publish <T>(this IUniformSession session, Action <T> messageConstructor, CancellationToken cancellationToken = default)
        {
            Guard.AgainstNull(nameof(session), session);
            Guard.AgainstNull(nameof(messageConstructor), messageConstructor);

            return(session.Publish(messageConstructor, new PublishOptions(), cancellationToken));
        }
            public async Task DoSomething(IMessageSession messageSession)
            {
                await messageSession.Send <ISomeOtherCommand>(_ => { });

                await messageSession.Publish <ISomeOtherEvent>(_ => { });

                await uniformSession.Send <ISomeOtherCommand>(_ => { });

                await uniformSession.Publish <ISomeOtherEvent>(_ => { });
            }
            public async Task Handle(SomeCommand message, IMessageHandlerContext context)
            {
                await context.Send(new SomeCommand());

                await context.Publish(new SomeEvent());

                await uniformSession.Send(new SomeCommand());

                await uniformSession.Publish(new SomeEvent());

                context.DoNotContinueDispatchingCurrentMessageToHandlers();
            }
            public override async Task Invoke(IIncomingLogicalMessageContext context, Func <Task> next)
            {
                await uniformSession.Send(new SomeCommand());

                await uniformSession.Publish(new SomeEvent());

                await context.Send(new SomeCommand());

                await context.Publish(new SomeEvent());

                await next();

                context.Headers["testHeader"] = "testValue";
            }
Exemplo n.º 8
0
        /// <summary>
        /// Publish the message to subscribers.
        /// </summary>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <typeparam name="T">The message type.</typeparam>
        public static Task Publish <T>(this IUniformSession session)
        {
            Guard.AgainstNull(nameof(session), session);

            return(session.Publish <T>(_ => { }, new PublishOptions()));
        }
Exemplo n.º 9
0
 public async Task PublicEvent(IEvent @event)
 {
     await _session.Publish(@event).ConfigureAwait(false);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Publish the message to subscribers.
        /// </summary>
        /// <param name="session">The instance of <see cref="IUniformSession" /> to use for the action.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
        /// <typeparam name="T">The message type.</typeparam>
        public static Task Publish <T>(this IUniformSession session, CancellationToken cancellationToken = default)
        {
            Guard.AgainstNull(nameof(session), session);

            return(session.Publish <T>(_ => { }, new PublishOptions(), cancellationToken));
        }
 public Task PublishEvent(CancellationToken cancellationToken = default) => session.Publish(new SomeEvent(), cancellationToken: cancellationToken);