Exemplo n.º 1
0
        public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result)
        {
            int ndx = (int)indexes[0];

            result = new DynamicXml(_elements[ndx]);
            return(true);
        }
Exemplo n.º 2
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);
             }
             result = new DynamicXml(items);
         }
     }
     return(true);
 }