本文整理汇总了C#中System.CommandLine.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# CommandLine.TryGetValue方法的具体用法?C# CommandLine.TryGetValue怎么用?C# CommandLine.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CommandLine
的用法示例。
在下文中一共展示了CommandLine.TryGetValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: commandLine_tryGetValue_using_valid_args_should_return_expected_value
public void commandLine_tryGetValue_using_valid_args_should_return_expected_value()
{
var expectedValue = 1000;
var target = new CommandLine( new[] { "-d=1000" } );
Int32 value;
Boolean actual = target.TryGetValue<Int32>( "d", out value );
actual.Should().Be.True();
value.Should().Be.EqualTo( expectedValue );
}
示例2: commandLine_tryGetValue_using_nullable_as_expected_value_and_missing_parameter_should_return_null
public void commandLine_tryGetValue_using_nullable_as_expected_value_and_missing_parameter_should_return_null()
{
var target = new CommandLine( new String[ 0 ] );
Int32? v;
Boolean actual = target.TryGetValue<Int32?>( "xyz", out v );
actual.Should().Be.False();
v.HasValue.Should().Be.False();
}
示例3: commandLine_tryGetValue_using_empty_args_should_not_fail
public void commandLine_tryGetValue_using_empty_args_should_not_fail()
{
var expected = false;
var target = new CommandLine( new String[ 0 ] );
Int32 v;
Boolean actual = target.TryGetValue<Int32>( "xyz", out v );
actual.Should().Be.EqualTo( expected );
}
示例4: CommandLine_using_valid_source_with_equals_in_the_parameter_value_should_handle_value_as_expected
public void CommandLine_using_valid_source_with_equals_in_the_parameter_value_should_handle_value_as_expected()
{
var target = new CommandLine( new[] { "-s=foo=bar" } );
String actual;
target.TryGetValue( "s", out actual );
actual.Should().Be.EqualTo( "foo=bar" );
}
示例5: commandLine_tryGetValue_using_invalid_format_input_value_should_not_fail
public void commandLine_tryGetValue_using_invalid_format_input_value_should_not_fail()
{
var target = new CommandLine( new[] { "xyz=1_0" } );
Int32 v;
Boolean actual = target.TryGetValue<Int32>( "xyz", out v );
actual.Should().Be.False();
}
示例6: CommandLine
public void commandLine_tryGetValue_using_nullable_as_expected_value_and_valid_parameter_should_return_expected_value()
{
var expected = new Nullable<Int32>( 10 );
var target = new CommandLine( new[] { "xyz=10" } );
Int32? v;
Boolean actual = target.TryGetValue<Int32?>( "xyz", out v );
actual.Should().Be.True();
v.Should().Be.EqualTo( expected );
}