示例#1
0
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            result = null;
            var elements = element.Elements(binder.Name);

            if (elements == null)
            {
                return(false);
            }

            if (args.Length > 0)
            {
                elements = elements.Where((e) =>
                {
                    for (int i = 0; i < args.Length; i += 2)
                    {
                        var a = e.Attribute(args[i].ToString());
                        if (a == null || a.Value != args[i + 1].ToString())
                        {
                            return(false);
                        }
                    }
                    return(true);
                });
            }

            //if (elements.Count() == 1)
            //	result = new XmlItem(elements.First());
            //else
            result = new XmlItems(elements);
            return(true);
        }
示例#2
0
        public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
        {
            var elements = element.Elements();

            if (elements == null)
            {
                result = null;
                return(false);
            }
            //if (elements.Count() == 1)
            //	result = new XmlItem(elements.First());
            //else
            result = new XmlItems(elements);
            return(true);
        }