-
Notifications
You must be signed in to change notification settings - Fork 0
/
task4.cs
57 lines (47 loc) · 987 Bytes
/
task4.cs
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
public struct ApiSetup<T>
{ }
class Api
{
public ApiSetup<T> For<T>(T obj)
{
return new ApiSetup<T>();
}
}
interface ISomeInterfaceA
{ }
interface ISomeInterfaceB
{ }
public class ObjectA : ISomeInterfaceA
{ }
public class ObjectB : ISomeInterfaceB
{ }
static class MyExtensionsApi
{
public static ApiSetup<ObjectA> For(this Api api, ObjectA obj)
{
return api.For<ObjectA>(obj);
}
public static ApiSetup<ObjectB> For(this Api api, ObjectB obj)
{
return api.For<ObjectB>(obj);
}
}
static class MyExtensionsObjectA
{
public static void SetupObjectA(this ApiSetup<ObjectA> setup)
{ }
}
static class MyExtensionsObjectB
{
public static void SetupObjectB(this ApiSetup<ObjectB> setup)
{ }
}
class Program
{
static void Main(string[] args)
{
Api apiObject = new Api();
apiObject.For(new ObjectA()).SetupObjectA();
apiObject.For(new ObjectB()).SetupObjectB();
}
}