Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / tests / generic-xdomain.2.cs
1 using System;
2 using System.ComponentModel;
3 using System.Runtime.Remoting;
4
5 namespace Test {
6         public class Test {
7                 static void Main ()
8                 {
9                         AppDomain domain = AppDomain.CreateDomain ("new-domain");
10                         domain.DoCallBack (Run);
11                         Type stType = typeof (Something<string, string>);
12                         Other<string, string> st = (Other<string, string>) domain.CreateInstanceAndUnwrap (stType.Assembly.FullName, stType.FullName);
13                         Console.WriteLine ("in main int: {0}", st.getInt ());
14                         Console.WriteLine ("in main types: {0}", st.getTypeNames<Test> ());
15                 }
16
17                 public static void Run ()
18                 {
19                     DoRun<string, string>(new Something<string, string> ());
20                 }
21
22                 public static void DoRun<T1, T2> (Other<T1, T2> some)
23                 {
24                         Console.WriteLine ("domain: {0}", AppDomain.CurrentDomain.FriendlyName);
25                         Console.WriteLine ("This is null: {0}", some.Mappings == null);
26                         Console.WriteLine ("int: {0}", some.getInt ());
27                 }
28         }
29
30         public class Other<T1, T2> : MarshalByRefObject {
31                 public T2 Mappings {
32                         get { return default(T2); }
33                 }
34
35                 public virtual int getInt () {
36                         return 123;
37                 }
38
39                 public virtual string getTypeNames<T3> () {
40                         return "error";
41                 }
42         }
43
44         public class Something<T1, T2> : Other<T1,T2> {
45                 public override int getInt () {
46                         return 456;
47                 }
48
49                 public override string getTypeNames<T3> () {
50                         Console.WriteLine ("getTypeNames in {0}", AppDomain.CurrentDomain.FriendlyName);
51                         return typeof(T1).ToString () + " " + typeof(T2).ToString () + " " + typeof (T3).ToString ();
52                 }
53         }
54 }