Exemplo n.º 1
0
        public Hierarchy Named(out Hierarchy element)
        {
            Hierarchy last = Children.Count > 0 ? Children[Children.Count - 1] : this;
            if (last == null)
            {
                throw new InvalidOperationException("You must add a Hierarchy element before calling Named!");
            }

            element = last;
            return this;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add a new child to the hierarchy that will contain its own children.
 /// </summary>
 /// <param name="element">The element name.</param>
 /// <returns>A Hierarchy object to continue construction.</returns>
 public Hierarchy Items(string element)
 {
     Hierarchy item = new Hierarchy { Element = element, Parent = this };
     Children.Add(item);
     return item;
 }