Exemple #1
0
        /// <summary>
        /// Creates a dataflow builder from a batched join of multiple source blocks.
        /// </summary>
        /// <typeparam name="TOutput1"></typeparam>
        /// <typeparam name="TOutput2"></typeparam>
        /// <typeparam name="TOutput3"></typeparam>
        /// <param name="sourceBlock1"></param>
        /// <param name="sourceBlock2"></param>
        /// <param name="sourceBlock3"></param>
        /// <param name="batchSize"></param>
        /// <param name="joinOptions"></param>
        /// <returns></returns>
        public ISourceDataflowBuilder <Tuple <IList <TOutput1>, IList <TOutput2>, IList <TOutput3> > > BatchedJoin <TOutput1, TOutput2, TOutput3>(ISourceBlock <TOutput1> sourceBlock1, ISourceBlock <TOutput2> sourceBlock2, ISourceBlock <TOutput3> sourceBlock3, int batchSize, DataflowJoinOptions joinOptions = default(DataflowJoinOptions))
        {
            if (sourceBlock1 == null)
            {
                throw new ArgumentNullException("sourceBlock1");
            }
            if (sourceBlock2 == null)
            {
                throw new ArgumentNullException("sourceBlock2");
            }
            if (sourceBlock3 == null)
            {
                throw new ArgumentNullException("sourceBlock3");
            }

            var batchedJoinBlock = new BatchedJoinBlock <TOutput1, TOutput2, TOutput3>(batchSize, joinOptions.JoinBlockOptions);

            LinkHelper.Link(sourceBlock1, batchedJoinBlock.Target1, joinOptions.Target1LinkOptions);
            LinkHelper.Link(sourceBlock2, batchedJoinBlock.Target2, joinOptions.Target2LinkOptions);
            LinkHelper.Link(sourceBlock3, batchedJoinBlock.Target3, joinOptions.Target3LinkOptions);

            var multipleSourcesWrapper = new MultipleSourceDataflowWrapper(new IDataflowBlock[] { sourceBlock1, sourceBlock2, sourceBlock3 });
            var sourceWrapper          = new ReceivableSourceDataflowWrapper <Tuple <IList <TOutput1>, IList <TOutput2>, IList <TOutput3> > >(multipleSourcesWrapper, batchedJoinBlock, batchedJoinBlock);

            return(FromSource(sourceWrapper));
        }
Exemple #2
0
        /// <summary>
        /// Creates a dataflow builder from a join of multiple source blocks.
        /// </summary>
        /// <typeparam name="TOutput1"></typeparam>
        /// <typeparam name="TOutput2"></typeparam>
        /// <param name="sourceBlock1"></param>
        /// <param name="sourceBlock2"></param>
        /// <param name="joinOptions"></param>
        /// <returns></returns>
        public ISourceDataflowBuilder <Tuple <TOutput1, TOutput2> > Join <TOutput1, TOutput2>(ISourceBlock <TOutput1> sourceBlock1, ISourceBlock <TOutput2> sourceBlock2, DataflowJoinOptions joinOptions = default(DataflowJoinOptions))
        {
            if (sourceBlock1 == null)
            {
                throw new ArgumentNullException("sourceBlock1");
            }
            if (sourceBlock2 == null)
            {
                throw new ArgumentNullException("sourceBlock2");
            }

            var joinBlock = new JoinBlock <TOutput1, TOutput2>(joinOptions.JoinBlockOptions);

            LinkHelper.Link(sourceBlock1, joinBlock.Target1, joinOptions.Target1LinkOptions);
            LinkHelper.Link(sourceBlock2, joinBlock.Target2, joinOptions.Target2LinkOptions);

            var multipleSourcesWrapper = new MultipleSourceDataflowWrapper(new IDataflowBlock[] { sourceBlock1, sourceBlock2 });
            var sourceWrapper          = new ReceivableSourceDataflowWrapper <Tuple <TOutput1, TOutput2> >(multipleSourcesWrapper, joinBlock, joinBlock);

            return(FromSource(sourceWrapper));
        }