public static void AddRabbitMQ(this IServiceCollection services, Action <BrokerOption> action) { var option = new BrokerOption(); action.Invoke(option); IBusClient client = new RabbitMQClient(); client.CreateConnection(option.Host, option.UserName, option.Password); foreach (var bindOption in option.BindOptions) { client.Bind(bindOption.Exchange, bindOption.Queue, bindOption.RoutingKey); } services.AddSingleton <IBusClient>(client); }