コード例 #1
0
        /// <summary>
        /// Main method to render custom component implementation.
        /// </summary>
        /// <returns></returns>
        protected RenderFragment RenderCustomComponent() => builder =>
        {
            builder.OpenComponent(0, ComponentMapper.GetImplementation(this));

            foreach (var parameter in parameters)
            {
                builder.AddAttribute(1, parameter.Key, parameter.Value);
            }

            // since we're rendering custom component instead of this one, we need
            // to get the ID of the rendered component. Then that ID will be used
            // and sent to java script when needed.
            builder.AddComponentReferenceCapture(2, (otherComponent) =>
            {
                if (otherComponent is BaseComponent baseComponent)
                {
                    // getting the ElementRef directly is not possible so as a workaround we need to
                    // get it through the function
                    GetCustomElementRef = () => baseComponent.ElementRef;

                    ElementId = baseComponent.ElementId;
                }
            });

            builder.CloseComponent();
        };
コード例 #2
0
ファイル: BaseComponent.cs プロジェクト: komirineni/Blazorise
        /// <summary>
        /// Main method to render custom component implementation.
        /// </summary>
        /// <returns></returns>
        protected RenderFragment RenderCustomComponent() => builder =>
        {
            builder.OpenComponent(0, ComponentMapper.GetImplementation(this));

            foreach (var parameter in parameters)
            {
                builder.AddAttribute(1, parameter.Key, parameter.Value);
            }

            builder.CloseComponent();
        };