public IFlowBuilder To <TBlockTarget>() where TBlockTarget : BlockBase
        {
            if (this._sourceIds == null || !this._sourceIds.Any())
            {
                throw new InvalidOperationException("Source block not set. Use Link() method before To()");
            }

            var targetBlock = this.GetBlock(this.CreateDefaultBlockWithId <TBlockTarget>());

            if (targetBlock == null)
            {
                throw new InvalidOperationException($"Target block with of type {typeof(TBlockTarget).Name} not found");
            }

            foreach (var source in this._sourceIds)
            {
                var sourceBlock = this.GetBlock(source);
                if (sourceBlock == null)
                {
                    throw new InvalidOperationException($"target block with id {source} not found");
                }

                this._recentLinks.Push(BlockLink.Link(sourceBlock, targetBlock));
            }

            return(this);
        }
示例#2
0
        public static BlockLink Link(BlockBase source, BlockBase target, ICondition condition = null)
        {
            if (source == null || target == null)
            {
                throw new ArgumentNullException();
            }
            if (source == target)
            {
                throw new ArgumentException("Cant link block to itself");
            }

            var link = new BlockLink(source, target, condition);

            source.AddLink(link);
            target.AddLink(link);

            return(link);
        }
        public IFlowBuilder To(string targetId)
        {
            this.ValidateInExisting(targetId);
            if (this._sourceIds == null || !this._sourceIds.Any())
            {
                throw new InvalidOperationException("Source block not set. Use Link() method before To()");
            }

            var targetBlock = this.GetBlock(targetId);

            foreach (var source in this._sourceIds)
            {
                var sourceBlock = this.GetBlock(source);
                if (sourceBlock == null)
                {
                    throw new InvalidOperationException($"target block with id {source} not found");
                }

                this._recentLinks.Push(BlockLink.Link(sourceBlock, targetBlock));
            }

            return(this);
        }