mirror of
https://github.com/Smaug123/WoofWare.PawPrint
synced 2025-10-11 08:48:38 +00:00
Rejig test harness (#68)
This commit is contained in:
27
WoofWare.PawPrint.Test/sourcesPure/CustomDelegate.cs
Normal file
27
WoofWare.PawPrint.Test/sourcesPure/CustomDelegate.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
public delegate bool MyFilter(object item, object criteria);
|
||||
|
||||
public class DelegateDemo
|
||||
{
|
||||
// This static field initialization will generate the exact IL pattern:
|
||||
public static readonly MyFilter FilterField = FilterImpl;
|
||||
|
||||
// The static method that the delegate points to
|
||||
private static bool FilterImpl(object item, object criteria)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int Main(string[] argv)
|
||||
{
|
||||
// Force static constructor to run
|
||||
var filter = FilterField;
|
||||
|
||||
// Test the delegate
|
||||
bool result = filter("test item", "criterion");
|
||||
if (result)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user