|
Imports System.Collections.Generic
Imports System.Text
Public Class Validation
Private ReadOnly m_ErrorList As New Dictionary(Of String, String)
Public ReadOnly Property ErrorCount As Integer
Get
Return m_ErrorList.Count
End Get
End Property
Public ReadOnly Property Item(ByVal propertyName As String) As String
Get
If m_ErrorList.ContainsKey(propertyName) Then
Return m_ErrorList(propertyName)
End If
Return Nothing
End Get
End Property
Public Overrides Function ToString() As String
Dim sb As New StringBuilder
For Each s In m_ErrorList.Values
sb.AppendLine(s)
Next
Return sb.ToString()
End Function
Public Sub Clear(ByVal propertyName As String)
If m_ErrorList.ContainsKey(propertyName) Then
m_ErrorList.Remove(propertyName)
End If
End Sub
Protected Sub AddValidationError(ByVal propertyName As String, ByVal message As String)
If m_ErrorList.ContainsKey(propertyName) Then
Dim existingMessage = m_ErrorList(propertyName)
If Not existingMessage.Contains(message) Then
m_ErrorList(propertyName) &= ";" & message
End If
Else
m_ErrorList.Add(propertyName, message)
End If
End Sub
End Class
|
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.
He started his career as a PDP-11 assembly language programmer in downtown Tokyo, learning what "patience" in real life means by punching a 110 baud ASR-33 Teletype frantically. He used to be able to put in the absolute loader sequence through the switch panel without consulting the DEC programming card.
Since then, his computer language experiences include 8051 assembly, FOCAL, BASIC, FORTRAN-IV, Turbo/MS C, VB. VB.NET, and C#.
Now, he lives with his wife, two grown-up kids (get out of my place!), and two cats in Westerville, Ohio.