コード例 #1
0
        string GetEntityRender()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"<{EntityOrigin.Name}");
            foreach (var item in EntityOrigin.Attributes)
            {
                string attrValue = item.Value;
                switch (item.Key)
                {
                case "src":
                case "href":
                    attrValue = MetadataContainerOwner.ResolveUrl(attrValue);
                    break;
                }
                if (!string.IsNullOrEmpty(attrValue))
                {
                    sb.Append($" {item.Key}=\"{attrValue}\"");
                }
                else
                {
                    sb.Append($" {item.Key}");
                }
            }
            if (EntityOrigin.Name == "script" || !string.IsNullOrEmpty(EntityOrigin.Content))
            {
                sb.Append(">");
                if (EntityOrigin.Name == "title")
                {
                    sb.Append(string.Format(TitleFormat, EntityOrigin.Content));
                }
                else
                {
                    sb.Append(EntityOrigin.Content);
                }
                sb.Append($"</{EntityOrigin.Name}>");
            }
            else
            {
                sb.Append("/>");
            }
            sb.Append(Environment.NewLine);
            return(sb.ToString());
        }