-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathDelegateFlow.cs
More file actions
158 lines (128 loc) · 2.33 KB
/
DelegateFlow.cs
File metadata and controls
158 lines (128 loc) · 2.33 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using System;
class DelegateFlow
{
void M1(int i) { }
static void M2(Action<int> a)
{
a(0);
a = _ => { };
a(1);
}
void M3()
{
M2(_ => { });
M2(M1);
}
void M4(Action<int> a)
{
M2(a);
}
void M5()
{
M4(_ => { });
M4(M1);
}
void M6(Action<Action<int>> aa, Action<int> a)
{
aa(a);
}
void M7()
{
M6(a => { a(1); }, M1);
}
Action<int> Prop
{
get { return _ => { }; }
set { value(0); }
}
void M8()
{
dynamic d = this;
d.Prop = d.Prop;
}
static Func<Action<int>> F = () => _ => { };
void M9()
{
F()(0);
}
Action<int> M10()
{
return _ => { };
}
void M11()
{
M10()(0);
}
public delegate void EventHandler();
public event EventHandler Click;
public void M12()
{
Click += M11;
Click();
M13(M9);
}
public void M13(EventHandler eh)
{
Click += eh;
Click();
}
public void M13()
{
void M14(MyDelegate d) => d();
M14(new MyDelegate(M9));
M14(new MyDelegate(new MyDelegate(M11)));
M14(M12);
M14(() => { });
}
public void M14()
{
void LocalFunction(int i) { };
M2(LocalFunction);
}
public void M15()
{
Func<int> f = () => 42;
new Lazy<int>(f);
f = () => 43;
new Lazy<int>(f);
}
public delegate void MyDelegate();
public unsafe void M16(delegate*<Action<int>, void> fnptr, Action<int> a)
{
fnptr(a);
}
public unsafe void M17()
{
M16(&M2, (i) => { });
}
public unsafe void M18()
{
delegate*<Action<int>, void> fnptr = &M2;
fnptr((i) => { });
}
void M19(Action a, bool b)
{
if (b)
a = () => { };
a();
}
void M20(bool b) => M19(() => { }, b);
Action<int> Field;
Action<int> Prop2 { get; set; }
DelegateFlow(Action<int> a, Action<int> b)
{
Field = a;
Prop2 = b;
}
void M20()
{
new DelegateFlow(
_ => { },
_ => { }
);
this.Field(0);
this.Prop2(0);
Field(0);
Prop2(0);
}
}