コード例 #1
0
        /// <summary>
        /// Connects any consumers for the component to the message dispatcher
        /// </summary>
        /// <param name="bus"></param>
        /// <param name="instance"></param>
        public static UnsubscribeAction SubscribeInstance([NotNull] this IServiceBus bus, [NotNull] object instance)
        {
            Guard.AgainstNull(instance, "instance", "A null instance cannot be subscribed");

            InstanceConnector connector = InstanceConnectorCache.GetInstanceConnector(instance.GetType());

            return(bus.Configure(x => connector.Connect(x, instance)));
        }
コード例 #2
0
        /// <summary>
        /// Connects any consumers for the component to the message dispatcher
        /// </summary>
        /// <typeparam name="T">The consumer type</typeparam>
        /// <param name="bus"></param>
        /// <param name="instance"></param>
        public static UnsubscribeAction SubscribeInstance <T>([NotNull] this IServiceBus bus, [NotNull] T instance)
            where T : class
        {
            Guard.AgainstNull(instance, "instance", "A null instance cannot be subscribed");

            InstanceConnector connector = InstanceConnectorCache.GetInstanceConnector <T>();

            return(bus.Configure(x => connector.Connect(x, instance)));
        }
コード例 #3
0
 /// <summary>
 /// Subscribe a component to the pipeline that handles every message
 /// </summary>
 /// <typeparam name="TComponent"></typeparam>
 /// <param name="pipeline">The pipeline to configure</param>
 /// <param name="instance">The instance that will handle the messages</param>
 /// <returns></returns>
 public static UnsubscribeAction ConnectInstance <TComponent>(this IInboundMessagePipeline pipeline, TComponent instance)
     where TComponent : class
 {
     return(pipeline.Configure(x =>
     {
         InstanceConnector connector = InstanceConnectorCache.GetInstanceConnector <TComponent>();
         return connector.Connect(x, instance);
     }));
 }
コード例 #4
0
        public ISubscriptionReference Subscribe(IInboundPipelineConfigurator configurator)
        {
            UnsubscribeAction unsubscribe = _connector.Connect(configurator, _instance);

            return(_referenceFactory(unsubscribe));
        }