Esempio n. 1
0
 public override bool TryGetMember(GetMemberBinder binder, out object result)
 {
     result = null;
     if (binder.Name == "Value")
         result = _elements[0].Value;
     else if (binder.Name == "Count")
         result = _elements.Count;
     else
     {
         var attr = _elements[0].Attribute(XName.Get(binder.Name));
         if (attr != null)
             result = attr;
         else
         {
             var items = _elements.Descendants(XName.Get(binder.Name));
             if (items == null || items.Count() == 0) return false;
             if (items.Count() == 1)
             {
                 XElement element = new List<XElement>(items)[0];
                 if (element.HasElements)
                 {
                     result = new XmlObject(items);
                 }
                 else
                 {
                     result = new List<XElement>(items)[0].Value;
                 }
             }
             else
             {
                 result = new XmlObject(items);
             }
         }
     }
     return true;
 }
Esempio n. 2
0
 public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
 {
     int ndx = (int)indexes[0];
     result = new XmlObject(_elements[ndx]);
     return true;
 }