Exemplo n.º 1
0
 public virtual void WriteXml(XmlWriter writer)
 {
     if (Name != null)
     {
         writer.WriteAttributeString(NameAttributeName, Name);
     }
     writer.WriteAttributeString(KeyTypeAttributeName, typeof(TKey).Name);
     writer.WriteAttributeString(CountAttributeName, this.Count.ToString());
     if (ExtraAttributeNames != null)
     {
         foreach (var key in ExtraAttributeNames)
         {
             string val;
             if (ExtraAttributes.ContainsKey(key) &&
                 (val = ExtraAttributes[key]) != null)
             {
                 writer.WriteAttributeString(key, val);
             }
         }
     }
     if (ExtraElementManager != null && ExtraElement != null)
     {
         ExtraElementManager.Serialize(writer, ExtraElement);
     }
     this.ToList().ForEach(item => {
         XmlHelper <TItem> .writeElement(writer, item);
     });
 }
Exemplo n.º 2
0
        public override string ToString()
        {
            var ret = "";

            if (!String.IsNullOrEmpty(Name))
            {
                ret += NameAttributeName + ":'" + Name + "', ";
            }
            ret += CountAttributeName + ":" + this.Count;
            if (ExtraAttributeNames != null && ExtraAttributes.Count > 0)
            {
                var attr = new List <string>(ExtraAttributes.Count);
                foreach (var key in ExtraAttributeNames)
                {
                    if (ExtraAttributes.ContainsKey(key))
                    {
                        attr.Add("'" + key + "':'" + ExtraAttributes[key] + "'");
                    }
                }
                ret += ", ExtraAttribute:{" + String.Join(", ", attr) + "}";
            }
            if (ExtraElementManager != null && ExtraElement != null)
            {
                ret += ", " + ExtraElementManager.Name + ":{" + ExtraElement + "}";
            }
            return(ret);
        }