Esempio n. 1
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            if (Type is null)
            {
                return;
            }

            switch (TypeKind)
            {
            case TypeKind.Scalar:
            case TypeKind.Object:
                builder.OpenComponent <ValueEditor>(0);
                builder.AddAttribute(1, nameof(TypeKind), TypeKind);
                builder.AddAttribute(2, nameof(Type), Type);
                builder.AddComponentReferenceCapture(3, obj => editor = (EditorBase)obj);
                builder.CloseComponent();
                break;

            case TypeKind.List:
                builder.OpenComponent <ListTypeEditor>(0);
                builder.AddAttribute(1, nameof(TypeKind), TypeKind);
                builder.AddAttribute(2, nameof(Type), Type);
                builder.AddComponentReferenceCapture(3, obj => editor = (EditorBase)obj);
                builder.CloseComponent();
                break;

            case TypeKind.Any:
                builder.OpenComponent <RawEditor>(0);
                builder.AddAttribute(1, nameof(TypeKind), TypeKind);
                builder.AddAttribute(2, nameof(Type), Type);
                builder.AddComponentReferenceCapture(3, obj => editor = (EditorBase)obj);
                builder.CloseComponent();
                break;

            case TypeKind.Unit:
                builder.AddContent(0, "<not required>");
                break;

            default:
                //throw new NotImplementedException();
                builder.OpenElement(0, "div");
                builder.AddAttribute(1, "class", "flex flex-col");
                builder.AddMarkupContent(2, @$ "<span class=" "text-red-600 font-bold" ">{TypeKind}</span><span class=" "text-red-600 font-bold" ">{Type}</span>");
                builder.OpenComponent <RawEditor>(3);
                builder.AddAttribute(4, nameof(TypeKind), TypeKind);
                builder.AddAttribute(5, nameof(Type), Type);
                builder.AddComponentReferenceCapture(6, obj => editor = (EditorBase)obj);
                builder.CloseComponent();
                builder.CloseElement();
                break;
            }

            base.BuildRenderTree(builder);
        }
Esempio n. 2
0
        /// <inheritdoc />
        protected override void BuildRenderInput(RenderTreeBuilder builder)
        {
            LabelType labelTypeEffective = (this as IInputWithLabelType).LabelTypeEffective;

            builder.OpenComponent <HxInputTagsInternal>(1);
            builder.AddAttribute(1000, nameof(HxInputTagsInternal.Value), Value);
            builder.AddAttribute(1001, nameof(HxInputTagsInternal.ValueChanged), EventCallback.Factory.Create <List <string> >(this, HandleValueChanged));
            builder.AddAttribute(1002, nameof(HxInputTagsInternal.DataProvider), DataProvider);
            builder.AddAttribute(1005, nameof(HxInputTagsInternal.SuggestMinimumLengthEffective), SuggestMinimumLengthEffective);
            builder.AddAttribute(1006, nameof(HxInputTagsInternal.SuggestDelayEffective), SuggestDelayEffective);
            builder.AddAttribute(1007, nameof(HxInputTagsInternal.InputId), InputId);
            builder.AddAttribute(1008, nameof(HxInputTagsInternal.CoreFormControlCssClass), GetInputCssClassToRender());             // we want to shift original input-classes to the wrapping .form-control container
            builder.AddAttribute(1009, nameof(HxInputTagsInternal.EnabledEffective), EnabledEffective);
            builder.AddAttribute(1011, nameof(HxInputTagsInternal.Placeholder), (labelTypeEffective == Havit.Blazor.Components.Web.Bootstrap.LabelType.Floating) ? "placeholder" : Placeholder);
            builder.AddAttribute(1012, nameof(HxInputTagsInternal.LabelTypeEffective), labelTypeEffective);
            builder.AddAttribute(1013, nameof(HxInputTagsInternal.AllowCustomTags), AllowCustomTags);
            builder.AddAttribute(1014, nameof(HxInputTagsInternal.DelimitersEffective), DelimitersEffective);
            builder.AddAttribute(1015, nameof(HxInputTagsInternal.InputSizeEffective), ((IInputWithSize)this).InputSizeEffective);
            builder.AddAttribute(1016, nameof(HxInputTagsInternal.ShowAddButtonEffective), ShowAddButtonEffective);
            builder.AddAttribute(1017, nameof(HxInputTagsInternal.Naked), Naked);
            builder.AddAttribute(1018, nameof(HxInputTagsInternal.CssClass), CssClassHelper.Combine(this.CssClass, IsValueInvalid() ? InvalidCssClass : null));
            builder.AddAttribute(1019, nameof(HxInputTagsInternal.AddButtonText), this.AddButtonText);
            builder.AddAttribute(1020, nameof(HxInputTagsInternal.TagBadgeSettingsEffective), this.TagBadgeSettingsEffective);
            builder.AddAttribute(1021, nameof(HxInputTagsInternal.InputGroupStartText), this.InputGroupStartText);
            builder.AddAttribute(1022, nameof(HxInputTagsInternal.InputGroupEndText), this.InputGroupEndText);
            builder.AddAttribute(1023, nameof(HxInputTagsInternal.InputGroupStartTemplate), this.InputGroupStartTemplate);
            builder.AddAttribute(1024, nameof(HxInputTagsInternal.InputGroupEndTemplate), this.InputGroupEndTemplate);
            builder.AddAttribute(1025, nameof(HxInputTagsInternal.InputGroupCssClass), this.InputGroupCssClass);

            builder.AddMultipleAttributes(1090, this.AdditionalAttributes);

            builder.AddComponentReferenceCapture(1100, component => hxInputTagsInternalComponent = (HxInputTagsInternal)component);
            builder.CloseComponent();
        }
