Programming pattern / architectural question

前端 未结 6 1411
生来不讨喜
生来不讨喜 2021-02-10 13:50

I am currently working on a project where I have a BankAccount entity for some other entity.

Each bank account as a reference to a bank entity, an account number and opt

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-10 14:36

    You can just use a delegate to validate, you don't need to pass a whole interface, who ever wants to set it has to have a validator.

    public delegate bool Validation(IBAN iban);
    void SetIBAN(IBAN iban, Validation isValid){ 
      if(!isValid(iban)) throw new ArgumentException();
    ...}
    

提交回复
热议问题