How to Use EViL

EViL was designed with two goals in mind: 1) to give developers something useful right out of the box and 2) to give developers an easy way to extend EViL as they see fit.

To Use EViL Out of the Box

1. Add a reference to the EViL assembly.
2. Make your entities inherit from EvilBaseEntity.
3. Decorate the properties on your entities with whatever combination of attributes you need.
4. Invoke the IsValid method on your entity.

More info about EvilBaseEntity
To use any of the EViL attributes, your entity classes MUST inherit from this abstract class because this is where the base implementation of the IsValid method and the ValidationErrors collection are found. If you have an existing base class from which your entities already inherit from, you can simply make your base class inherit from EvilBaseEntity and you're good to go.
  • IsValid: This method takes care of collecting all the validation attributes on the entity and then invoking them appropriately.
  • ValidationErrors: This string collection contains the list of all error messages that have occured during validation. This collection can be used to display all validation error messages to the user.

To Extend EViL By Creating Your Own Custom Attributes

1. Add a reference to the EViL assembly.
2. Make your own attributes inherit from EvilBaseAttribute.
3. Provide implementation for ValidateValue.

More info about EvilBaseAttribute
All of the EViL attributes inherit from this abstract attribute class, which provides the base constructor and the base Message property. It also provides an abstract method named ValidateValue that all derived classes must implement. Therefore, if you want to create your own custom validation attributes, simply inherit from EvilBaseAttribute and provide the implementation for ValidateValue.

Last edited Dec 6, 2006 at 8:37 PM by Arcware, version 3


No comments yet.