コード例 #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());
 }