Framework Structure of business Verification Code
Delegated business Verification processing:
Public Delegate function rulehandler (byval target as object, byval e as ruleargs) as Boolean
Target: The data object to be processed.
E: Verify the rule parameter. This parameter will guide the execution of the verification method. This parameter must contain at least the name of the data item to be verified on the target and other verification conditions.
<Serializable ()> public class ruleargs
Private mpropertyname as string
Public readonly property propertyname () as string
Get
Return mpropertyname
End get
End Property
Public sub new (byval propertyname as string)
Mpropertyname = propertyname
End sub
End Class
Create a verification rule Manager. The verification rule Manager uses the verification name to manage the verification rules (which must be applied to hybriddictionary). The management of verification includes at least adding verification and performing verification.
Public class rulesmanage
'Add verification rules. All verification rules are saved by hybriddictionary.
Public sub addrule (byval handler as rulehandler, byval rulename as string, byval ruleargs as ruleargs)
'Perform verification. The verification execution is completed by the rulehandler stored in hybriddictionary. The target processing is guided by rulename, and rulename corresponds to ruleargs, ruleargs contains the name of the verification data and other verification criteria
Public sub checkrules (byval target as object, byval rulename as string)
End sub