IdeaBlade.Validation Assembly > IdeaBlade.Validation Namespace > DelegateVerifier<T> Class > DelegateVerifier<T> Constructor : DelegateVerifier<T> Constructor(String,VerifierCondition<T>) |
'Declaration
Public Function New( _ ByVal errorMessage As String, _ ByVal verifierCondition As IdeaBlade.Validation.VerifierCondition(Of T) _ )
'Usage
Dim errorMessage As String Dim verifierCondition As IdeaBlade.Validation.VerifierCondition(Of T) Dim instance As New DelegateVerifier(Of T)(errorMessage, verifierCondition)
public DelegateVerifier<T>( string errorMessage, IdeaBlade.Validation.VerifierCondition<T> verifierCondition )
private DelegateVerifier SampleDelegateVerifier() { // A simple example adding a delegate verifier for the Employee HireDate property. // This verifier could more easily be handled using a DateTimeRangeVerifier, // but is intended to show the parts to a DelegateVerifier. string errorMessage = "HireDate must be greater than MinValue"; // Define the verification test. VerifierCondition<Employee> condition = (emp, trigger, ctx) => { // Note when executed before the property is set that we must inspect the ProposedValue. DateTime? hireDate = (trigger.Timing == TriggerTiming.BeforeSet) ? (DateTime?) trigger.ProposedValue : emp.HireDate; return new VerifierResult(hireDate >= DateTime.Parse("1/1/2000")); }; // Create the verifier. var v = new DelegateVerifier<Employee>(errorMessage, condition); // Add a trigger - here it's the HireDate property. v.AddTrigger(Employee.PropertyMetadata.HireDate.Name); return v; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2