protected virtual UnsubscribeAction Connect <TMessage>(ISubscriberContext context, Consumes <TMessage> .Selected consumer) where TMessage : class { var sink = new InstanceMessageSink <TMessage>(message => { // rock it return(consumer.Accept(message) ? (Action <TMessage>)consumer.Consume : null); }); return(context.Pipeline.ConnectToRouter(sink, () => context.SubscribedTo <TMessage>())); }
protected virtual UnsubscribeAction ConnectWorker <TComponent, TMessage>(ISubscriberContext context, Consumes <Distributed <TMessage> > .Selected consumer) where TComponent : Consumes <Distributed <TMessage> > .Selected where TMessage : class { var sink = new WorkerMessageSink <Distributed <TMessage> >(message => { // rock it return(consumer.Accept(message) ? (Action <Distributed <TMessage> >)consumer.Consume : null); }); return(context.Pipeline.ConnectToRouter(sink, () => context.SubscribedTo <Distributed <TMessage> >())); }
public IEnumerable <Action <TMessage> > Enumerate(TMessage message) { Consumes <TMessage> .Selected consumer = BuildConsumer(); try { if (consumer.Accept(message) == false) { yield break; } yield return(consumer.Consume); } finally { Release(consumer); } }