当前位置: 首页>>代码示例>>C#>>正文


C# Validator.GetByte方法代码示例

本文整理汇总了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 );
        }
开发者ID:william-gross,项目名称:enterprise-web-library,代码行数:101,代码来源:RsLibraryTester.cs


注:本文中的Validator.GetByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。