示例#1
0
        /// <summary>
        /// Създава таг
        /// </summary>
        /// <param name="aCurrentTag"></param>
        /// <param name="aCurrentTags"></param>
        /// <param name="aTagValue"></param>
        /// <returns></returns>
        private HTMLTag Create_Tag(HTMLTag aCurrentTag, HTMLTagCollection aCurrentTags, ref string aTagValue)
        {
            // Затварящ таг
            if (aTagValue.StartsWith("</"))
            {
                List <string> lsValue = GetTagValue(aTagValue);

                if (aCurrentTag.TagName == lsValue[0].ToUpper())
                {
                    aTagValue = "";
                }

                return(aCurrentTag.TagParent);
            }
            // Кратък гаг
            else if (aTagValue.EndsWith("/>"))
            {
                List <string> lsValue = GetTagValue(aTagValue);

                HTMLTag htmlTag = new HTMLTag(aCurrentTag, lsValue[0], HTMLTagType.ShortHTML);
                aCurrentTags.Add(htmlTag);
                AddTagProperties(htmlTag, lsValue);

                aTagValue = "";
                return(aCurrentTag);
            }
            // Отварящ таг
            else if (aTagValue.StartsWith("<"))
            {
                List <string> lsValue = GetTagValue(aTagValue);
                // Изключение: Кратък гаг
                if (lsValue[0].ToUpper() == "BR")
                {
                    HTMLTag htmlTag = new HTMLTag(aCurrentTag, lsValue[0], HTMLTagType.ShortHTML);
                    aCurrentTags.Add(htmlTag);
                    AddTagProperties(htmlTag, lsValue);

                    aTagValue = "";
                    return(aCurrentTag);
                }
                // Отваря тага
                else
                {
                    HTMLTag htmlTag = new HTMLTag(aCurrentTag, lsValue[0], HTMLTagType.HTML);
                    aCurrentTags.Add(htmlTag);
                    AddTagProperties(htmlTag, lsValue);

                    aTagValue = "";
                    return(htmlTag);
                }
            }
            // текстови таг
            else
            {
                HTMLTag htmlTag = new HTMLTag(aCurrentTag, aTagValue, HTMLTagType.Text);
                aCurrentTags.Add(htmlTag);

                aTagValue = "";
                return(aCurrentTag);
            }
        }