Пример #1
0
        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);
        }
Пример #2
0
        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));
        }
Пример #3
0
 public IEnumerable <T> Elements <T>(XName name) where T : Tag
 {
     return(InnerElement.Elements(name).Select(element => Convert <T>(element)));
 }
Пример #4
0
 public IEnumerable <XElement> Elements()
 {
     return(InnerElement.Elements());
 }