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(); }
public static T GetVariable <T>(MemberInfo member, Type destinationType = null) { return((T)ParameterService.GetFromMemberInfo(member, destinationType ?? typeof(T), ParameterService.Instance.GetEnvironmentVariable)); }
public static T GetNamedArgument <T>(MemberInfo member, Type destinationType = null) { return((T)ParameterService.GetFromMemberInfo(member, destinationType ?? typeof(T), ParameterService.Instance.GetCommandLineArgument)); }
public static T GetParameter <T>(MemberInfo member, Type destinationType = null) { return((T)ParameterService.GetFromMemberInfo(member, destinationType ?? typeof(T), ParameterService.Instance.GetParameter)); }