/// <summary> /// Dispatch a message through the pipeline. If the message will be consumed, the accept function /// is called to allow the endpoint to acknowledge the message reception if applicable /// </summary> /// <param name="pipeline">The pipeline instance</param> /// <param name="message">The message to dispatch</param> /// <param name="acknowledge">The function to call if the message will be consumed by the pipeline</param> public static bool Dispatch(this IMessagePipeline pipeline, object message, Func <object, bool> acknowledge) { bool consumed = false; foreach (Action <object> consumer in pipeline.Enumerate(message)) { if (!acknowledge(message)) { return(false); } acknowledge = x => true; consumed = true; consumer(message); } return(consumed); }