/// <summary> /// Creates a new instance of RabbitBus /// </summary> /// <param name="connectionConfiguration"> /// An IConnectionConfiguration instance. /// </param> /// <param name="registerServices"> /// Override default services. For example, to override the default IEasyNetQLogger: /// RabbitHutch.CreateBus("host=localhost", x => x.Register<IEasyNetQLogger>(_ => myLogger)); /// </param> /// <returns></returns> public static IBus CreateBus(IConnectionConfiguration connectionConfiguration, Action <IServiceRegister> registerServices) { Preconditions.CheckNotNull(connectionConfiguration, "connectionConfiguration"); Preconditions.CheckNotNull(registerServices, "registerServices"); Action <IServiceRegister> registerServices2 = x => { x.Register(_ => connectionConfiguration); registerServices(x); }; var serviceProvider = ComponentRegistration.CreateServiceProvider(registerServices2); return(serviceProvider.Resolve <IBus>()); }
/// <summary> /// Creates a new instance of RabbitBus /// </summary> /// <param name="connectionConfiguration"> /// An IConnectionConfiguration instance. /// </param> /// <param name="registerServices"> /// Override default services. For example, to override the default IEasyNetQLogger: /// RabbitHutch.CreateBus("host=localhost", x => x.Register<IEasyNetQLogger>(_ => myLogger)); /// </param> /// <returns></returns> public static IBus CreateBus(IConnectionConfiguration connectionConfiguration, Action <IServiceRegister> registerServices) { if (connectionConfiguration == null) { throw new ArgumentNullException("connectionConfiguration"); } if (registerServices == null) { throw new ArgumentNullException("registerServices"); } Action <IServiceRegister> registerServices2 = x => { x.Register(_ => connectionConfiguration); registerServices(x); }; var serviceProvider = ComponentRegistration.CreateServiceProvider(registerServices2); return(serviceProvider.Resolve <IBus>()); }