예제 #1
0
        /// <summary>
        /// Creates the node structure.
        /// </summary>
        /// <returns>The node.</returns>
        internal Node CreateNodes()
        {
            var node = new Node(ActionCommand.ACTION_BLOCK_CHILD_NODE);

            if (blockType != ActionBlockType.Default)
            {
                node.Tag = ActionBlockTypeHelper.ToString(blockType);
            }
            if (type != ActionBlockUsageType.Press)
            {
                node.Attributes.Add(TYPE_ATTRIBUTE, ActionBlockUsageTypeHelper.ToString(type));
            }
            foreach (Action action in this)
            {
                node.Children.AddLast(action.CreateNodes());
            }
            return(node);
        }
예제 #2
0
        /// <summary>
        /// Creates a new ActionBlock.
        /// </summary>
        /// <param name="validator">The validator to use for validation.</param>
        /// <param name="node">The "actionblock" node.</param>
        internal ActionBlock(NodeValidator validator, Node node)
            : base(validator, node)
        {
            if (!string.IsNullOrEmpty(node.Tag))
            {
                blockType = ActionBlockTypeHelper.TryParse(node.Tag);
            }
            if (node.Attributes.ContainsKey(TYPE_ATTRIBUTE))
            {
                type = ActionBlockUsageTypeHelper.TryParse(node.Attributes[TYPE_ATTRIBUTE]);
            }

            foreach (var child in node.Children)
            {
                if (child.Name.ToUpperInvariant() == ACTION_CHILD_NODE)
                {
                    Add(new Action(validator, child));
                }
            }
        }