3 using System
.ComponentModel
;
4 using System
.Diagnostics
;
8 public sealed class FooClass
<S
> where S
: class
10 public static FooClass
<S
> Create(string name
, Action
<S
> action
)
12 return new FooClass
<S
>(name
, action
);
15 public static FooClass
<S
> Create
<T
>(S source
, string name
,
16 Func
<S
, T
> func
, FooClass
<T
> fooChild
)
19 return new FooClass
<S
>(source
, name
, CreateCallback(func
, fooChild
));
22 private static Action
<S
> CreateCallback
<T
>(
23 Func
<S
, T
> func
, FooClass
<T
> fooChild
)
26 return delegate(S source
)
31 private FooClass(string name
, Action
<S
> action
)
37 private FooClass(S source
, string name
, Action
<S
> action
)
44 readonly string m_name
;
50 public int Value { get; set; }
51 public MyClass Child { get; set; }
54 public class VarCompilerTest
57 public static void Main(string[] args
)
59 MyClass obj
= new MyClass();
61 FooClass
<MyClass
> fooChild
= FooClass
<MyClass
>.Create("Value", delegate { nCalls++; }
);
62 FooClass
<MyClass
>.Create(obj
, "Child", x
=> x
.Child
, fooChild
);