/// <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); }
/// <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); }