Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Constraints.Constraint that accepts a predicate as the constrai…
…nt. Closes #14.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
' ___________________________________________________ | ||
' | ||
' (c) Hi-Integrity Systems 2012. All rights reserved. | ||
' www.hisystems.com.au - Toby Wicks | ||
' ___________________________________________________ | ||
' | ||
|
||
Option Strict On | ||
Option Explicit On | ||
|
||
Namespace Constraints | ||
|
||
''' <summary> | ||
''' </summary> | ||
Public Class Constraint(Of T) | ||
Implements IConstraint(Of T) | ||
|
||
Private pobjPredicate As Func(Of T, Boolean) | ||
|
||
Public Sub New(ByVal objPredicate As Func(Of T, Boolean)) | ||
|
||
If objPredicate Is Nothing Then | ||
Throw New ArgumentNullException | ||
End If | ||
|
||
pobjPredicate = objPredicate | ||
|
||
End Sub | ||
|
||
Private Function ValueSatisfiesConstraint(value As T) As Boolean Implements IConstraint(Of T).ValueSatisfiesConstraint | ||
|
||
Return pobjPredicate.Invoke(value) | ||
|
||
End Function | ||
|
||
End Class | ||
|
||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters