Beispiel #1
0
        /// <summary>
        /// Connects any consumers for the object to the message dispatcher
        /// </summary>
        /// <typeparam name="T">The consumer type</typeparam>
        /// <param name="bus">The service bus instance to call this method on.</param>
        /// <param name="instance">The instance to subscribe.</param>
        /// <returns>The unsubscribe action that can be called to unsubscribe the instance
        /// passed as an argument.</returns>
        public static ConnectHandle ConnectInstance <T>(this IBus bus, T instance)
            where T : class, IConsumer
        {
            IInstanceConnector connector = InstanceConnectorCache.GetInstanceConnector <T>();

            return(connector.ConnectInstance(bus, instance));
        }
Beispiel #2
0
 public InstanceSubscriptionBuilder(object instance,
                                    ReferenceFactory referenceFactory)
 {
     _instance         = instance;
     _connector        = InstanceConnectorCache.GetInstanceConnector(instance.GetType());
     _referenceFactory = referenceFactory;
 }
        /// <summary>
        /// Connects any consumers for the component to the message dispatcher
        /// </summary>
        /// <param name="bus">The service bus to configure</param>
        /// <param name="instance"></param>
        /// <returns>The unsubscribe action that can be called to unsubscribe the instance
        /// passed as an argument.</returns>
        public static UnsubscribeAction SubscribeInstance([NotNull] this IServiceBus bus, [NotNull] object instance)
        {
            Guard.AgainstNull(instance, "instance", "A null instance cannot be subscribed");

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

            return(bus.Configure(x => connector.Connect(x, instance)));
        }
        /// <summary>
        /// Connects any consumers for the component to the message dispatcher
        /// </summary>
        /// <typeparam name="T">The consumer type</typeparam>
        /// <param name="bus">The service bus instance to call this method on.</param>
        /// <param name="instance">The instance to subscribe.</param>
        /// <returns>The unsubscribe action that can be called to unsubscribe the instance
        /// passed as an argument.</returns>
        public static UnsubscribeAction SubscribeInstance <T>([NotNull] this IServiceBus bus, [NotNull] T instance)
            where T : class, IConsumer
        {
            Guard.AgainstNull(instance, "instance", "A null instance cannot be subscribed");

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

            return(bus.Configure(x => connector.Connect(x, instance)));
        }
 /// <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 =>
     {
         IInstanceConnector connector = InstanceConnectorCache.GetInstanceConnector <TComponent>();
         return connector.Connect(x, instance);
     }));
 }
Beispiel #6
0
        /// <summary>
        /// Connects any consumers for the object to the message dispatcher
        /// </summary>
        /// <param name="bus">The service bus to configure</param>
        /// <param name="instance"></param>
        /// <returns>The unsubscribe action that can be called to unsubscribe the instance
        /// passed as an argument.</returns>
        public static ConnectHandle ConnectInstance(this IBus bus, object instance)
        {
            if (bus == null)
            {
                throw new ArgumentNullException(nameof(bus));
            }
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

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

            return(connector.ConnectInstance(bus, instance));
        }