<dfn id="w48us"></dfn><ul id="w48us"></ul>
  • <ul id="w48us"></ul>
  • <del id="w48us"></del>
    <ul id="w48us"></ul>
  • asp.net 組合模式的PHP代碼

    時間:2024-10-07 12:35:26 ASP 我要投稿
    • 相關推薦

    asp.net 組合模式的PHP代碼

      復制代碼 代碼如下:

      using System;

      using System.Collections.Generic;

      using System.Linq;

      using System.Text;

      namespace Test

      {

      class Program

      {

      static void Main(string[] args)

      {

      var customer = new Customer

      {

      IsActive = true,

      LateFees = 100M,

      TotalRentNumber = 10

      };

      Console.WriteLine(customer.CanRent());

      Console.ReadKey();

      }

      }

      public interface ISpecification

      {

      ///

      /// 是否可以租賃

      ///

      bool IsSatisfiedBy(T entity);

      ///

      /// 與操作

      ///

      ISpecificationAnd(ISpecificationother);

      ///

      /// 否操作

      ///

      ISpecificationNot();

      }

      ///

      /// 基類

      ///

      public abstract class CompositeSpecification: ISpecification

      {

      public abstract bool IsSatisfiedBy(T candidate);

      public ISpecificationAnd(ISpecificationother)

      {

      return new AndSpecification(this, other);

      }

      public ISpecificationNot()

      {

      return new NotSpecification(this);

      }

      }

      ///

      /// 與操作

      ///

      public class AndSpecification: CompositeSpecification

      {

      private ISpecificationleftSpecification;

      private ISpecificationrightSpecification;

      public AndSpecification(ISpecificationleftSpecification, ISpecificationrightSpecification)

      {

      this.leftSpecification = leftSpecification;

      this.rightSpecification = rightSpecification;

      }

      public override bool IsSatisfiedBy(T entity)

      {

      return leftSpecification.IsSatisfiedBy(entity) && rightSpecification.IsSatisfiedBy(entity);

      }

      }

      ///

      ///否操作

      ///

      public class NotSpecification: CompositeSpecification

      {

      private ISpecificationinnerSpecification;

      public NotSpecification(ISpecificationinnerSpecification)

      {

      this.innerSpecification = innerSpecification;

      }

      public override bool IsSatisfiedBy(T entity)

      {

      return !innerSpecification.IsSatisfiedBy(entity);

      }

      }

      ///

      /// 是否達到最大的規定租賃數

      ///

      public class HasReachedMaxSpecification : CompositeSpecification

      {

      public override bool IsSatisfiedBy(Customer entity)

      {

      return entity.TotalRentNumber > 5;

      }

      }

      ///

      /// 是否激活

      ///

      public class CustomerActiveSpecification : CompositeSpecification

      {

      public override bool IsSatisfiedBy(Customer entity)

      {

      return entity.IsActive;

      }

      }

      ///

      /// 是否欠費

      ///

      public class CustomerHasLateFeesSpecification : CompositeSpecification

      {

      public override bool IsSatisfiedBy(Customer entity)

      {

      return entity.LateFees > 0;

      }

      }

      public class Customer

      {

      private ISpecificationhasReachedRentalThreshold;

      private ISpecificationcustomerIsActive;

      private ISpecificationcustomerHasLateFees;

      public Customer()

      {

      hasReachedRentalThreshold = new HasReachedMaxSpecification();

      customerIsActive = new CustomerActiveSpecification();

      customerHasLateFees = new CustomerHasLateFeesSpecification();

      }

      ///

      /// 用戶租賃DVD數量

      ///

      public int TotalRentNumber

      {

      get;

      set;

      }

      ///

      /// 賬戶是否激活

      ///

      public bool IsActive

      {

      get;

      set;

      }

      ///

      /// 用戶之前是否還欠費

      ///

      public decimal LateFees

      {

      get;

      set;

      }

      public bool CanRent()

      {

      ISpecificationcanRent = customerIsActive.And(hasReachedRentalThreshold.Not()).And(customerHasLateFees.Not());

      return canRent.IsSatisfiedBy(this);

      }

      }

      }

    【asp.net 組合模式的PHP代碼】相關文章:

    php數組函數序列之array-combine() - 數組合并函數的代碼08-25

    php如何過濾危險html代碼09-21

    將php實現過濾UBB代碼09-11

    php對圖像的各種處理函數代碼總結07-03

    如何在cmd下面寫php代碼01-22

    ASP.NET連SQL7接口的源代碼06-06

    PHP url 加密解密函數代碼方法10-25

    企業薪酬設計基本模式及組合模式02-26

    關于PHP var-dump遍歷對象屬性的函數與應用代碼06-21

    關于ASP.NET使用JavaScript顯示信息提示窗口實現原理及代碼05-09

    主站蜘蛛池模板: 欧美精品亚洲精品日韩专区| 93精91精品国产综合久久香蕉| 成人一区二区三区精品| 久久99精品综合国产首页| 精品久久久久久综合日本| 国语自产少妇精品视频蜜桃| 99久久久国产精品免费无卡顿| 国产亚洲精品自在久久| 久久91综合国产91久久精品| 亚洲欧美精品伊人久久| 国产精品国产高清国产专区| 久久久久99精品成人片牛牛影视| 男女男精品视频网站在线观看| 亚洲午夜国产精品无码老牛影视| 精品无码国产自产拍在线观看| 国产精品55夜色66夜色| 国产精品内射婷婷一级二| 久久国产成人亚洲精品影院| 亚洲精品中文字幕无码蜜桃| 91精品国产福利在线导航| 国产激情精品一区二区三区| 热久久国产欧美一区二区精品| 精品三级AV无码一区| 国产精品性爱| 国产精品自在线拍国产| 精品乱码久久久久久夜夜嗨| 国产精品18久久久久久vr| 国产在线精品福利大全| 国产剧情国产精品一区| 蜜臀av无码人妻精品| 久久精品国产一区二区三区日韩| 欧美成人精品欧美一级乱黄一区二区精品在线| 精品人妻va出轨中文字幕| 国产亚洲精品a在线观看 | 亚洲国产精品欧美日韩一区二区| 久久91这里精品国产2020| 久久se精品一区二区| 四虎成人精品永久免费AV| 久久国产午夜精品一区二区三区| 黄床大片免费30分钟国产精品 | 99久久免费只有精品国产|