public string ToXml(string indent = "")
        {
            var str1 = "\r\n" + indent + "<" + Name;

            foreach (var t in Attrs)
            {
                var name  = t.Name;
                var value = t.Value.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;")
                            .Replace("\"", "&quot;").Replace("'", "&apos;");
                str1 = str1 + " " + name + "=\"" + value + "\"";
            }
            string str2;

            if (Text.Length > 0)
            {
                var text = Text.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;")
                           .Replace("\"", "&quot;").Replace("'", "&apos;");

                if (Childs.Count > 0)
                {
                    var str3    = str1 + ">" + "\r\n" + indent + "\t" + text;
                    var indent1 = indent + "\t";
                    str3 = Childs.Aggregate(str3, (current, t) => current + t.ToXml(indent1));
                    str2 = str3 + "\r\n" + indent + "</" + Name + ">";
                }
                else
                {
                    str2 = str1 + ">" + text + "</" + Name + ">";
                }
            }
            else if (Childs.Count > 0)
            {
                var str3    = str1 + ">";
                var indent1 = indent + "\t";
                str3 = Childs.Aggregate(str3, (current, t) => current + t.ToXml(indent1));
                str2 = str3 + "\r\n" + indent + "</" + Name + ">";
            }
            else
            {
                str2 = str1 + "/>";
            }
            return(str2);
        }
Exemple #2
0
 public TimeSpan TimeSpentWithChilds(DateTime sinceDate = new DateTime())
 {
     return(TimeSpent2(sinceDate) +
            Childs.Aggregate(new TimeSpan(), (sum, next) => sum += next.TimeSpentWithChilds(sinceDate)));
 }