コード例 #1
0
        public void InstanceConvertOverloaded()
        {
            var expr = new CallConverterExpression {
                Source = Source,
                Path   = $"{nameof(Foo.Sub)}.{nameof(Foo.InstanceConvertOverloaded)}",
            };

            expr.GetValue(Source).As <ConverterFunc>().Invoke(1, 2m, Culture).Should().Be("B-1-2m");
            expr.GetValue(Source).As <ConverterFunc>().Invoke(1, 2f, Culture).Should().Be("B-1-2f");
        }
コード例 #2
0
        public void ConvertSource()
        {
            var expr = new CallConverterExpression {
                Source = new Func <object, object>(v => Source.InstanceConvert1((int)v)),
            };

            expr.GetValue(Source).As <ConverterFunc>().Invoke(1, 2, Culture).Should().Be("A-1");
        }
コード例 #3
0
        public void StaticConvert(string methodName, string result)
        {
            var expr = new CallConverterExpression {
                Source = Source,
                Path   = $"{nameof(Foo.Sub)}.{methodName}",
            };

            expr.GetValue(Source).As <ConverterFunc>().Invoke(1, 2, Culture).Should().Be(result);
        }