Esempio n. 3
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            base.BuildRenderTree(builder);

            List <RenderFragment> containerChildContents = new List <RenderFragment>();
            int line = 0;

            foreach (var group in Items.GroupBy(x => x.Name.ToUpperInvariant().FirstOrDefault()))
            {
                builder.OpenComponent <Container>(line++);
                builder.AddAttribute(line++, "class", "mb-4 bg-dark");
                RenderInput <TItem> containerInput = new RenderInput <TItem>()
                {
                    line = 0, OriginalBuilder = builder, InputItems = group
                };

                builder.AddAttribute(line++, "ChildContent", ChildRender(containerInput));

                builder.AddComponentReferenceCapture(line++, (refCapture) =>
                {
                    ListSectionWrappers[group.Key] = (Container)refCapture;
                });

                builder.CloseComponent();
            }
        }
Esempio n. 4
0
        public void Render(RenderTreeBuilder renderTreeBuilder, RenderConfig config)
        {
            List <KeyValueModel> tableDataSource = new List <KeyValueModel>();
            var attributeConfig = (TableAttribute)config.ControlAttribute;

            renderTreeBuilder.OpenComponent(0, config.InputControlType);
            renderTreeBuilder.AddAttribute(1, nameof(BFormItemObject.EnableAlwaysRender), true);
            renderTreeBuilder.AddAttribute(2, nameof(BTable.AutoGenerateColumns), true);
            renderTreeBuilder.AddAttribute(3, nameof(BTable.DataType), typeof(KeyValueModel));
            if (attributeConfig != null)
            {
                renderTreeBuilder.AddAttribute(4, nameof(BTable.Height), attributeConfig.Height);
                renderTreeBuilder.AddAttribute(5, nameof(BTable.IsEditable), attributeConfig.IsEditable);
                if (attributeConfig.IsEditable)
                {
                    renderTreeBuilder.AddAttribute(6, nameof(BTable.DataType), typeof(KeyValueModel));
                    if (config.Page == null)
                    {
                        ExceptionHelper.Throw(ExceptionHelper.CascadingValueNotFound, "表格启用可编辑功能后必须在外面套一层 CascadingValue,值为 this,名称为 Page");
                    }
                    renderTreeBuilder.AddAttribute(7, nameof(BTable.OnSave), EventCallback.Factory.Create <TableSaveEventArgs>(config.Page, DefaultSaverAsync));
                }
            }
            renderTreeBuilder.AddAttribute(8, nameof(BTable.DataSourceChanged), EventCallback.Factory.Create <object>(this, dataSource =>
            {
                tableDataSource     = (List <KeyValueModel>)dataSource;
                config.EditingValue = dataSource;
            }));
            renderTreeBuilder.AddAttribute(9, nameof(BTable.DataSource), tableDataSource);
            renderTreeBuilder.AddComponentReferenceCapture(10, table => currentTable = (BTable)table);
            renderTreeBuilder.CloseComponent();
        }
Esempio n. 5
0
 protected override void BuildRenderTree(RenderTreeBuilder builder)
 {
     if (builder != null)
     {
         var seq = 0;
         builder.OpenElement(seq++, "div");
         builder.AddMultipleAttributes(seq++, AdditionalAttributes);
         builder.AddAttribute(seq++, "class", GetBaseClassAttributes());
         if (Value != null && Value.Length > 0)
         {
             foreach (var endorsement in Value)
             {
                 seq = BuildRenderTreeForEndorsement(builder, seq, endorsement);
             }
         }
         builder.OpenElement(seq++, "button");
         builder.AddAttribute(seq++, "class", "add-key");
         builder.AddAttribute(seq++, "title", "Add First Key");
         builder.AddAttribute(seq++, "type", "button");
         builder.AddAttribute(seq++, "onclick", EventCallback.Factory.Create <MouseEventArgs>(this, () => AddNewKeyToRootList()));
         builder.CloseElement();
         if (!string.IsNullOrWhiteSpace(Placeholder) && (Value == null || Value.Length == 0))
         {
             builder.OpenElement(seq++, "span");
             builder.AddAttribute(seq++, "class", "placeholder");
             builder.AddContent(seq++, Placeholder.Trim());
             builder.CloseElement();
         }
         builder.CloseElement();
         builder.OpenComponent <InputPublicKeyDialog>(seq++);
         builder.AddComponentReferenceCapture(seq++, (__value) => { InputPublicKeyDialog = (InputPublicKeyDialog)__value; });
         builder.CloseComponent();
     }
 }
