/// <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)); }
/// <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)); }