public override bool TryGetMember(GetMemberBinder binder, out object result) { if (binder == null) { throw new ArgumentNullException("binder"); } if (string.IsNullOrWhiteSpace(binder.Name)) { throw new ArgumentException(@"binder.name must be non empty string", "binder"); } var child = InnerElement.Elements(binder.Name).FirstOrDefault(); if (child == null) { child = new XElement(binder.Name); InnerElement.Add(child); } result = CreateInstance(child); return(true); }
public override bool TryGetMember(GetMemberBinder binder, out object result) { if (binder == null) { throw new ArgumentNullException("binder"); } if (string.IsNullOrWhiteSpace(binder.Name)) { throw new ArgumentException(@"binder.name must be non empty string", "binder"); } var child = InnerElement.Elements(binder.Name).FirstOrDefault(); if (child != null) { result = CreateInstance(child); return(true); } throw new InvalidOperationException(string.Format("Element '{0}' not found among subelements of '{1}'", binder.Name, InnerElement.Name.LocalName)); }
public IEnumerable <T> Elements <T>(XName name) where T : Tag { return(InnerElement.Elements(name).Select(element => Convert <T>(element))); }
public IEnumerable <XElement> Elements() { return(InnerElement.Elements()); }