Esempio n. 6
0
    /// <inheritdoc/>
    protected override void BuildRenderInput(RenderTreeBuilder builder)
    {
        RefreshState();

        builder.OpenComponent <HxMultiSelectInternal <TValue, TItem> >(100);
        builder.AddAttribute(101, nameof(HxMultiSelectInternal <TValue, TItem> .InputId), InputId);
        builder.AddAttribute(102, nameof(HxMultiSelectInternal <TValue, TItem> .InputCssClass), GetInputCssClassToRender());
        builder.AddAttribute(103, nameof(HxMultiSelectInternal <TValue, TItem> .InputText), CurrentValueAsString);
        builder.AddAttribute(104, nameof(HxMultiSelectInternal <TValue, TItem> .EnabledEffective), EnabledEffective);
        builder.AddAttribute(105, nameof(HxMultiSelectInternal <TValue, TItem> .ItemsToRender), itemsToRender);
        builder.AddAttribute(106, nameof(HxMultiSelectInternal <TValue, TItem> .TextSelector), TextSelector);
        builder.AddAttribute(107, nameof(HxMultiSelectInternal <TValue, TItem> .ValueSelector), ValueSelector);
        builder.AddAttribute(108, nameof(HxMultiSelectInternal <TValue, TItem> .Value), Value);
        builder.AddAttribute(109, nameof(HxMultiSelectInternal <TValue, TItem> .NullDataText), NullDataText);
        builder.AddAttribute(110, nameof(HxMultiSelectInternal <TValue, TItem> .ItemSelectionChanged), EventCallback.Factory.Create <HxMultiSelectInternal <TValue, TItem> .SelectionChangedArgs>(this, args => HandleItemSelectionChanged(args.Checked, args.Item)));
        builder.AddAttribute(111, nameof(HxMultiSelectInternal <TValue, TItem> .InputGroupStartText), InputGroupStartText);
        builder.AddAttribute(112, nameof(HxMultiSelectInternal <TValue, TItem> .InputGroupStartTemplate), InputGroupStartTemplate);
        builder.AddAttribute(113, nameof(HxMultiSelectInternal <TValue, TItem> .InputGroupEndText), InputGroupEndText);
        builder.AddAttribute(114, nameof(HxMultiSelectInternal <TValue, TItem> .InputGroupEndTemplate), InputGroupEndTemplate);

        builder.AddMultipleAttributes(200, this.AdditionalAttributes);

        builder.AddComponentReferenceCapture(111, r => hxMultiSelectInternalComponent = (HxMultiSelectInternal <TValue, TItem>)r);

        builder.CloseComponent();
    }
Esempio n. 7
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            base.BuildRenderTree(builder);

            var name = View?.GetType().Name ?? "null";

            builder.OpenElement(0, "div");
            builder.AddAttribute(1, "class", $"comet-view comet-view-{name}");

            if (View is null)
            {
                builder.OpenElement(2, "div");
                builder.AddAttribute(3, "class", "alert alert-danger");
                builder.AddAttribute(4, "role", "alert");
                builder.AddMarkupContent(5, "View cannot be null.");
                builder.CloseElement();
            }
            else if (View.GetOrCreateViewHandler() is IBlazorViewHandler handler)
            {
                builder.OpenComponent(6, handler.ComponentType);
                builder.SetKey(handler);
                builder.AddComponentReferenceCapture(7, handler.OnComponentLoad);
                builder.CloseComponent();
            }
            else
            {
                builder.OpenElement(8, "div");
                builder.AddAttribute(9, "class", "alert alert-danger");
                builder.AddAttribute(10, "role", "alert");
                builder.AddMarkupContent(11, $"Invalid view handler: <b>{View.GetType()}</b>");
                builder.CloseElement();
            }

            builder.CloseElement();
        }
Esempio n. 8
0
 protected override void BuildRenderTree(RenderTreeBuilder builder)
 {
     builder.OpenElement("div");
     builder.AddAttribute("hg-input-endorsement-list");
     builder.AddMultipleAttributes(AdditionalAttributes);
     if (Value is not null && Value.Length > 0)
     {
         builder.OpenRegion();
         for (int i = 0; i < Value.Length; i++)
         {
             builder.OpenRegion(i);
             BuildRenderTreeForEndorsement(builder, Value[i]);
             builder.CloseRegion();
         }
         builder.CloseRegion();
     }
     builder.OpenElement("button");
     builder.AddAttribute("hg-add-key");
     builder.AddAttribute("title", "Add First Key");
     builder.AddAttribute("type", "button");
     builder.AddAttribute("onclick", EventCallback.Factory.Create <MouseEventArgs>(this, () => AddNewKeyToRootList()));
     builder.CloseElement();
     if (!string.IsNullOrWhiteSpace(Placeholder) && (Value is null || Value.Length == 0))
     {
         builder.OpenElement("span");
         builder.AddAttribute("hg-placeholder");
         builder.AddContent(Placeholder.Trim());
         builder.CloseElement();
     }
     builder.CloseElement();
     builder.OpenComponent <InputPublicKeyDialog>();
     builder.AddComponentReferenceCapture((__value) => { InputPublicKeyDialog = (InputPublicKeyDialog)__value; });
     builder.CloseComponent();
 }
