Exemplo n.º 1
0
        /// <summary>
        /// Closes a block at the specified index.
        /// </summary>
        /// <param name="index">The index.</param>
        private void Close(int index)
        {
            var block = OpenedBlocks[index];

            // If the pending object is removed, we need to remove it from the parent container
            if (block.Parser != null)
            {
                if (!block.Parser.Close(this, block))
                {
                    block.Parent?.Remove(block);

                    if (block is LeafBlock leaf)
                    {
                        leaf.Lines.Release();
                    }
                }
                else
                {
                    // Invoke the Closed event
                    var blockClosed = block.Parser.GetClosedEvent;
                    blockClosed?.Invoke(this, block);
                }
            }
            OpenedBlocks.RemoveAt(index);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Discards the specified block from the stack, remove from its parent.
 /// </summary>
 /// <param name="block">The block.</param>
 public void Discard(Block block)
 {
     for (int i = OpenedBlocks.Count - 1; i >= 1; i--)
     {
         if (OpenedBlocks[i] == block)
         {
             block.Parent.Remove(block);
             OpenedBlocks.RemoveAt(i);
             break;
         }
     }
 }