Пример #1
0
        public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            result = null;

            XAttribute att = _root.Attribute(binder.Name);

            if (att.IsNotNull())
            {
                result = att.Value;
                return(true);
            }

            var nodes = _root.Elements(binder.Name);

            if (nodes.Count() > 1)
            {
                result =
                    nodes
                    .Select(n => n.HasElements ? (object)new DynamicXmlDeserializer(n) : n.Value)
                    .ToList();

                return(true);
            }

            XElement node = _root.Element(binder.Name);

            if (node.IsNotNull())
            {
                result = node.HasElements ? (object)new DynamicXmlDeserializer(node) : node.Value;
                return(true);
            }

            return(true);
        }