Exemplo n.º 1
0
        public static SimpleOutlet <T> CreateOutlet <T>(IPipe pipe)
        {
            var promisedPipe = new Promised <IPipe>();

            promisedPipe.Fulfill(pipe);
            return(new SimpleOutlet <T>(promisedPipe));
        }
        public ISourcePipe <TMessage> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var outlet = Outlet(promisedPipe);

            return(promisedPipe.Fulfill(new SourcePipe <TMessage>(outlet, MessageProducer)));
        }
Exemplo n.º 3
0
        public ISinkPipe <TMessage> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var inlet = Inlet(promisedPipe);

            return(promisedPipe.Fulfill(new SinkPipe <TMessage>(inlet)));
        }
        public IBigValvedPipe <TReceive, TSend, TTieBreaker> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var inlets  = Enumerable.Repeat <Func <SimpleInlet <TReceive> > >(() => new SimpleInlet <TReceive>(promisedPipe), NumberOfInlets).Select(f => f()).ToList();
            var outlets = Enumerable.Repeat <Func <SimpleOutlet <TSend> > >(() => new SimpleOutlet <TSend>(promisedPipe), NumberOfOutlets).Select(f => f()).ToList();

            return(promisedPipe.Fulfill(new BigValvedPipe <TReceive, TSend, TTieBreaker>(inlets, outlets, TieBreaker)));
        }
Exemplo n.º 5
0
        public ICapacityPipe <TMessage> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var inlet  = Inlet(promisedPipe);
            var outlet = Outlet(promisedPipe);

            return(promisedPipe.Fulfill(new CapacityPipe <TMessage>(inlet, outlet, Capacity)));
        }
Exemplo n.º 6
0
        public IValvedPipe <TReceive, TSend, TTieBreaker> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var inlet  = Inlet(promisedPipe);
            var outlet = Outlet(promisedPipe);

            return(promisedPipe.Fulfill(new ValvedPipe <TReceive, TSend, TTieBreaker>(inlet, outlet, TieBreaker)));
        }
Exemplo n.º 7
0
        public IBasicPipe <TMessage> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var inlet  = Inlet(promisedPipe);
            var outlet = Outlet(promisedPipe);

            return(promisedPipe.Fulfill(new BasicPipe <TMessage>(inlet, outlet)));
        }
        public IBigEitherOutletPipe <TMessage, TTieBreaker> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var inlet   = new SimpleInlet <TMessage>(promisedPipe);
            var outlets = Enumerable.Repeat <Func <SimpleOutlet <TMessage> > >(() => new SimpleOutlet <TMessage>(promisedPipe), Size).Select(f => f()).ToList();

            return(promisedPipe.Fulfill(new BigEitherOutletPipe <TMessage, TTieBreaker>(inlet, outlets, TieBreaker)));
        }
Exemplo n.º 9
0
        public ITransformPipe <TSourceMessage, TTargetMessage> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var inlet  = Inlet(promisedPipe);
            var outlet = Outlet(promisedPipe);

            return(promisedPipe.Fulfill(new TransformPipe <TSourceMessage, TTargetMessage>(inlet, outlet, Map)));
        }
Exemplo n.º 10
0
        public ISplittingPipe <TMessage> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var inlet       = Inlet(promisedPipe);
            var leftOutlet  = LeftOutlet(promisedPipe);
            var rightOutlet = RightOutlet(promisedPipe);

            return(promisedPipe.Fulfill(new SplittingPipe <TMessage>(inlet, leftOutlet, rightOutlet)));
        }
        public IEitherInletPipe <TTieBreaker, TMessage> Build()
        {
            var promisedPipe = new Promised <IPipe>();

            var leftInlet  = LeftInlet(promisedPipe);
            var rightInlet = RightInlet(promisedPipe);
            var outlet     = Outlet(promisedPipe);

            return(promisedPipe.Fulfill(new EitherInletPipe <TTieBreaker, TMessage>(leftInlet, rightInlet, outlet, TieBreaker)));
        }
Exemplo n.º 12
0
        /// <summary>
        /// A convenience method for creating an adapter for an inlet pair.
        /// This will automatically connect the adapter to the internal inlet and pass events between the adapter and external inlet.
        ///
        /// The external inlet should be the inlet the world can interact with, while the internal inlet is the corresponding inlet of
        /// our internal pipe system - the implementation of this pipe.
        /// </summary>
        protected IAdapterOutlet <TMessage> CreateAndConnectAdapter <TMessage>(IInlet <TMessage> internalInlet, IInlet <TMessage> externalInlet)
        {
            var promisedPipe = new Promised <IPipe>();

            promisedPipe.Fulfill(this);

            var adapterOutlet = new AdapterOutlet <TMessage>(promisedPipe);

            SharedResource.ConnectTo(adapterOutlet.SharedResource);

            adapterOutlets.Add(adapterOutlet);
            inletOutletBiLookup.Add(externalInlet, adapterOutlet);

            // Do not check if the graph forms a tree - it probably doesn't as all adapters are connected
            // to this pipe. However, messages should never be passed in a cycle or violate the "tree-ness" nevertheless.
            adapterOutlet.ConnectTo(internalInlet, false);
            return(adapterOutlet);
        }