public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out object result) { int ndx = (int)indexes[0]; result = new DynamicDataXml(_elements[ndx]); return(true); }
public override bool TryGetMember(GetMemberBinder binder, out object result) { result = null; if (binder.Name == "value") { result = _elements[0].Value; return(true); } else if (binder.Name == "nodes") { result = new DynamicDataNodes(_elements.Elements().Select(e => new DynamicDataXml(e)).ToList()); return(true); } else { var attr = _elements[0].Attribute(XName.Get(binder.Name)); if (attr != null) { result = attr; return(true); } else { var items = _elements.Elements(XName.Get(binder.Name)); if (items == null || items.Count() == 0) { return(false); } result = new DynamicDataXml(items); return(true); } } }