Example #1
0
        public sealed override Expression Bind(object[] args, ReadOnlyCollection <ParameterExpression> parameters, LabelTarget returnLabel)
        {
            if (args.Length == 0)
            {
                throw new InvalidOperationException();
            }

            MetaObject[] mos;
            if (args.Length != 1)
            {
                mos = new MetaObject[args.Length - 1];
                for (int i = 1; i < args.Length; i++)
                {
                    mos[i - 1] = MetaObject.ObjectToMetaObject(args[i], parameters[i]);
                }
            }
            else
            {
                mos = MetaObject.EmptyMetaObjects;
            }

            MetaObject binding = Bind(
                MetaObject.ObjectToMetaObject(args[0], parameters[0]),
                mos
                );

            if (binding == null)
            {
                throw Error.BindingCannotBeNull();
            }

            return(GetMetaObjectRule(binding, returnLabel));
        }