/
generic-marshalbyref.2.cs
81 lines (66 loc) · 1.36 KB
/
generic-marshalbyref.2.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
static class Program
{
static int Main()
{
DocumentForm<object> browseForm = new DocumentForm<object> ();
if (browseForm.DoInit () != 248)
return 1;
var domain = AppDomain.CreateDomain ("foo");
var engine = Engine.CreateRemote (domain);
if (engine.GetDomainName<object> () != "foo")
return 2;
return 0;
}
}
public abstract class EntityBase
{
}
public class GenEntity<T> : EntityBase
{
}
class DocumentForm<T>
{
internal int DoInit()
{
var g = new Grid1<GenEntity<T>>(123);
var g2 = new Grid2<GenEntity<T>>(123);
return g.num + g2.num;
}
}
public class Grid1<TEntity> : MarshalByRefObject
{
public int num;
public Grid1 (int i)
{
num = i + 1;
}
}
public class Grid2<TEntity> : MarshalByRefObject where TEntity : EntityBase, new()
{
public int num;
public Grid2 (int i)
{
num = i + 1;
}
}
public class Engine : MarshalByRefObject
{
public Engine ()
{
}
public string GetDomainName<T> ()
{
return AppDomain.CurrentDomain.FriendlyName;
}
public string GetDomainName ()
{
return AppDomain.CurrentDomain.FriendlyName;
}
public static Engine CreateRemote (AppDomain domain)
{
return (Engine) domain.CreateInstanceAndUnwrap (
typeof (Engine).Assembly.FullName,
typeof (Engine).FullName);
}
}