Esempio n. 9
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            //EnabledRender = false;

            base.BuildRenderTree(builder);

            if (bvgColumn.PropertyChanged == null)
            {
                bvgColumn.PropertyChanged = BvgColumn_PropertyChanged;
            }

            int k = -1;

            builder.OpenElement(k++, "th");
            builder.AddAttribute(k++, "class", bvgColumn.CssClass);



            builder.OpenElement(k++, "div");
            builder.AddAttribute(k++, "id", "divCol" + bvgColumn.ID);
            builder.AddAttribute(k++, "class", "ColumnDiv");
            builder.AddAttribute(k++, "style", string.Concat("width:", bvgColumn.ColWidthDiv, "px"));


            builder.OpenElement(k++, "div"); //to arrange text in center
            builder.AddAttribute(k++, "style", string.Concat("width:", (bvgColumn.bvgGrid.bvgSettings.bSortStyle.width + 5), "px"));
            builder.CloseElement();          //div

            builder.OpenElement(k++, "span");
            builder.AddAttribute(k++, "id", "spCol" + bvgColumn.ID);
            builder.AddAttribute(k++, "class", "ColumnSpan");
            builder.AddAttribute(k++, "style", string.Concat("width:", bvgColumn.ColWidthSpan, "px"));
            builder.AddAttribute(k++, "onmousedown", Clicked);
            builder.AddContent(k++, bvgColumn.prop.Name);
            builder.CloseElement(); //span


            builder.OpenComponent <CompSort>(k++);
            builder.AddAttribute(k++, "bvgColumn", bvgColumn);
            builder.AddAttribute(k++, "IsNotHidden", bvgColumn.IsSorted);
            builder.CloseComponent();



            builder.OpenComponent <CompBlazorSplitter>(k++);
            builder.AddAttribute(k++, "bsSettings", bvgColumn.bsSettings);
            builder.AddAttribute(k++, "OnPositionChange", new Action <bool, int, int>(OnPositionChange));
            builder.AddComponentReferenceCapture(k++, (c) =>
            {
                bvgColumn.BSplitter = c as CompBlazorSplitter;
            });
            builder.CloseComponent();


            builder.CloseElement(); //div


            builder.CloseElement(); //th
        }
Esempio n. 10
0
        public void CannotAddComponentReferenceCaptureWithNoParent()
        {
            // Arrange
            var builder = new RenderTreeBuilder(new TestRenderer());

            // Act/Assert
            Assert.Throws <InvalidOperationException>(() =>
            {
                builder.AddComponentReferenceCapture(0, _ => { });
            });
        }
Esempio n. 11
0
        public void CannotAddComponentReferenceCaptureInsideRegion()
        {
            // Arrange
            var builder = new RenderTreeBuilder(new TestRenderer());

            // Act/Assert
            Assert.Throws <InvalidOperationException>(() =>
            {
                builder.OpenRegion(0);
                builder.AddComponentReferenceCapture(1, _ => { });
            });
        }
Esempio n. 12
0
        public void CannotAddAttributeToComponentReferenceCapture()
        {
            // Arrange
            var builder = new RenderTreeBuilder(new TestRenderer());

            // Act/Assert
            Assert.Throws <InvalidOperationException>(() =>
            {
                builder.OpenComponent <TestComponent>(0);
                builder.AddComponentReferenceCapture(1, _ => { });
                builder.AddAttribute(2, "name", "value");
            });
        }
 protected override void BuildRenderTree(RenderTreeBuilder builder)
 {
     if (Value.IsNullOrNone())
     {
         builder.OpenElement("div");
         builder.AddAttribute("hg-input-endorsement");
         builder.AddAttribute("hg-none");
         builder.AddMultipleAttributes(AdditionalAttributes);
         builder.OpenElement("button");
         builder.AddAttribute("hg-add-key");
         builder.AddAttribute("title", "Add First Key");
         builder.AddAttribute("type", "button");
         builder.AddAttribute("onclick", EventCallback.Factory.Create <MouseEventArgs>(this, () => AddNewKeyToTree(Value)));
         builder.CloseElement();
         if (!string.IsNullOrWhiteSpace(Placeholder))
         {
             builder.OpenElement("span");
             builder.AddAttribute("hg-placeholder");
             builder.AddContent(Placeholder.Trim());
             builder.CloseElement();
         }
         builder.CloseElement();
     }
     else
     {
         builder.OpenElement("div");
         builder.AddAttribute("hg-input-endorsement");
         builder.AddMultipleAttributes(AdditionalAttributes);
         if (Value.Type == KeyType.List)
         {
             builder.OpenRegion();
             BuildRenderTreeForList(builder, Value);
             builder.CloseRegion();
         }
         else
         {
             builder.OpenElement("div");
             builder.AddAttribute("hg-input-endorsement-public-key");
             builder.OpenRegion();
             BuildRenderTreeForKey(builder, Value);
             builder.CloseRegion();
             builder.CloseElement();
         }
         builder.CloseElement();
     }
     builder.OpenComponent <InputPublicKeyDialog>();
     builder.AddComponentReferenceCapture((__value) => { InputPublicKeyDialog = (InputPublicKeyDialog)__value; });
     builder.CloseComponent();
 }
