本文整理汇总了C#中Validator.GetByte方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.GetByte方法的具体用法?C# Validator.GetByte怎么用?C# Validator.GetByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator.GetByte方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
vp = new ValidationErrorHandler( errorWriter ); // "myGoodInt" );
Console.WriteLine( validator.GetInt( vp, "-342" ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter ); // "myBadDate" );
Console.WriteLine( validator.GetSqlSmallDateTimeFromParts( vp, "3", "", "" ) );
Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter ); // "myBadDate" );
Console.WriteLine( validator.GetSqlSmallDateTimeFromParts( vp, "", "", "" ) );
Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter ); // "zip" );
Console.WriteLine( validator.GetZipCode( vp, "14580", true ).FullZipCode );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter ); // "zip" );
Console.WriteLine( validator.GetZipCode( vp, "14580-1234", true ).FullZipCode );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter ); // "badZip" );
Console.WriteLine( validator.GetZipCode( vp, "123", false ).FullZipCode );
Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );
Console.WriteLine( "---------------------------------\nPhone Numbers:\n------------------------------------\n" );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( validator.GetPhoneNumber( vp, "5854556476", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( validator.GetPhoneNumber( vp, "585 4556476", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( validator.GetPhoneNumber( vp, "( 585 )455-6476", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( validator.GetPhoneNumber( vp, "(585)455-6476", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( validator.GetPhoneNumber( vp, "585-455-6476", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "With lots of spaces: " + validator.GetPhoneNumber( vp, "585 872 0291 ", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "With x: " + validator.GetPhoneNumber( vp, "5854556476 x 12345", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "With space ext. allowed: " + validator.GetPhoneNumber( vp, "5854556476 12345", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "Toni example 1: " + validator.GetPhoneNumber( vp, "321-663-4810", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "Toni example 2: " + validator.GetPhoneNumber( vp, "585-336-7600 ext 65361", true, true, false ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "Gibberish, should fail^ " + validator.GetPhoneNumber( vp, "sodifuoisafdoiu", true, true, true ) );
Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "With space no ext. allowed, should fail^ " + validator.GetPhoneNumber( vp, "5854556476 12345", false, false, true ) );
Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "With extension and no delimeters, should fail^ " + validator.GetPhoneNumber( vp, "585455647612345", true, true, false ) );
Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine(
"With extension and no delimeters, should succeed since allowGarbage is on. " + validator.GetPhoneNumber( vp, "585455647612345", true, true, true ) );
Assert.IsFalse( vp.LastResult != ErrorCondition.NoError );
vp = new ValidationErrorHandler( errorWriter );
Console.WriteLine( "Should fail^ " + validator.GetPhoneNumber( vp, "02934", true, true, false ) );
Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );
Console.WriteLine( "------------------------\nEnd phone numbers.\n-------------------------------\n" );
vp = new ValidationErrorHandler( errorWriter ); // "badByte" );
Console.WriteLine( validator.GetByte( vp, "234987234" ) );
Assert.IsFalse( vp.LastResult == ErrorCondition.NoError );
var key = Rijndael.Create().Key;
Console.Write( "Encryption Key: { " );
foreach( var b in key )
Console.Write( b + ", " );
Console.WriteLine();
Console.WriteLine( "SSN length: " + EncryptionOps.EncryptString( EncryptionOps.GenerateInitVector(), "987654321" ).Length );
}