protected override void BuildRenderTree(RenderTreeBuilder builder) { base.BuildRenderTree(builder); builder.OpenComponent <CascadingValue <FluentBase> >(0); builder.AddAttribute(1, "Name", "FluentParent"); builder.AddAttribute(2, "Value", this); builder.AddAttribute(3, "ChildContent", (RenderFragment)(builder2 => { if (FluentParent == null) { builder2.OpenElement(4, "div"); builder2.AddAttribute(5, "id", id); builder2.AddAttribute(6, "style", "display:none;"); if (this is IHasChildren) { builder2.AddContent(7, (this as IHasChildren).ChildContent); } else if (this is IHasTextContent) { builder2.AddContent(7, (this as IHasTextContent).ChildContent); builder2.AddElementReferenceCapture(8, elementRef => (this as IHasTextContent).TextContainingReference = elementRef); } builder2.CloseElement(); } else { ////Create react component on parent. SelfChild = FluentParent.CreateReactChildComponent(this, FluentComponentAttributes, GetSerializedEvents(), FluentParent.SelfChild); builder2.OpenElement(4, "div"); if (this is IHasChildren) { builder2.AddContent(5, (this as IHasChildren).ChildContent); } else if (this is IHasTextContent) { builder2.AddContent(5, (this as IHasTextContent).ChildContent); builder2.AddElementReferenceCapture(6, elementRef => { (this as IHasTextContent).TextContainingReference = elementRef; }); } builder2.CloseElement(); } })); builder.CloseComponent(); }
public ReactChild CreateReactChildComponent(FluentBase self, Dictionary <string, object> childParameters, IEnumerable <SerializedEvent> childEvents, ReactChild parent = null) { ReactChild child = null; if (parent == null) { child = new ReactChild(self) { componentName = (string)childParameters["componentName"], parameters = childParameters, serializedEvents = childEvents }; reactChildren.Add(child); } else { child = new ReactChild(self) { componentName = (string)childParameters["componentName"], parameters = childParameters, serializedEvents = childEvents }; parent.children.Add(child); } return(child); }