Esempio n. 14
0
        public void CanAddMultipleReferenceCapturesToSameComponent()
        {
            // There won't be any way of doing this from Razor because there's no known use
            // case for it. However it's harder to *not* support it than to support it, and
            // there's no known reason to prevent it, so here's test coverage to show it
            // just works.

            // Arrange
            var             builder = new RenderTreeBuilder(new TestRenderer());
            Action <object> referenceCaptureAction1 = elementRef => { };
            Action <object> referenceCaptureAction2 = elementRef => { };

            // Act
            builder.OpenComponent <TestComponent>(0);
            builder.AddComponentReferenceCapture(0, referenceCaptureAction1);
            builder.AddComponentReferenceCapture(0, referenceCaptureAction2);
            builder.CloseComponent();

            // Assert
            Assert.Collection(builder.GetFrames(),
                              frame => AssertFrame.Component <TestComponent>(frame, 3),
                              frame => AssertFrame.ComponentReferenceCapture(frame, referenceCaptureAction1),
                              frame => AssertFrame.ComponentReferenceCapture(frame, referenceCaptureAction2));
        }
        private void BuilderComponent(RenderTreeBuilder builder)
        {
            var gridAux = AppDataTransfer.Result as GridGenericView;

            if (gridAux == null)
            {
                Toast.ShowInfo("Erro ao carregar a entidade!");
                return;
            }
            var  seq     = 0;
            Type generic = typeof(OXGrid <>);

            Type[] typeArgs    = { gridAux.Model };
            Type   constructed = generic.MakeGenericType(typeArgs);

            viewEdit = TypeHelper.CreateInstance(gridAux.View);
            oxGrid   = TypeHelper.CreateInstance(constructed);
            var grid = TypeHelper.ConvertTo(oxGrid, constructed);

            //create layout

            builder.AddAttribute(seq++, "ChildContent", (RenderFragment)((builder2) =>
            {
                builder2.AddMarkupContent(seq++, "\r\n        ");
                builder2.OpenComponent <OXPanel>(3);
                builder2.AddAttribute(seq++, "Title", gridAux.Caption);
                builder2.AddAttribute(seq++, "SubTitle", gridAux.Descricao);
                builder2.AddAttribute(seq++, "ChildContent", (RenderFragment)((builder3) =>
                {
                    RenderGrid(builder3, seq);
                }));
                builder2.CloseComponent();
            }));
            builder.CloseComponent();
            builder.AddMarkupContent(seq++, "\r\n");

            var viewComp = viewEdit.GetType();

            builder.OpenComponent(seq++, viewComp);
            builder.AddAttribute(seq++, "Caption", gridAux.Caption);
            builder.AddAttribute(seq++, "GridView", grid);
            builder.AddComponentReferenceCapture(seq++, (value) =>
            {
                var getRef = TypeHelper.ConvertTo(value, gridAux.View);
                viewEdit   = getRef;
            });
            builder.CloseComponent();
        }
Esempio n. 16
0
 protected override void BuildRenderTree(RenderTreeBuilder builder)
 {
     if (builder != null)
     {
         var seq = 0;
         if (Value == null)
         {
             builder.OpenElement(seq++, "div");
             builder.AddMultipleAttributes(seq++, AdditionalAttributes);
             builder.AddAttribute(seq++, "class", $"{GetBaseClassAttributes()} empty");
             builder.OpenElement(seq++, "button");
             builder.AddAttribute(seq++, "class", "add-key");
             builder.AddAttribute(seq++, "title", "Add First Key");
             builder.AddAttribute(seq++, "type", "button");
             builder.AddAttribute(seq++, "onclick", EventCallback.Factory.Create <MouseEventArgs>(this, () => AddNewKeyToTree(Value)));
             builder.CloseElement();
             if (!string.IsNullOrWhiteSpace(Placeholder))
             {
                 builder.OpenElement(seq++, "span");
                 builder.AddAttribute(seq++, "class", "placeholder");
                 builder.AddContent(seq++, Placeholder.Trim());
                 builder.CloseElement();
             }
             builder.CloseElement();
         }
         else
         {
             builder.OpenElement(seq++, "div");
             builder.AddMultipleAttributes(seq++, AdditionalAttributes);
             builder.AddAttribute(seq++, "class", GetBaseClassAttributes());
             if (Value.Type == KeyType.List)
             {
                 seq = BuildRenderTreeForList(builder, seq, Value);
             }
             else
             {
                 builder.OpenElement(seq++, "div");
                 builder.AddAttribute(seq++, "class", "public-key");
                 seq = BuildRenderTreeForKey(builder, seq, Value);
                 builder.CloseElement();
             }
             builder.CloseElement();
         }
         builder.OpenComponent <InputPublicKeyDialog>(seq++);
         builder.AddComponentReferenceCapture(seq++, (__value) => { InputPublicKeyDialog = (InputPublicKeyDialog)__value; });
         builder.CloseComponent();
     }
 }
