コード例 #1
0
        public HtmlTag(string tag)
            : this()
        {
            tag = tag.Substring(1, tag.Length - 2);

            var spaceIndex = tag.IndexOf(" ");

            //Extract tag name
            if (spaceIndex < 0)
            {
                TagName = tag;
            }
            else
            {
                TagName = tag.Substring(0, spaceIndex);
            }

            //Check if is end tag
            if (TagName.StartsWith("/"))
            {
                IsClosing = true;
                TagName   = TagName.Substring(1);
            }

            TagName = TagName.ToLower();

            //Extract attributes
            var atts = Parser.Match(Parser.HmlTagAttributes, tag);

            foreach (Match att in atts)
            {
                //Extract attribute and value
                var chunks = att.Value.Split('=');

                if (chunks.Length == 1)
                {
                    if (!Attributes.ContainsKey(chunks[0]))
                    {
                        Attributes.Add(chunks[0].ToLower(), string.Empty);
                    }
                }
                else if (chunks.Length == 2)
                {
                    var attname  = chunks[0].Trim();
                    var attvalue = chunks[1].Trim();

                    if (attvalue.StartsWith("\"") && attvalue.EndsWith("\"") && attvalue.Length > 2)
                    {
                        attvalue = attvalue.Substring(1, attvalue.Length - 2);
                    }

                    if (!Attributes.ContainsKey(attname))
                    {
                        Attributes.Add(attname, attvalue);
                    }
                }
            }
        }
コード例 #2
0
ファイル: BuildRetainer.cs プロジェクト: tmat/roslyn-tools
 public bool IsRelease() => TagName.StartsWith("refs/tags/release/");