Imports Microsoft.Practices.EnterpriseLibrary.Validation Imports System.Globalization Imports System.Reflection Namespace Common.Entities.Net35 ''' <summary> ''' This helper class was copied from the ASP.NET VAB integration. ''' </summary> Friend Class PropertyMappedValidatorValueAccessBuilder Inherits MemberValueAccessBuilder Protected Overrides Function DoGetFieldValueAccess(ByVal fieldInfo As FieldInfo) As ValueAccess Throw New NotSupportedException() End Function Protected Overrides Function DoGetMethodValueAccess(ByVal methodInfo As MethodInfo) As ValueAccess Throw New NotSupportedException() End Function Protected Overrides Function DoGetPropertyValueAccess(ByVal propertyInfo As PropertyInfo) As ValueAccess Return New PropertyMappedValidatorValueAccess(propertyInfo.Name) End Function End Class ''' <summary> ''' This helper class was copied from the ASP.NET VAB integration. ''' </summary> Friend Class PropertyMappedValidatorValueAccess Inherits ValueAccess Private propertyName As String Public Sub New(ByVal propertyName As String) Me.propertyName = propertyName End Sub Public Overrides Function GetValue(ByVal source As Object, ByRef value As Object, ByRef valueAccessFailureMessage As String) As Boolean value = Nothing valueAccessFailureMessage = Nothing Dim validator As EnterpriseValidationRule = CType(source, EnterpriseValidationRule) If (Me.propertyName.Equals(validator.PropertyName)) Then Return validator.GetValue(value, valueAccessFailureMessage) End If valueAccessFailureMessage = String.Format(CultureInfo.CurrentUICulture, _ "The property name ""{0}"" is not mapped to validators in the naming context.", _ Me.propertyName) Return False End Function Public Overrides ReadOnly Property Key() As String Get Return Me.propertyName End Get End Property End Class End Namespace
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)