Ok... first a little background information on how the verification is executed based on a trigger or setting of a property.
If you take a look at the generated code (xxxDataRow class) for a property, in the setter you will see the following:
public virtual System.String LastName {
get {
System.String result_;
if (GetInterceptor<System.String>("LastName", GetLastNameImpl, out result_)) return result_;
return GetLastNameImpl();
}
[System.Diagnostics.DebuggerNonUserCode]
set {
if (BeforeSetValue("LastName", value)) {
if (!SetInterceptor<System.String>("LastName", value, SetLastNameImpl)) {
SetLastNameImpl(value);
}
AfterSetValue("LastName");
}
}
}
It is the base implementation of the BeforeSetValue (preset) and AfterSetValue (postset) methods that makes a call to the VerifierEngine. Here is the code for BeforeSetValue:
/// <summary>
/// Override this method to perform any logic before a column value is set. Make sure to
/// call the base implementation if you want any registered preset verifiers to execute.
/// </summary>
/// <param name="pPropertyName"></param>
/// <param name="pProposedValue"></param>
/// <returns></returns>
protected virtual bool BeforeSetValue(string pPropertyName, Object pProposedValue) {
VerifierResultCollection results = this.VerifierEngine.Execute(this, pPropertyName, pProposedValue);
if (!results.AreOk) {
throw new VerifierResultException(results);
}
return true;
}
You can override the above method in your entity class and, for that particular property, not throw an exception but cache the results instead. At this point your entity class would have the verification results.
Edited by eileenv - 05-Feb-2009 at 5:15pm