/// <summary> /// Subscribes the specified service bus. /// </summary> /// <typeparam name="TMessage">The type of the message.</typeparam> /// <param name="serviceBus">The service bus.</param> /// <param name="condition">The condition.</param> public static void Subscribe <TMessage>(this IPublishingServiceBus serviceBus, Predicate <TMessage> condition) where TMessage : class { var p = new Predicate <object>(m => (m is TMessage ? condition((TMessage)m) : true)); serviceBus.Subscribe(typeof(TMessage), p); }
/// <summary> /// Unsubscribes the specified service bus. /// </summary> /// <typeparam name="TMessage">The type of the message.</typeparam> /// <param name="serviceBus">The service bus.</param> public static void Unsubscribe <TMessage>(this IPublishingServiceBus serviceBus) where TMessage : class { serviceBus.Subscribe(typeof(TMessage)); }
/// <summary> /// Subscribes the specified service bus. /// </summary> /// <param name="serviceBus">The service bus.</param> /// <param name="messageType">Type of the message.</param> public static void Subscribe(this IPublishingServiceBus serviceBus, Type messageType) { }
// publishing /// <summary> /// Publishes the specified service bus. /// </summary> /// <typeparam name="TMessage">The type of the message.</typeparam> /// <param name="serviceBus">The service bus.</param> /// <param name="messageBuilder">The message builder.</param> public static void Publish <TMessage>(this IPublishingServiceBus serviceBus, Action <TMessage> messageBuilder) where TMessage : class { serviceBus.Publish(serviceBus.CreateMessage <TMessage>(messageBuilder)); }