Example #1
0
        BlockStack MergeStacks(IBlock b1, IBlock b2)
        {
            BlockStack ret = new BlockStack();

            if ((b1 is BlockStack))
            {
                BlockStack bs1 = b1 as BlockStack;
                ret.AddRange(bs1);
            }
            else
            {
                // We need to remove b1 from its parent before adding it to the newly merged stack
                // otherwise consider such a scenario:
                // 1- We drag a stack block into an existing stackBlock in a C block
                // 2- 'b1' is the existing stackBlock, it is not added to ret, but is still an arg of the C block
                // 3- after merge is called, we'll try to set ret as the arg of the C block; the C will try
                // to remove the old arg (b1)...but it doesn't have C as a parent! exception thrown
                b1.ParentRelationship.Detach(this);
                ret.Add(b1);
            }
            if ((b2 is BlockStack))
            {
                BlockStack bs2 = b2 as BlockStack;
                ret.AddRange(bs2);
            }
            else
            {
                b2.ParentRelationship.Detach(this);
                ret.Add(b2);
            }
            return(ret);
        }
Example #2
0
        public IBlock DeepClone()
        {
            BlockStack ret = new BlockStack();

            foreach (IBlock block in Blocks)
            {
                ret.Add(block);
            }
            return(ret);
        }
Example #3
0
        private IBlock ToBlockStack(JToken json)
        {
            BlockStack b = new BlockStack();

            for (int i = 1; i < json.Count(); ++i)
            {
                IBlock subBlock = ToBlock(json[i]);
                if (i == 1 && subBlock is ProcDefBlock)
                {
                    currentProcDef = subBlock as ProcDefBlock;
                }
                b.Add(subBlock);
            }
            currentProcDef = null;
            return(b);
        }