WebMarkupMin.Core.GenericHtmlMinifier.UpgradeToMetaCharsetTag C# (CSharp) Метод

UpgradeToMetaCharsetTag() приватный Метод

Upgrades a META content-type tag to the META charset tag
private UpgradeToMetaCharsetTag ( WebMarkupMin.Core.Parsers.HtmlTag tag ) : WebMarkupMin.Core.Parsers.HtmlTag
tag WebMarkupMin.Core.Parsers.HtmlTag META content-type tag
Результат WebMarkupMin.Core.Parsers.HtmlTag
        private HtmlTag UpgradeToMetaCharsetTag(HtmlTag tag)
        {
            HtmlTag upgradedTag = tag;

            HtmlAttribute contentAttribute = tag.Attributes.SingleOrDefault(a => a.NameInLowercase == "content");
            if (contentAttribute != null)
            {
                string content = contentAttribute.Value.Trim();
                if (content.Length > 0)
                {
                    Match contentMatch = _metaContentTypeTagValueRegex.Match(content);
                    if (contentMatch.Success)
                    {
                        string charset = contentMatch.Groups["charset"].Value;
                        upgradedTag = new HtmlTag(tag.Name, tag.NameInLowercase,
                            new List<HtmlAttribute>
                            {
                                new HtmlAttribute("charset", "charset", charset, HtmlAttributeType.Text)
                            },
                            tag.Flags
                        );
                    }
                }
            }

            return upgradedTag;
        }