Ejemplo n.º 1
0
        /// <summary>
        /// Add a child to the current element builder.
        /// </summary>
        public ElementBuilder AddChild(string id, Element element, IAction <Element> onElement = null)
        {
            ArrayRig <ElementBuilder> builders;

            if (!MultiChildren.TryGetValue(id, out builders))
            {
                _multiChildren.Add(id, builders = new ArrayRig <ElementBuilder>());
            }
            var builder = new ElementBuilder();

            builders.Add(builder);
            builder.Action  = BuilderAction.Add;
            builder.Element = element;
            if (onElement != null)
            {
                builder._onBuilt = onElement;
            }
            return(builder);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add a child to the current element builder. The specified callback function will
        /// be called if an element cannot be found for the specified key.
        /// </summary>
        public ElementBuilder AddChild(string id, string key, IFunc <Element> getFallback, IAction <Element> onElement = null)
        {
            ArrayRig <ElementBuilder> builders;

            if (!MultiChildren.TryGetValue(id, out builders))
            {
                _multiChildren.Add(id, builders = new ArrayRig <ElementBuilder>());
            }
            var builder = new ElementBuilder();

            builders.Add(builder);
            builder.Action     = BuilderAction.Add;
            builder.GetElement = getFallback;
            builder.Key        = key;
            if (onElement != null)
            {
                builder._onBuilt = onElement;
            }
            return(builder);
        }