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


C# Recipe.Prepare方法代码示例

本文整理汇总了C#中Recipe.Prepare方法的典型用法代码示例。如果您正苦于以下问题:C# Recipe.Prepare方法的具体用法?C# Recipe.Prepare怎么用?C# Recipe.Prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Recipe的用法示例。


在下文中一共展示了Recipe.Prepare方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_build_a_single_expression_when_given_two_query_parameters_with_an_and

        public void Should_build_a_single_expression_when_given_two_query_parameters_with_an_and( )
        {
            var r = new Recipe<SampleData>( "Address lk 'Test' and Value gt '20'" );

            var data = new SampleRepository
                           {
                               DataSource = new[ ]
                                                {
                                                    new SampleData {Address = "Test 2", Value = 21},
                                                    new SampleData {Address = "Test 3", Value = 19},
                                                    new SampleData {Address = "Not like anything else", Value = 30},
                                                }
                           }.DataSource;

            data = data.Where( r.Prepare( ) );

            Assert.AreEqual( 1, data.Count( ) );
        }
开发者ID:tbd-develop,项目名称:roastpotato,代码行数:18,代码来源:When_given_instructions.cs

示例2: Should_build_a_single_expression_when_given_a_complex_parameter_string

        public void Should_build_a_single_expression_when_given_a_complex_parameter_string( )
        {
            var r = new Recipe<SampleData>( "Address lk 'Test' and (Value gt '20' or Id eq '1')" );

            var data = new SampleRepository
                           {
                               DataSource = new[ ]
                                                {
                                                    new SampleData {Address = "Test 2", Value = 21, Id = 2},
                                                    new SampleData {Address = "Test 3", Value = 19, Id = 13},
                                                    new SampleData
                                                        {Address = "Test else", Value = 18, Id = 1},
                                                    new SampleData
                                                        {Address = "Not like anything else", Value = 30, Id = 4},
                                                }
                           }.DataSource;

            data = data.Where( r.Prepare( ) );

            Assert.AreEqual( 2, data.Count( ) );
        }
开发者ID:tbd-develop,项目名称:roastpotato,代码行数:21,代码来源:When_given_instructions.cs

示例3: Should_build_a_working_expression_given_one_value_query

        public void Should_build_a_working_expression_given_one_value_query( )
        {
            var r = new Recipe<SampleData>( "Address lk 'Test'" );

            var data = new SampleRepository
                           {
                               DataSource = new[ ]
                                                {
                                                    new SampleData {Address = "Test 2"},
                                                    new SampleData {Address = "Test 3"},
                                                    new SampleData {Address = "Not like anything else"},
                                                }
                           }.DataSource;
            data = data.Where( r.Prepare( ) );

            Assert.AreEqual( 2, data.Count( ) );
        }
开发者ID:tbd-develop,项目名称:roastpotato,代码行数:17,代码来源:When_given_instructions.cs

示例4: Should_build_a_single_instruction_when_provided_one_value_query

        public void Should_build_a_single_instruction_when_provided_one_value_query( )
        {
            var r = new Recipe<SampleData>( "Address lk 'Test'" );

            Assert.IsNotNull( r.Prepare( ) );
        }
开发者ID:tbd-develop,项目名称:roastpotato,代码行数:6,代码来源:When_given_instructions.cs

示例5: Main

        static void Main(string[ ] args)
        {
            CustomerRepository repository = new CustomerRepository
                                                {
                                                    DataSource = new[ ]
                                                                     {
                                                                         new Customer
                                                                             {
                                                                                 FirstName = "John",
                                                                                 LastName = "Smith",
                                                                                 CreditLimit = 10000,
                                                                                 Address = "156 Langolier Drive",
                                                                                 State = "NJ"
                                                                             },
                                                                         new Customer
                                                                             {
                                                                                 FirstName = "Herbert",
                                                                                 LastName = "Jenkins",
                                                                                 CreditLimit = 5000,
                                                                                 Address = "123 Penny Lane",
                                                                                 State = "OR"
                                                                             },
                                                                         new Customer
                                                                             {
                                                                                 FirstName = "Fred",
                                                                                 LastName = "Jones",
                                                                                 CreditLimit = 1500,
                                                                                 Address = "155 Poor Street",
                                                                                 State = "NJ"
                                                                             }
                                                                     }
                                                };

            //string recipeInstructions = "CreditLimit gte '5000' and LastName lk 'Jen' or CreditLimit lt '1600'";

            //Recipe<Customer> customerRecipe = new Recipe<Customer>( recipeInstructions );

            //var results = repository.DataSource.Where( customerRecipe.Prepare( ) );

            //foreach ( var result in results )
            //{
            //    Console.WriteLine( result );
            //}

            while ( true )
            {
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.Clear( );
                Console.WriteLine( "Query" );
                Console.WriteLine( new string( '-', 30 ) );
                Console.Write( ">" );
                var recipe = Console.ReadLine( );

                if ( recipe.Equals( "quit", StringComparison.InvariantCultureIgnoreCase ) )
                    break;

                Recipe<Customer> customerRecipe = new Recipe<Customer>( recipe );

                if ( customerRecipe.Invalid )
                    break;

                var results = repository.DataSource.Where( customerRecipe.Prepare( ) );

                Console.WriteLine( "First Name\t\tLastName\t\tState\t\tAddress\t\tCredit Limit" );
                Console.WriteLine( new string( '-', 100 ) );

                foreach ( var result in results )
                {
                    Console.WriteLine( string.Format( "{0}\t\t{1}\t\t{2}", result.FirstName, result.LastName,
                                                    result.Address ) );
                }

                Console.WriteLine( "Any key to continue" );
                Console.ReadKey( );
            }
        }
开发者ID:tbd-develop,项目名称:roastpotato,代码行数:76,代码来源:Program.cs


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