Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ship
- public bool Validate()
- {
- //validate properties only found on a ship
- FurtherValidate();
- }
- public abstract bool FurtherValidate();
- public override bool FurtherValidate()
- {
- //validate properties only found on a lifeboat
- }
- public class Ship
- {
- public virtual bool Validate()
- {
- //validate properties only found on a ship
- return true;
- }
- }
- public class Lifeboat : Ship
- {
- public override bool Validate()
- {
- base.Validate();
- // lifeboat specific code
- return true;
- }
- }
- protected abstract bool FurtherValidate();
- protected IValidator FurtherValidation { private get; set; }
- public bool Validate()
- {
- //validate properties only found on a ship
- if (FurtherValidation == null)
- throw new ValidationIsRequiredException();
- if (!FurtherValidation.IsValid(this))
- // logic for invalid state
- }
Add Comment
Please, Sign In to add comment