Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface Validatable {
- public void validate() throws ValidateException;
- }
- interface Object1Validatable {
- public void validate(Object1Converse converse) throws ValidateException;
- }
- class Object1 implements Object1Validatable {
- ...
- public void validate() throws ValidateException {
- throw new UnsupportedOperationException();
- }
- }
- class Object2 implements Validatable {
- ...
- public void validate() throws ValidateException {
- ...
- }
- }
- interface Object1Validatable {
- public void validate(Object1Converse converse) throws ValidateException;
- }
- class Object1 implements Object1Validatable {
- ...
- public void validate(Object1Converse converse) throws ValidateException {
- ...
- }
- }
- interface Object2Validatable {
- public void validate() throws ValidateException;
- }
- class Object2 implements Object2Validatable {
- ...
- public void validate() throws ValidateException {
- ...
- }
- }
- interface Validatable {
- void validate(Validator v);
- }
- class Object1 implements Validatable{
- void validate(Validator v){
- v.foo
- v.bar
- }
- }
- class Object1Converse implements Validator{
- //....
- }
- class Object2 implements Validatable{
- void validate(Validator v){
- //do whatever you need and ingore validator ?
- }
- }
- public class MyClass {
- //Properties and methods here
- }
- public class MyClassValidator : IValidator<MyClass> {
- IList<IValidatorError> IValidator.Validate(MyClass obj) {
- //Perform some checks here
- }
- }
- //...
- public void RegisterValidators() {
- Validators.Add<MyClassValidator>();
- }
- //...
- public void PerformSomeLogic() {
- var myobj = new MyClass { };
- //Set some properties, call some methods, etc.
- var v = Validators.Get<MyClass>();
- if(v.GetErrors(myobj).Count() > 0)
- throw new Exception();
- SaveToDatabase(myobj);
- }
- interface Validateable
- {
- }
- interface EmptyValidateable inherits Validateable //Or is it implements?
- {
- void validate() throws ValidateException;
- }
- interface Objectvalidateable inherits Validateable
- {
- void validate(Object validateObj);
- }
Add Comment
Please, Sign In to add comment