コード例 #1
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public Task <string> RenderAsync(object model)
        {
            bool showValues = UserSettings.GetProperty <bool>("ShowEnumValue");

            showValues = showValues && PropData.GetAdditionalAttributeValue("ShowEnumValue", true);

            string desc;
            string caption = ObjectSupport.GetEnumDisplayInfo(model, out desc, ShowValue: showValues);

            if (HtmlAttributes.Count > 0 || !string.IsNullOrWhiteSpace(desc))
            {
                YTagBuilder tag = new YTagBuilder("span");
                tag.AddCssClass("yt_enum");
                tag.AddCssClass("t_display");
                FieldSetup(tag, FieldType.Anonymous);
                tag.Attributes.Add(Basics.CssTooltipSpan, desc);
                tag.SetInnerText(caption);
                return(Task.FromResult(tag.ToString(YTagRenderMode.Normal)));
            }
            else
            {
                return(Task.FromResult(caption));
            }
        }