Esempio n. 17
0
    void Render(RenderTreeBuilder builder)
    {
        builder.OpenComponent(0, Type);

        if (Parameters != null)
        {
            foreach (var entry in Parameters)
            {
                builder.AddAttribute(1, entry.Key, entry.Value);
            }
        }

        builder.AddComponentReferenceCapture(2, component => Instance = component);

        builder.CloseComponent();
    }
Esempio n. 18
0
 protected override void BuildRenderTree(RenderTreeBuilder builder)
 {
     if (_Items != null)
     {
         var i = 0;
         foreach (var e in _Items)
         {
             builder.OpenComponent(++i, typeof(ContentPresenter));
             builder.AddAttribute(++i, nameof(ContentPresenter.ViewType), e.ViewType);
             builder.AddAttribute(++i, nameof(ContentPresenter.Attributes), e.Attributes);
             builder.AddComponentReferenceCapture(++i, o => e.View = o as ComponentBase);
             builder.SetKey(e.GetHashCode());
             builder.CloseComponent();
         }
     }
 }
Esempio n. 19
0
        /// <inheritdoc/>
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            if (Type == null)
            {
                BuildFallbackComponent(builder);
                return;
            }

            builder.OpenComponent(0, Type);
            builder.AddMultipleAttributes(0, Parameters);
            builder.AddComponentReferenceCapture(1, (componentRef) =>
            {
                Instance = (IComponent)componentRef;
                OnAfterLoad?.Invoke(this);
            });
            builder.CloseComponent();
        }
Esempio n. 20
0
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            //EnabledRender = false;

            base.BuildRenderTree(builder);


            int k = -1;

            builder.OpenComponent <CompBlazorScrollbar>(k++);
            builder.AddAttribute(k++, "bsbSettings", RuntimeHelpers.TypeCheck <BsbSettings>(bvgScroll.bsbSettings));
            builder.AddAttribute(k++, "OnPositionChange", new Action <double>(onscroll));
            builder.AddComponentReferenceCapture(k++, (c) =>
            {
                bvgScroll.compBlazorScrollbar = c as CompBlazorScrollbar;
            });

            builder.CloseComponent();
        }
        private void RenderGrid(RenderTreeBuilder builder, int seq)
        {
            var constructed = oxGrid.GetType();

            builder.AddMarkupContent(seq++, "\r\n            ");
            builder.OpenComponent(seq++, constructed);
            builder.AddAttribute(seq++, "AllowButtons", RuntimeHelpers.TypeCheck <System.Boolean>(true));
            builder.AddAttribute(seq++, "AllowPrint", RuntimeHelpers.TypeCheck <System.Boolean>(true));
            builder.AddAttribute(seq++, "OnAdd", RuntimeHelpers.TypeCheck(EventCallback.Factory.Create(this, (value) => viewEdit.ShowDialog(null, OxActionModel.New))));
            builder.AddAttribute(seq++, "OnEdit", RuntimeHelpers.TypeCheck(EventCallback.Factory.Create(this, (value) => viewEdit.ShowDialog(value, OxActionModel.Edit))));
            builder.AddAttribute(seq++, "OnDelete", RuntimeHelpers.TypeCheck(EventCallback.Factory.Create(this, (value) => viewEdit.ShowDialog(value, OxActionModel.Delete))));
            builder.AddComponentReferenceCapture(seq++, (value) =>
            {
                var getRef = TypeHelper.ConvertTo(value, constructed);
                oxGrid     = getRef;
            });
            builder.CloseComponent();
            builder.AddMarkupContent(seq++, "\r\n        ");
        }
        protected override void BuildRenderTree(RenderTreeBuilder builder)
        {
            if (loaded == null)
            {
                builder.OpenElement(1, "p");
                builder.AddContent(2, "Loading....");
                builder.CloseElement();
                return;
            }



            builder.OpenComponent(0, type);
            builder.AddMultipleAttributes(0, Parameters);
            builder.AddComponentReferenceCapture(1, (componentRef) =>
            {
                Instance = (IComponent)componentRef;
            });
            builder.CloseComponent();
        }
Esempio n. 23
0
        public void CanAddComponentReferenceCaptureInsideComponent()
        {
            // Arrange
            var             builder  = new RenderTreeBuilder(new TestRenderer());
            Action <object> myAction = elementRef => { };

            // Act
            builder.OpenComponent <TestComponent>(0);               //  0: <TestComponent
            builder.AddAttribute(1, "attribute2", 123);             //  1:     attribute2=intExpression123>
            builder.AddComponentReferenceCapture(2, myAction);      //  2:     # capture: myAction
            builder.AddContent(3, "some text");                     //  3:     some text
            builder.CloseComponent();                               //     </TestComponent>

            // Assert
            Assert.Collection(builder.GetFrames(),
                              frame => AssertFrame.Component <TestComponent>(frame, 4, 0),
                              frame => AssertFrame.Attribute(frame, "attribute2", 123, 1),
                              frame => AssertFrame.ComponentReferenceCapture(frame, myAction, 2),
                              frame => AssertFrame.Text(frame, "some text", 3));
        }
