blob: ca1897e84f35cae310ef92542f91845313bfc5fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
using System;
class TestA
{
public string value;
public TestA (string value)
{
this.value = value;
}
public string Select<U> (Func<TestA, U> f)
{
return value;
}
}
static class TestB
{
static public TestA Where(this TestA a, Func<TestA,bool> predicate)
{
if (predicate (a))
return new TestA ("where used");
return null;
}
}
public class CustomQueryExpressionPattern
{
public static int Main ()
{
var v = new TestA ("Oh yes");
string foo = from a in v select a;
if (foo != "Oh yes")
return 1;
v = new TestA ("where?");
// It also tests that select is not called in this case
v = from a in v where a.value != "wrong" select a;
if (v.value != "where used")
return 1;
Console.WriteLine (v.value.ToString ());
return 0;
}
}
|