public ServerObject NewItem(string name)
		{
			Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
			ServerObject obj = new ServerObject(name);
			Add (obj);
			return obj;
		}
		public ServerObject CreateItem(string name, int val)
		{
			Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
			ServerObject obj = new ServerObject(name);
			obj.SetValue (val);
			return obj;
		}
Exemplo n.º 3
0
		void RunTestObject (ServerList list)
		{
			DynProperty prop1 = new DynProperty("defcontext");
			DynProperty prop2 = new DynProperty("proxy");

			try
			{
				Context.RegisterDynamicProperty (prop1, null, Context.DefaultContext);
				Context.RegisterDynamicProperty (prop2, list, null);

				CallSeq.Add(">> Clear");
				list.GetType().GetMethod ("Clear").Invoke (list, null);
				CallSeq.Add("<< Clear");

				CallSeq.Add(">> Set fields");
				list.NumVal = 4;
				list.StrVal = "hi";
				CallSeq.Add("<< Set fields");

				CallSeq.Add(">> Get fields");
				int nv = list.NumVal;
				string sv = list.StrVal;
				CallSeq.Add("<< Get fields");
				CallSeq.Add ("Get fields Result: " + nv + " / " + sv);

				CallSeq.Add(">> ParameterTest1");
				string b;
				list.ParameterTest1 (112, out b);
				CallSeq.Add("<< ParameterTest1");
				CallSeq.Add("ParameterTest1 Result: " + b);

				CallSeq.Add(">> ParameterTest2");
				int bn;
				list.ParameterTest2 (112, out bn);
				CallSeq.Add("<< ParameterTest2");
				CallSeq.Add("ParameterTest2 Result: " + bn);

				// These are remote calls that return references to remote objects

				CallSeq.Add (">> Creating two remote items");
				ServerObject item0 = list.CreateItem ("S0", 33);

				item0.SetValue (55);
				list.Add (item0);

				ServerObject item1 = list.NewItem ("S1");
				item1.SetValue (111);
				ServerObject item2 = list.NewItem ("S2");
				item2.SetValue (222);
				CallSeq.Add ("<< Creating two remote items");

				// Two objects created in this client app

				CallSeq.Add (">> Creating two client items");
				ServerObject item3 = new ServerObject ("C1");
				item3.SetValue (333);
				ServerObject item4 = new ServerObject ("C2");
				item4.SetValue (444);
				CallSeq.Add ("<< Creating two client items");

				// Object references passed to the remote list

				CallSeq.Add (">> Adding items");
				list.Add (item3);
				list.Add (item4);
				CallSeq.Add ("<< Adding items");

				// This sums all values of the ServerObjects in the list. The server
				// makes a remote call to this client to get the value of the
				// objects created locally

				CallSeq.Add (">> Processing items");
				list.ProcessItems ();
				CallSeq.Add ("<< Processing items");
			}
			catch (Exception ex)
			{
				Console.WriteLine ("ERR:" + ex.ToString());
				throw;
			}
			
			Context.UnregisterDynamicProperty ("defcontext", null, Context.DefaultContext);
			Context.UnregisterDynamicProperty ("proxy", list, null);
		}
		public void Add (ServerObject v)
		{
			Assert.IsTrue (RemotingServices.IsTransparentProxy(this));
			values.Add (v);
			CallSeq.Add ("Added " + v.Name);
		}
Exemplo n.º 5
0
 public void Add(ServerObject v)
 {
     Assert.IsTrue(RemotingServices.IsTransparentProxy(this));
     values.Add(v);
     CallSeq.Add("Added " + v.Name);
 }