• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ExpressionSpecification类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ExpressionSpecification的典型用法代码示例。如果您正苦于以下问题:C# ExpressionSpecification类的具体用法?C# ExpressionSpecification怎么用?C# ExpressionSpecification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExpressionSpecification类属于命名空间,在下文中一共展示了ExpressionSpecification类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: XOrTestCase3

        public void XOrTestCase3()
        {
            var left = new ExpressionSpecification<String>( x => false );
            var target = left.XOr( x => false );

            var actual = target.IsSatisfiedBy( String.Empty );
            Assert.IsFalse( actual );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:8,代码来源:ISpecification.XOr.Test.cs


示例2: OrTestCase4

        public void OrTestCase4()
        {
            var left = new ExpressionSpecification<String>( x => true );
            var target = left.Or( x => true );

            var actual = target.IsSatisfiedByWithMessages( String.Empty );
            Assert.AreEqual( 0, actual.Count() );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:8,代码来源:ISpecification.Or.Test.cs


示例3: OrTestCase

        public void OrTestCase()
        {
            var left = new ExpressionSpecification<String>( x => true );
            var target = left.Or( x => true );

            var actual = target.IsSatisfiedBy( String.Empty );
            Assert.IsTrue( actual );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:8,代码来源:ISpecification.Or.Test.cs


示例4: QueryItemById

 // Methods
 public Item QueryItemById(int id)
 {
     var itemIdSpec = new ExpressionSpecification<Item>(i => i.Id == id);
     var items = _itemRepository
         .Select(itemIdSpec, _includedProperties)
         .SingleOrDefault();
     return items;
 }
开发者ID:msupetran,项目名称:TipidPC,代码行数:9,代码来源:ItemDomainService.cs


示例5: AndTestCaseNullCheck

        public void AndTestCaseNullCheck()
        {
            var target = new ExpressionSpecification<String>( x => false );
            ExpressionSpecification<String> other = null;

            Action test = () => target.And( other );

            test.ShouldThrow<ArgumentNullException>();
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:ExpressionSpecification.Test.cs


示例6: AndTestCase3

        public void AndTestCase3()
        {
            var target = new ExpressionSpecification<String>( x => false );
            var other = new ExpressionSpecification<String>( x => false );

            var actual = target.And( other );
            var result = actual.IsSatisfiedBy( String.Empty );
            Assert.IsFalse( result );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:ExpressionSpecification.Test.cs


示例7: AndTestCase1

        public void AndTestCase1()
        {
            var left = new ExpressionSpecification<String>( x => true );
            var target = left.And( x => false );

            var actual = target.IsSatisfiedBy( String.Empty );
            actual.Should()
                  .BeFalse();
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:ISpecification.And.Test.cs


示例8: SatisfiesWithMessagesTestCase

        public void SatisfiesWithMessagesTestCase()
        {
            var specification = new ExpressionSpecification<String>( x => x.Length > 3 )
                .And( x => x.StartsWith( "1" ) );

            var actual = "1234".SatisfiesWithMessages( specification )
                               .ToList();
            Assert.AreEqual( 0, actual.Count );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:Object.Generic.SatisfiesWithMessages.Test.cs


示例9: XOrTestCase10

        public void XOrTestCase10()
        {
            var left = new ExpressionSpecification<String>( x => false, "msgLeft" );
            var target = left.XOr( x => true, "msgRight" );

            var actual = target.IsSatisfiedByWithMessages( String.Empty )
                               .ToList();
            Assert.AreEqual( 0, actual.Count() );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:9,代码来源:ISpecification.XOr.Test.cs


示例10: AndTestCase3

        public void AndTestCase3()
        {
            var left = new ExpressionSpecification<String>( x => false );
            var right = new ExpressionSpecification<String>( x => true );
            var target = new AndSpecification<String>( left, right );

            var actual = target.And( new ExpressionSpecification<String>( x => false ) );
            var result = actual.IsSatisfiedBy( String.Empty );
            Assert.IsFalse( result );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:10,代码来源:AndSpecification.Test.cs


示例11: XOrTestCase4

        public void XOrTestCase4()
        {
            var left = new ExpressionSpecification<String>( x => true );
            var target = left.XOr( x => true );

            var actual = target.IsSatisfiedByWithMessages( String.Empty )
                               .ToList();
            Assert.AreEqual( 1, actual.Count );
            Assert.AreEqual( "The given object matches both specifications.", actual[0] );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:10,代码来源:ISpecification.XOr.Test.cs


示例12: WhereNotTestCase

        public void WhereNotTestCase()
        {
            var target = new List<Int32> { 1, 10, 100, 1000 };
            var specification = new ExpressionSpecification<Int32>( x => x >= 100 );

            var actual = target.WhereNot( specification )
                               .ToList();
            Assert.AreEqual( 2, actual.Count );
            Assert.AreEqual( 1, actual.Count( x => x == 1 ) );
            Assert.AreEqual( 1, actual.Count( x => x == 10 ) );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:11,代码来源:IEnumerable[T].WhereNot.Test.cs


示例13: Test_And_Specification

        public void Test_And_Specification()
        {
            ISpecification<int> rule1 = new ExpressionSpecification<int>(x => x == 1, "rule1 failed");
            ISpecification<int> rule2 = new ExpressionSpecification<int>(x => x == 2, "rule2 failed");
            ISpecification<int> rule3 = new ExpressionSpecification<int>(x => x == 3, "rule3 failed");
            ISpecification<int> rule4 = rule1.Or(rule2).Or(rule3);

            var result = rule4.ValidateWithMessages(4);

            Assert.IsTrue(result.Count > 0);
        }
开发者ID:Himansh1306,项目名称:Fluentx,代码行数:11,代码来源:Fluentester.cs


示例14: SatisfiesWithMessagesTestCase2

        public void SatisfiesWithMessagesTestCase2()
        {
            var specification = new ExpressionSpecification<String>( x => x.Length > 3, "msg1" )
                .And( x => x.StartsWith( "1" ), "msg2" );

            var actual = "234".SatisfiesWithMessages( specification )
                              .ToList();
            Assert.AreEqual( 2, actual.Count );
            Assert.AreEqual( 1, actual.Count( x => x == "msg1" ) );
            Assert.AreEqual( 1, actual.Count( x => x == "msg2" ) );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:11,代码来源:Object.Generic.SatisfiesWithMessages.Test.cs


示例15: AndTestCase11

        public void AndTestCase11()
        {
            var left = new ExpressionSpecification<String>( x => false, "msgLeft" );
            var target = left.And( x => false, "msgRight" );

            var actual = target.IsSatisfiedByWithMessages( String.Empty )
                               .ToList();

            actual.Should()
                  .HaveCount( 2 );
            actual.Should()
                  .Contain( "msgLeft", "msgRight" );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:13,代码来源:ISpecification.And.Test.cs


示例16: Main

        public static void Main()
        {
            var someBookstore = new Bookstore("Shakespeare and Company");

            var witchesAbroad = new Book("Witches abroad", Genre.Fantasy, 301);
            someBookstore.Add(witchesAbroad);
            var hatFullOfSky = new Book("Hat full of sky", Genre.Fantasy, 310);
            someBookstore.Add(hatFullOfSky);
            var gameOfThrones = new Book("Game of thrones", Genre.Fantasy, 900);
            someBookstore.Add(gameOfThrones);
            var deathOnTheNile = new Book("Death on the Nile", Genre.Crime, 400);
            someBookstore.Add(deathOnTheNile);
            var historyOfTheBalkans = new Book("History of the Balkans", Genre.History, 1120);
            someBookstore.Add(historyOfTheBalkans);

            Console.WriteLine(someBookstore);

            var ruleOnlyFantasy = new ExpressionSpecification<Book>(b => b.Genre == Genre.Fantasy);
            var ruleLargeBooks = new ExpressionSpecification<Book>(b => b.Pages > 1000);
            var rulePagesBelow500 = new ExpressionSpecification<Book>(b => b.Pages < 500);
            var ruleFantasyOrLargeBooks = ruleOnlyFantasy.Or(ruleLargeBooks);

            var allBooks = someBookstore.All();

            var largeBooks = allBooks.FindAll(b => ruleLargeBooks.IsSatisfiedBy(b));
            Console.WriteLine("Large books:");
            foreach (var book in largeBooks)
            {
                Console.WriteLine(book);
            }

            Console.WriteLine();

            var fantasyAndLargeBooks = allBooks.FindAll(b => ruleFantasyOrLargeBooks.IsSatisfiedBy(b));
            Console.WriteLine("Fantasy and large books:");
            foreach (var book in fantasyAndLargeBooks)
            {
                Console.WriteLine(book);
            }

            Console.WriteLine();
        }
开发者ID:DennyGD,项目名称:High-Quality-Code,代码行数:42,代码来源:Demo.cs


示例17: Main

        public void Main(string[] args)
        {
            var ehSolteiro = new ExpressionSpecification<Pessoa>(p => p.EstadoCivil == EstadoCivil.Solteiro);
              var ehHomem = new ExpressionSpecification<Pessoa>(p => p.Sexo == Sexo.Masculino);
              var ehHomemSolteiro = ehSolteiro & ehHomem;
              var ouHomemOuSolteiro = ehHomem ^ ehSolteiro;

              var log = new Microsoft.Framework.Logging.LoggerFactory();
              log.MinimumLevel = Microsoft.Framework.Logging.LogLevel.Verbose;

              using (var db = new PessoaDbContext())
              {
            db.Pessoas.Where(ouHomemOuSolteiro)
              .Select(x => x).ToList().ForEach(x => Console.WriteLine(x));

              }

              Console.WriteLine("Finished OK.");
              Console.ReadLine();
        }
开发者ID:msmaldi,项目名称:SpecificationPattern,代码行数:20,代码来源:Program.cs


示例18: Main

        public static void Main(string[] args)
        {
            var mobiles = new List<Mobile>() {
                new Mobile(MobileBrand.Apple, MobileType.Smart),
                new Mobile(MobileBrand.Samsung, MobileType.Smart),
                new Mobile(MobileBrand.Samsung, MobileType.Basic)
            };

            var smartSpecification = new ExpressionSpecification<Mobile>(mobile => mobile.Type == MobileType.Smart);
            var appleSpecification = new ExpressionSpecification<Mobile>(mobile => mobile.Brand == MobileBrand.Apple);
            // find all smart mobiles;
            var smartMobiles = mobiles.FindAll(mobile => smartSpecification.IsSatisfiedBy(mobile));
            // find all apple smart mobiles;
            var andSpecification = new AndSpecification<Mobile>(smartSpecification, appleSpecification);
            var appleSmartMobiles = mobiles.FindAll(mobile => andSpecification.IsSatisfiedBy(mobile));

            Console.WriteLine("Hello World!");

            Console.ReadKey();
        }
开发者ID:beginor,项目名称:DesignPatterns,代码行数:20,代码来源:Program.cs


示例19: Login

        public string Login(string username, string password)
        {
            if (string.IsNullOrEmpty(username))
            {
                return "";
            }
            var filter = new ExpressionSpecification<Employee>(
                (e) => e.UserName == username);
            var employees = repository.Find(filter);

            if (employees == null || employees.Count() == 0)
            {
                throw new ApplicationException("Invalid user name or password.");
            }

            var employee = employees.First();
            if (employee.Password != password)
            {
                throw new ApplicationException("Invalid username or password.");
            }
            return "Login successful!";
        }
开发者ID:roligee,项目名称:onlinestore,代码行数:22,代码来源:LoginManager.cs


示例20: XOrTestCase

        public void XOrTestCase()
        {
            var left = new ExpressionSpecification<String>( x => true );
            var right = new ExpressionSpecification<String>( x => true );
            var target = new XOrSpecification<String>( left, right );

            var actual = target.XOr( new ExpressionSpecification<String>( x => true ) );
            var result = actual.IsSatisfiedBy( String.Empty );
            Assert.IsTrue( result );
        }
开发者ID:MannusEtten,项目名称:Extend,代码行数:10,代码来源:OrSpecification.Test.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ExpressionStatement类代码示例发布时间:2022-05-24
下一篇:
C# ExpressionResult类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap