2 using System
.Security
.Policy
;
3 using System
.Runtime
.Remoting
;
4 using System
.Threading
;
8 class MBRTest
: MarshalByRefObject
12 return (int) AppDomain
.CurrentDomain
.GetData("test_integer");
18 return (string) AppDomain
.CurrentDomain
.GetData("test_string");
24 return (bool) AppDomain
.CurrentDomain
.GetData("test_bool");
30 return (int []) AppDomain
.CurrentDomain
.GetData("test_array");
37 Console
.WriteLine ("Friendly name: " + AppDomain
.CurrentDomain
.FriendlyName
);
39 AppDomain newDomain
= AppDomain
.CreateDomain ("NewDomain");
41 if (!RemotingServices
.IsTransparentProxy(newDomain
))
44 // First test that this domain get's the right data from the other domain
45 newDomain
.SetData ("test_string", "a");
47 object t
= newDomain
.GetData("test_string");
48 if (t
.GetType() != typeof(string))
51 if ((string) newDomain
.GetData ("test_string") != "a")
54 newDomain
.SetData ("test_integer", 1);
55 if ((int) newDomain
.GetData ("test_integer") != 1)
58 newDomain
.SetData ("test_bool", true);
59 if ((bool)newDomain
.GetData ("test_bool") != true)
62 newDomain
.SetData ("test_bool", false);
63 if ((bool)newDomain
.GetData ("test_bool") != false)
66 int [] ta
= { 1, 2, 3 }
;
67 newDomain
.SetData ("test_array", ta
);
69 int [] ca
= (int [])newDomain
.GetData ("test_array");
71 if (ca
[0] != 1 || ca
[1] != 2 || ca
[2] != 3)
74 // Creata a MBR object to test that the other domain has the correct info
75 MBRTest test
= (MBRTest
) newDomain
.CreateInstanceAndUnwrap (typeof(MBRTest
).Assembly
.FullName
, typeof(MBRTest
).FullName
);
77 if (!RemotingServices
.IsTransparentProxy(test
))
80 // Time to test that the newDomain also have the same info
87 if (test
.Bool
!= false)
92 if (ca
[0] != 1 || ca
[1] != 2 || ca
[2] != 3)
95 Console
.WriteLine("test-ok");