Example #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);
        }