Ejemplo n.º 1
0
        /// <summary>
        /// Creates the node structure.
        /// </summary>
        /// <returns>The node.</returns>
        internal Node CreateNodes()
        {
            var node = new Node(ControllerList.CONTROLLER_CHILD_NODE);

            if (uuid != null)
            {
                node.Tag = uuid.ToString();
            }
            node.Attributes.Add(GROUP_ATTRIBUTE, DeviceGroupHelper.ToString(group));

            // *.pr0 files have the first member as the first node and the others listed at the end of the node list.
            if (members.Count > 0)
            {
                node.Children.AddLast(members.First.Value.CreateNodes());
            }

            node.Children.AddLast(controls.CreateNodes());
            node.Children.AddLast(shifts.CreateNodes());

            if (members.Count > 1)
            {
                LinkedList <Member> .Enumerator enumerator = members.GetEnumerator();
                enumerator.MoveNext();
                while (enumerator.MoveNext())
                {
                    node.Children.AddLast(enumerator.Current.CreateNodes());
                }
            }
            return(node);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new controller from the given node.
        /// </summary>
        /// <param name="validator">The validator to use for validation.</param>
        /// <param name="node">The controller node.</param>
        internal Controller(NodeValidator validator, Node node)
            : base(validator, node)
        {
            if (!string.IsNullOrEmpty(node.Tag))
            {
                uuid = new Guid(node.Tag);
            }
            if (node.Attributes.ContainsKey(GROUP_ATTRIBUTE))
            {
                group = DeviceGroupHelper.TryParse(node.Attributes[GROUP_ATTRIBUTE]);
            }

            foreach (var child in node.Children)
            {
                switch (child.Name.ToUpperInvariant())
                {
                case MEMBER_CHILD_NODE:
                    members.AddLast(new Member(validator, child));
                    break;

                case CONTROLS_CHILD_NODE:
                    controls = new ControlList(validator, child);
                    break;

                case SHIFTS_CHILD_NODE:
                    shifts = new ShiftList(validator, child);
                    break;
                }
            }
        }