Posts

Showing posts with the label Predicate

Donate

Predicate Wrapper Custom Class in C#

Based from this post: Predicate Wrapper Custom Class in VB.NET , here's the equivalent classes in C#. FindTrack class: public class SystemTrack { public int ID { get ; set ; } public string Author { get ; set ; } public string Title { get ; set ; } public static bool FindIndexTrackNumber(SystemTrack systrac, int searchArg) { return systrac.ID.Equals(searchArg); } } Predicate Class: public delegate bool PredicateWrapperDelegate<T, A>(T item, A argument); public class PredicateWrapper <T, A> { private A _argument; private PredicateWrapperDelegate<T, A> _wrapperDelegate; public PredicateWrapper(A argument, PredicateWrapperDelegate<T, A> wrapperDelegate) { _argument = argument; _wrapperDelegate = wrapperDelegate; } private bool InnerPredicate(T item) { return ...

Predicate Wrapper Custom Class in VB.NET

Here's a custom predicate wrapper class I got from visual basic forums. I'll be converting and posting the C# equivalent for this. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Public Delegate Function PredicateWrapperDelegate( Of T, A) _ ( ByVal item As T, ByVal argument As A) As Boolean Public Class PredicateWrapper ( Of T, A) Private _argument As A Private _wrapperDelegate As PredicateWrapperDelegate( Of T, A) Public Sub New( ByVal argument As A, _ ByVal wrapperDelegate As PredicateWrapperDelegate( Of T, A)) _argument = argument _wrapperDelegate = wrapperDelegate End Sub Private Function InnerPredicate( ByVal item As T) As Boolean Return _wrapperDelegate(item, _argument) End Function Public Shared Widening Operator CType ( _ ByVal wrapper As PredicateWrapper( Of T, A)) _ As Predicate( Of T) Return New Predicate( Of T...

Donate