Example #1
0
        void EndData(HtmlText containerClass)
        {
            if (currentData.Count > 0)
            {
                string data = currentData.Aggregate(new StringBuilder(), (x, y) => x.Append(y)).ToString();

                //TODO: clean this up
                char[] spaceChars = { (char)9, (char)10, (char)12, (char)13, (char)32 };
                if (string.IsNullOrEmpty(new string(data.Where(c => !spaceChars.Contains(c)).ToArray())))
                {
                    if (preserveWhitespaceTags.Intersect(tagStack.Select(tag => tag.TagName)).Count() == 0)
                    {
                        if (data.Contains("\n"))
                        {
                            data = "\n";
                        }
                        else
                        {
                            data = " ";
                        }
                    }
                }
                currentData = new List <string>();
                HtmlText o = containerClass;
                o.Value = data;
                o.Setup(currentTag, root.Previous);
                if (root.Previous != null)
                {
                    root.Previous.Next = o;
                }
                root.Previous = o;
                currentTag.AddChild(o);
            }
        }