2 // MonoTests.Remoting.ServerObject.cs
\r
4 // Author: Lluis Sanchez Gual (lluis@ximian.com)
\r
6 // 2003 (C) Copyright, Ximian, Inc.
\r
10 using System.Runtime.Remoting;
\r
11 using System.Runtime.Remoting.Lifetime;
\r
12 using System.Collections;
\r
13 using NUnit.Framework;
\r
15 namespace MonoTests.Remoting
\r
17 // A list of ServerObject instances
\r
19 [ContextHook("x", false)]
\r
20 public class ServerList:
\r
21 ContextBoundObject,
\r
24 ArrayList values = new ArrayList();
\r
25 public int NumVal = 0;
\r
26 public string StrVal = "val";
\r
30 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
31 CallSeq.Add ("List created");
\r
34 public void Dispose()
\r
36 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
37 CallSeq.Add ("List disposed");
\r
41 public void Add (ServerObject v)
\r
43 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
45 CallSeq.Add ("Added " + v.Name);
\r
48 public void ProcessItems ()
\r
50 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
51 CallSeq.Add ("Processing");
\r
54 foreach (ServerObject ob in values)
\r
55 total += ob.GetValue();
\r
57 CallSeq.Add ("Total: " + total);
\r
62 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
63 CallSeq.Add ("Clearing");
\r
67 public void ParameterTest1 (int a, out string b)
\r
69 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
73 public void ParameterTest2 (int a, out int b)
\r
75 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
79 public ServerObject NewItem(string name)
\r
81 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
82 ServerObject obj = new ServerObject(name);
\r
87 public ServerObject CreateItem(string name, int val)
\r
89 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
90 ServerObject obj = new ServerObject(name);
\r
95 public ComplexData SetComplexData (ComplexData data)
\r
97 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
98 CallSeq.Add ("Showing content of ComplexData");
\r
103 public override ObjRef CreateObjRef (Type type)
\r
105 Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
\r
106 CallSeq.Add ("### ServerList.CreateObjRef");
\r
107 return base.CreateObjRef (type);
\r
111 // A remotable object
\r
113 public class ServerObject:
\r
114 // ContextBoundObject
\r
120 public ServerObject (string name)
\r
127 get { return _name; }
\r
130 public void SetValue (int v)
\r
132 CallSeq.Add ("ServerObject " + _name + ": setting " + v);
\r
136 public int GetValue ()
\r
138 CallSeq.Add ("ServerObject " + _name + ": getting " + _value);
\r
142 public override ObjRef CreateObjRef (Type type)
\r
144 CallSeq.Add ("### ServerObject.CreateObjRef");
\r
145 return base.CreateObjRef (type);
\r
149 // Some complex data for testing serialization
\r
151 public enum AnEnum { a,b,c,d,e };
\r
154 public class ComplexData
\r
156 public AnEnum Val = AnEnum.a;
\r
158 public object[] Info;
\r
160 public ComplexData (AnEnum va, object[] info)
\r
166 public void Dump ()
\r
168 CallSeq.Add ("Content:");
\r
169 CallSeq.Add ("Val: " + Val);
\r
170 foreach (object ob in Info)
\r
171 CallSeq.Add ("Array item: " + ob);
\r