コード例 #1
0
        public void TestExpression()
        {
            var service = GetService(
                new[]
            {
                "--string",
                "--set",
                "1",
                "2",
                "3",
                "--interface-param"
            });

            var build = new TestBuild();

            ParameterService.GetFromMemberInfo(GetMemberInfo(() => build.String), typeof(AbsolutePath), service.GetParameter)
            .Should().BeNull();

            ParameterService.GetFromMemberInfo(GetMemberInfo(() => build.String), typeof(bool), service.GetParameter)
            .Should().BeOfType <bool>().Subject.Should().BeTrue();

            ParameterService.GetFromMemberInfo(GetMemberInfo(() => build.Set), destinationType: null, service.GetParameter)
            .Should().BeOfType <int[]>().Subject.Should().BeEquivalentTo(new[] { 1, 2, 3 });

            ParameterService.GetFromMemberInfo(GetMemberInfo(() => ((ITestComponent)build).Param), destinationType: null, service.GetParameter)
            .Should().BeOfType <bool>().Subject.Should().BeTrue();
        }
コード例 #2
0
 public static T GetVariable <T>(MemberInfo member, Type destinationType = null)
 {
     return((T)ParameterService.GetFromMemberInfo(member, destinationType ?? typeof(T), ParameterService.Instance.GetEnvironmentVariable));
 }
コード例 #3
0
 public static T GetNamedArgument <T>(MemberInfo member, Type destinationType = null)
 {
     return((T)ParameterService.GetFromMemberInfo(member, destinationType ?? typeof(T), ParameterService.Instance.GetCommandLineArgument));
 }
コード例 #4
0
 public static T GetParameter <T>(MemberInfo member, Type destinationType = null)
 {
     return((T)ParameterService.GetFromMemberInfo(member, destinationType ?? typeof(T), ParameterService.Instance.GetParameter));
 }