Esempio n. 24
0
 protected override void BuildRenderTree(RenderTreeBuilder builder)
 {
     if (builder != null)
     {
         builder.OpenElement(0, "div");
         builder.AddMultipleAttributes(1, AdditionalAttributes);
         builder.AddAttribute(2, "class", $"gateway-node-selector {CssClass}");
         builder.AddAttribute(3, "onclick", EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, OnShowDialogAsync));
         if (Value == null)
         {
             builder.OpenElement(4, "span");
             builder.AddAttribute(5, "class", "empty");
             builder.AddContent(6, "Select Gateway");
             builder.CloseElement();
         }
         else
         {
             builder.OpenElement(8, "span");
             builder.OpenElement(9, "span");
             builder.AddAttribute(10, "class", "account-id");
             builder.AddContent(11, $"{Value.ShardNum}.{Value.RealmNum}.{Value.AccountNum}");
             builder.CloseElement();
             builder.OpenElement(12, "span");
             builder.AddAttribute(13, "class", "at");
             builder.AddContent(14, " at ");
             builder.CloseElement();
             builder.OpenElement(15, "span");
             builder.AddAttribute(16, "class", "node-url");
             builder.AddContent(17, Value.Url);
             builder.CloseElement();
             builder.CloseElement();
         }
         builder.CloseElement();
         builder.OpenComponent <SelectGatewayDialog>(17);
         builder.AddAttribute(18, "SelectedEventCallback", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck(EventCallback.Factory.Create <Gateway>(this, OnGatewaySelected)));
         builder.AddComponentReferenceCapture(19, (__value) => { SelectGatewayDialog = (SelectGatewayDialog)__value; });
         builder.CloseComponent();
     }
 }
Esempio n. 25
0
 protected override void BuildRenderTree(RenderTreeBuilder builder)
 {
     builder.OpenElement("div");
     builder.AddAttribute("hg-input-gateway");
     builder.AddMultipleAttributes(AdditionalAttributes);
     builder.AddAttribute("class", CssClass);
     builder.AddAttribute("onclick", EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this, OnShowDialogAsync));
     if (Value == null)
     {
         builder.OpenElement("span");
         builder.AddAttribute("hg-empty");
         builder.AddContent("Select Gateway");
         builder.CloseElement();
     }
     else
     {
         builder.OpenElement("span");
         builder.OpenElement("span");
         builder.AddAttribute("hg-account-id");
         builder.AddContent($"{Value.ShardNum}.{Value.RealmNum}.{Value.AccountNum}");
         builder.CloseElement();
         builder.OpenElement("span");
         builder.AddAttribute("hg-at");
         builder.AddContent(" at ");
         builder.CloseElement();
         builder.OpenElement("span");
         builder.AddAttribute("hg-node-url");
         builder.AddContent(Value.Url);
         builder.CloseElement();
         builder.CloseElement();
     }
     builder.CloseElement();
     builder.OpenComponent <SelectGatewayDialog>();
     builder.AddAttribute("SelectedEventCallback", Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck(EventCallback.Factory.Create <Gateway>(this, OnGatewaySelected)));
     builder.AddComponentReferenceCapture((__value) => { _selectGatewayDialog = (SelectGatewayDialog)__value; });
     builder.CloseComponent();
 }
Esempio n. 26
0
        private void AddEditRow <M>(RenderTreeBuilder pBuilder, MGridAction pAction, bool pIsFilterRow, M pValue)
        {
            var visibleColumns = ColumnsList.Where(c => c.ShouldRenderColumn).ToArray();

            AddInlineTrHeight(pBuilder);

            pBuilder.OpenElement(577, "td");
            pBuilder.AddAttribute(578, "colspan", visibleColumns.Length);

            pBuilder.OpenElement(580, "table");
            pBuilder.OpenElement(581, "tbody");
            pBuilder.OpenElement(582, "tr");

            {
                pBuilder.OpenComponent <MForm <M> >(53);
                pBuilder.AddAttribute(587, nameof(MForm <M> .Model), pValue);
                pBuilder.AddAttribute(588, nameof(MForm <M> .IsInTableRow), true);
                pBuilder.AddAttribute(589, nameof(MForm <M> .Fields), (RenderFragment)((builder3) =>
                {
                    AddInlineFormFields(builder3, visibleColumns, pIsFilterRow);
                }));

                pBuilder.AddAttribute(594, nameof(MForm <M> .MFormGridContext), new MFormGridContext()
                {
                    Action = pAction
                });

                if (pIsFilterRow)
                {
                    pBuilder.AddAttribute(601, nameof(MForm <M> .EnableValidation), false);
                    pBuilder.AddAttribute(602, "data-is-filterrow", true);

                    pBuilder.AddAttribute(604, nameof(MForm <M> .OnValueChanged),
                                          EventCallback.Factory.Create <MFormValueChangedArgs <ExpandoObject> >(this, OnFilterValueChanged));
                }
                else
                {
                    //T == M here

                    pBuilder.AddAttribute(611, nameof(MForm <T> .OnValidSubmit), EventCallback.Factory.Create <MFormSubmitArgs>(this, async(a) =>
                    {
                        await OnFormSubmit(a);
                    }));

                    pBuilder.AddAttribute(616, nameof(MForm <T> .OnValueChanged), EventCallback.Factory.Create <MFormValueChangedArgs <T> >(this, OnEditValueChanged));

                    pBuilder.AddComponentReferenceCapture(618, (__value) =>
                    {
                        EditForm = (MForm <T>)__value;
                    });
                }

                pBuilder.CloseComponent();
            }

            pBuilder.CloseElement(); //tr
            pBuilder.CloseElement(); //tbody
            pBuilder.CloseElement(); //table

            pBuilder.CloseElement(); //td
        }
