public void TestSameContext () { CallSeq.Init("TestSameContext"); CallSeq.Add (">> TestSameContext"); CallSeq.Add (">> Creating instance"); ServerList list = new ServerList(); CallSeq.Add ("<< Creating instance"); RunTestObject (list); CallSeq.Add ("<< TestSameContext"); CallSeq.Check (Checks.seqSameContext,1); }
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); }