Example #1
0
 public void ConnectNodeByJoin(TaskNode start, TaskNode end, int outNr)
 {
     if (end.StreamIn == null)
     {
         throw new InvalidOperationException("Use ConnectNodeByJoin only after connecting the main connection");
     }
     start.ConnectOutStream((IWritableQueue)end.StreamIn, outNr, end.InType);
 }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="publisher"></param>
        /// <param name="reader"></param>
        /// <param name="streamNumber"></param>
        public BoundedBlockingQueue ConnectNodes(TaskNode publisher, TaskNode reader, int streamNumber, int queueSize)
        {
            if (!reader.InType.IsAssignableFrom(publisher.OutTypes[streamNumber]))
            {
                throw new InvalidOperationException(String.Format("The in-stream of the reader ({1}) cannot be assigned from the publisher of type ({0})", publisher.OutTypes[streamNumber].Name, reader.InType.Name));
            }
            Type bbOfT = typeof(BoundedBlockingQueue <>).MakeGenericType(new Type[] { reader.InType });
            BoundedBlockingQueue stream = (BoundedBlockingQueue)Activator.CreateInstance(bbOfT, queueSize);

            publisher.ConnectOutStream(stream, streamNumber, reader.InType);
            reader.ConnectInStream(stream);
            if (String.IsNullOrEmpty(stream.Name))
            {
                stream.Name = String.Format("from '{0}' to '{1}'", publisher.Name, reader.Name);
            }
            _streams.Add(stream);
            stream.OwningFlow = this;
            return(stream);
        }