コード例 #1
0
        public void MethodResoultionDynamicTest2()
        {
            const string targetPath = "Text";
            const string binding = @"Text $Ext.Method1(arg1)";
            var instance = new ExtInstance();
            BindingServiceProvider.ResourceResolver.AddObject("Ext", instance);
            IBindingParser bindingParser = CreateBindingParser();

            var context = new BindingBuilder(bindingParser.Parse(new object(), binding, null, null).Single());
            IBindingPath path = context.GetData(BindingBuilderConstants.TargetPath);
            path.Path.ShouldEqual(targetPath);

            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            var args = new object[] { instance, "st" };
            expression(context, args);
            instance.Assert(() => instance.Method1("st", 0M, "", int.MaxValue), new object[] { instance, "st", 0M, "", int.MaxValue });
        }
コード例 #2
0
        public void MethodResoultionDynamicTest4()
        {
            const string targetPath = "Text";
            const string binding = @"Text $Ext.Method2(arg1, arg2)";
            var instance = new ExtInstance();
            BindingServiceProvider.ResourceResolver.AddObject("Ext", instance);
            IBindingParser bindingParser = CreateBindingParser();

            var context = new BindingBuilder(bindingParser.Parse(binding, EmptyContext, new object(), null).Single());
            IBindingPath path = context.GetData(BindingBuilderConstants.TargetPath);
            path.Path.ShouldEqual(targetPath);

            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            var array = new[] { int.MinValue, int.MaxValue };
            var args = new object[] { instance, 2, array };
            expression(context, args);
            instance.Assert(() => instance.Method2(2, array), new object[] { instance, 2, int.MinValue, int.MaxValue });

            args = new object[] { instance, 2, 3 };
            expression(context, args);
            instance.Assert(() => instance.Method2(2, 3), args);
        }
コード例 #3
0
        public void MethodResoultionDynamicTest0()
        {
            const string targetPath = "Text";
            const string binding = @"Text $Ext.This().Method(arg1, arg2)";
            var instance = new ExtInstance();
            BindingServiceProvider.ResourceResolver.AddObject("Ext", instance);
            IBindingParser bindingParser = CreateBindingParser();

            var context = new BindingBuilder(bindingParser.Parse(new object(), binding, null, null).Single());
            IBindingPath path = context.GetData(BindingBuilderConstants.TargetPath);
            path.Path.ShouldEqual(targetPath);

            var expression = context.GetData(BindingBuilderConstants.MultiExpression);
            var args = new object[] { instance, 2M, 3M };
            expression(context, args);
            instance.Assert(() => instance.Method(2M, 3M), args);

            args = new object[] { instance, 2, 3 };
            expression(context, args);
            instance.Assert(() => instance.Method(2, 3), args);

            args = new object[] { instance, 2, 3 };
            expression(context, args);
            instance.Assert(() => instance.Method(2, 3), args);

            args = new object[] { instance, 2M, "t" };
            expression(context, args);
            instance.Assert(() => instance.Method(2M, "t"), args);

            args = new object[] { instance, 2, "t" };
            expression(context, args);
            instance.Assert(() => instance.Method(2M, "t"), args);

            args = new object[] { instance, "t", 2M };
            expression(context, args);
            instance.Assert(() => instance.Method("t", 2M), args);

            args = new object[] { instance, "t", 2 };
            expression(context, args);
            instance.Assert(() => instance.Method("t", 2), new object[] { instance, "t", 2M });
        }