Esempio n. 27
0
        public void Render(RenderTreeBuilder renderTreeBuilder, RenderConfig renderConfig)
        {
            var valueType      = renderConfig.Property.PropertyType;
            var nullValueType  = Nullable.GetUnderlyingType(valueType);
            var finalValueType = nullValueType ?? valueType;

            if (renderConfig.InputControlType.IsGenericTypeDefinition && !finalValueType.IsEnum)
            {
                throw new BlazuiException("下拉框生成只支持List或枚举类型");
            }
            else if (renderConfig.InputControlType.IsGenericTypeDefinition)
            {
                renderConfig.InputControlType = renderConfig.InputControlType.MakeGenericType(valueType);
            }
            renderTreeBuilder.OpenComponent(0, renderConfig.InputControlType);
            try
            {
                var selectAttr = renderConfig.Property.GetCustomAttribute <SelectAttribute>();
                if (selectAttr != null)
                {
                    var dataSource     = renderConfig.DataSource;
                    var dataSourceType = dataSource.GetType().GetGenericArguments()[0];
                    var valueProperty  = dataSourceType.GetProperty(selectAttr.Value);
                    var textProperty   = dataSourceType.GetProperty(selectAttr.Display);
                    renderTreeBuilder.AddAttribute(1, nameof(BSelect <string> .ChildContent), (RenderFragment)(builder =>
                    {
                        foreach (var item in dataSource as IEnumerable)
                        {
                            builder.OpenComponent(2, typeof(BSelectOption <>).MakeGenericType(valueProperty.PropertyType));
                            builder.AddAttribute(3, nameof(BSelectOption <string> .Value), valueProperty.GetValue(item));
                            builder.AddAttribute(4, nameof(BSelectOption <string> .Text), textProperty.GetValue(item));
                            builder.CloseComponent();
                        }
                    }));

                    CreateBind(renderConfig, renderTreeBuilder, 6);
                    renderTreeBuilder.AddComponentReferenceCapture(9, e => renderConfig.InputControl = e);
                    return;
                }
                if (!valueType.IsEnum)
                {
                    throw new BlazuiException("下拉框生成只支持List或枚举类型");
                }

                renderTreeBuilder.AddAttribute(6, nameof(BFormItemObject.ChildContent), (RenderFragment)(contentBuilder =>
                {
                    var names = Enum.GetNames(valueType);
                    for (int i = 0; i < names.Length; i++)
                    {
                        var name = names[i];
                        contentBuilder.OpenComponent(7, typeof(BSelectOption <>).MakeGenericType(renderConfig.Property.PropertyType));
                        var field = finalValueType.GetField(name);
                        var descAttr = field.GetCustomAttribute <DescriptionAttribute>();
                        var text = string.Empty;
                        if (descAttr != null)
                        {
                            text = descAttr.Description;
                        }
                        else
                        {
                            var displayAttr = field.GetCustomAttribute <DisplayAttribute>();
                            text = displayAttr?.Name ?? displayAttr?.Description;
                        }
                        contentBuilder.AddAttribute(8, nameof(BSelectOption <int> .Text), text ?? name);
                        contentBuilder.AddAttribute(9, nameof(BSelectOption <int> .Value), Enum.Parse(valueType, name));
                        contentBuilder.CloseComponent();
                    }
                }));
                renderTreeBuilder.AddAttribute(10, nameof(BFormItemObject.EnableAlwaysRender), true);
                if (!string.IsNullOrWhiteSpace(renderConfig.Placeholder))
                {
                    renderTreeBuilder.AddAttribute(11, nameof(BFormItemObject.Placeholder), renderConfig.Placeholder);
                }
                CreateBind(renderConfig, renderTreeBuilder, 13);
                renderTreeBuilder.AddComponentReferenceCapture(16, e => renderConfig.InputControl = e);
            }
            finally
            {
                renderTreeBuilder.CloseComponent();
            }
        }
        public static RenderTreeBuilder ComponentReferenceCapture(this RenderTreeBuilder builder, Action <object> action, [CallerLineNumber] int line = 0)
        {
            builder.AddComponentReferenceCapture(GetSequence(line), action);

            return(builder);
        }
Esempio n. 29
0
 internal static void AddComponentReferenceCapture(this RenderTreeBuilder builder, Action <object> componentReferenceCaptureAction, [CallerLineNumber] int lineNo = 0)
 {
     builder.AddComponentReferenceCapture(lineNo, componentReferenceCaptureAction);
 }