Example #1
0
        public void Doit(TodoManager mgr)
        {
            StructValue req = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_ReqWithMessage, vf);

            req.Add(MyValueFactoryCuae._mf_code, code);
            req.Add(MyValueFactoryCuae._mf_msg, message);

            Message msg = new Message(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_CuaeClient_doit2, vf);

            msg.Add(MyValueFactoryCuae._mf_req, req);

            Mailbox mb    = svc.BeginCall(msg);
            Object  value = svc.EndCall(mb, MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_CuaeServer__result_doit2);

            if (value is Exception)
            {
                Exception e = (Exception)value;
                throw e;
            }

            StructValue resp = (StructValue)value;

            //		resp.CheckType( MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response );
            MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response.CheckIsAssignableFrom(resp.GetXType);
            Console.WriteLine("**** delayDoit2b: req {0} response {1}\n", code, resp);
            //			String m = (String) resp.Get( MyValueFactoryCuae._mf_msg );
        }
        private void testS4Import(String s, Object[] value)
        {
            StructValue sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_S4, vf);

            sv.Add(ValueFactoryTest1._mf_tipe, s);
            sv.Add(ValueFactoryTest1._mf_x, value);
            S4 myS4 = ( S4 )vf.ImportCustomValue(sv);

            Assert.AreEqual(s, myS4.tipe);
            Assert.AreEqual(value, myS4.x);
        }
        public void test_S1_import()
        {
            StructValue sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_S1, vf);

            sv.Add(ValueFactoryTest1._mf_x, 101);
            sv.Add(ValueFactoryTest1._mf_y, 103);
            sv.Add(ValueFactoryTest1._mf_z, 107);
            S1 s = ( S1 )vf.ImportCustomValue(sv);

            Assert.AreEqual(101, s.x);
            Assert.AreEqual(103, s.y);
            Assert.AreEqual(107, s.z);
        }
        private void testExcp6Import(String msg, int code, Object[] value)
        {
            StructValue sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp6, vf);

            sv.Add(ValueFactoryTest1._mf_msg, msg);
            sv.Add(ValueFactoryTest1._mf_code, code);
            sv.Add(ValueFactoryTest1._mf_x, value);
            Excp6 e = ( Excp6 )vf.ImportCustomValue(sv);

            Assert.AreEqual(msg, e.msg);
            Assert.AreEqual(code, e.code);
            Assert.AreEqual(value, e.x);
        }
Example #5
0
        public override StructValue ExportValue(ValueFactory vf, Object value)
        {
            StructValue sv = new StructValue(type, vf);

            sv.Add(field, ((URL)value).ToString());
            return(sv);
        }
Example #6
0
        public override StructValue ExportValue(ValueFactory vf, Object value)
        {
            long        ms = (((DateTime)value).ToUniversalTime().Ticks - epoch) / TICKS_PER_MS;
            StructValue sv = new StructValue(type, vf);

            sv.Add(field, ms);
            return(sv);
        }
        private void testEnumImport(E1 e, XType t, Field f)
        {
            StructValue sv = new StructValue(t, vf);

            sv.Add(f, true);
            E1 a = (E1)vf.ImportCustomValue(sv);

            Assert.AreEqual(e, a);
        }
        public void test_S2_import()
        {
            StructValue sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_S2, vf);

            sv.Add(ValueFactoryTest1._mf_a, new S1(21, 22, 23));
            sv.Add(ValueFactoryTest1._mf_b, new S1(31, 32, 33));
            sv.Add(ValueFactoryTest1._mf_c, E1.A);

            S2 s = ( S2 )vf.ImportCustomValue(sv);

            Assert.AreEqual(21, s.a.x);
            Assert.AreEqual(22, s.a.y);
            Assert.AreEqual(23, s.a.z);
            Assert.AreEqual(31, s.b.x);
            Assert.AreEqual(32, s.b.y);
            Assert.AreEqual(33, s.b.z);
            Assert.AreEqual(E1.A, s.c);
        }
Example #9
0
        private void ReadKeysAndValues(StructValue sv)
        {
            XType t = sv.GetXType;

            while (true)
            {
                Field key = ReadField(t);
                if (key == null)
                {
                    break;
                }

                //Object obj = ReadValue( intValidator, true );
                //if ( obj == NONE )
                //    break;

                //int id = ( int ) obj;
                //Field key = t.GetField( id );
                //if (key == null)
                //    key = new Field(id, id.ToString());

                Validator v = t.GetValidator(key);
                if (v != null)
                {
                    sv.Add(key, ReadValue(v));
                }
                else
                {
                    // read the value but ignore it.
                    Object obj = ReadValue(Validator_object.Get(0));
                    if (false)
                    {
                        sv.Add(key, obj);
                    }
                }
            }
        }
Example #10
0
        public override StructValue ExportValue(ValueFactory vf, Object value)
        {
            StrStrHashMap map = ( StrStrHashMap )value;

            Object[] keysAndValues = new Object[map.Count * 2];
            int      index         = 0;

            foreach (KeyValuePair <String, String> me in map)
            {
                keysAndValues[index++] = me.Key;
                keysAndValues[index++] = me.Value;
            }

            StructValue sv = new StructValue(type, vf);

            sv.Add(field, keysAndValues);
            return(sv);
        }
Example #11
0
        public override StructValue ExportValue(ValueFactory vf, Object value)
        {
            //       List<object> list = (List<object>)value;
            ArrayList list = (ArrayList)value;

            Object[] values = new Object[list.Count];
            int      index  = 0;

            foreach (object me in list)
            {
                values[index++] = me;
            }

            StructValue sv = new StructValue(type, vf);

            sv.Add(field, values);
            return(sv);
        }
Example #12
0
        public override StructValue ExportValue(ValueFactory vf, Object value)
        {
            //     Dictionary<object, object> map = (Dictionary<object, object>)value;

            Hashtable map = (Hashtable)value;

            Object[] keysAndValues = new Object[map.Count * 2];
            int      index         = 0;

            foreach (DictionaryEntry me in map)
            {
                keysAndValues[index++] = me.Key;
                keysAndValues[index++] = me.Value;
            }

            StructValue sv = new StructValue(type, vf);

            sv.Add(field, keysAndValues);
            return(sv);
        }
Example #13
0
            /**
             * Handle messages from peer.
             * @param sender
             * @param msg
             * @throws Exception
             */
            public void dispatch(Who sender, Message msg)
            {
                Console.WriteLine("msg = " + msg);
                if (msg.IsType(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_CuaeServer_doit))
                {
                    StructValue req = (StructValue)msg.Get(MyValueFactoryCuae._mf_req);
                    MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Request.CheckIsAssignableFrom(req.GetXType);
                    int?code = (int?)req.Get(MyValueFactoryCuae._mf_code);

                    // String m;
                    StructValue resp;
                    switch (code.GetValueOrDefault())
                    {
                    case 23:
                        resp = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "foo");
                        delayDoit2a(7);
                        break;

                    case 19:
                        resp =
                            new StructValue(
                                MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_RespWithCode, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "bar");
                        resp.Add(MyValueFactoryCuae._mf_code, 54);
                        delayDoit2b(11, "heaven");
                        break;

                    case 13:
                        resp = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "baz");
                        delayDoit2a(99);
                        break;

                    default:
                        resp =
                            new StructValue(
                                MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_RespWithCode, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, " unknown code " + code);
                        resp.Add(MyValueFactoryCuae._mf_code, 63);
                        delayDoit2b(23, "killer bee");
                        break;
                    }



                    Message rmsg = msg.Reply();
                    Console.WriteLine("rmsg = " + rmsg);
                    Console.WriteLine("resp = " + resp);
                    rmsg.Add(MyValueFactoryCuae._mf_result, resp);
                    svc.TransportMessage(sender, rmsg);
                    return;
                }

                if (msg.IsType(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_CuaeServer_doit3))
                {
                    StructValue[] reqs = (StructValue[])msg.Get(MyValueFactoryCuae._mf_req);
                    StructValue   req  = reqs[0];
                    MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Request.CheckIsAssignableFrom(
                        req.GetXType);
                    int?code = (int?)req.Get(MyValueFactoryCuae._mf_code);

                    StructValue resp;
                    switch (code.GetValueOrDefault())
                    {
                    case 23:
                        resp =
                            new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "foo");
                        delayDoit2a(7);
                        break;

                    case 19:
                        resp = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_RespWithCode, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "bar");
                        resp.Add(MyValueFactoryCuae._mf_code, 54);
                        delayDoit2b(11, "heaven");
                        break;

                    case 13:
                        resp =
                            new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "baz");
                        delayDoit2a(99);
                        break;

                    default:
                        resp = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_RespWithCode, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "unknown code " + code);
                        resp.Add(MyValueFactoryCuae._mf_code, 63);
                        delayDoit2b(23, "killer bee");
                        break;
                    }

                    Message rmsg = msg.Reply();
                    Console.WriteLine("rmsg = " + rmsg);
                    Console.WriteLine("resp = " + resp);
                    rmsg.Add(MyValueFactoryCuae._mf_result, new StructValue[] { resp });
                    svc.TransportMessage(sender, rmsg);
                    return;
                }


                throw new Exception("unknown msg type " + msg);
            }
        public void test_excps_import()
        {
            Object[] boolObject   = new Object[] { ConstsTest1.BOOL1, ConstsTest1.BOOL2 };
            Object[] byteObject   = new Object[] { ConstsTest1.BYTE1, ConstsTest1.BYTE2, ConstsTest1.BYTE3, ConstsTest1.BYTE4, ConstsTest1.BYTE5 };
            Object[] shortObject  = new Object[] { ConstsTest1.SHORT1, ConstsTest1.SHORT2, ConstsTest1.SHORT3, ConstsTest1.SHORT4, ConstsTest1.SHORT5 };
            Object[] intObject    = new Object[] { ConstsTest1.INT1, ConstsTest1.INT2, ConstsTest1.INT3, ConstsTest1.INT4, ConstsTest1.INT5 };
            Object[] longObject   = new Object[] { ConstsTest1.LONG1, ConstsTest1.LONG2, ConstsTest1.LONG3, ConstsTest1.LONG4, ConstsTest1.LONG5 };
            Object[] floatObject  = new Object[] { ConstsTest1.FLOAT1, ConstsTest1.FLOAT2, ConstsTest1.FLOAT3, ConstsTest1.FLOAT4, ConstsTest1.FLOAT5 };
            Object[] doubleObject = new Object[] { ConstsTest1.DOUBLE1, ConstsTest1.DOUBLE2, ConstsTest1.DOUBLE3, ConstsTest1.DOUBLE4, ConstsTest1.DOUBLE5 };
            Object[] stringObject = new Object[] { ConstsTest1.STRING1, ConstsTest1.STRING2, ConstsTest1.STRING3, ConstsTest1.STRING4, ConstsTest1.STRING5 };

            String msg  = "Exception";
            int    code = 500;

            StructValue sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp1, vf);

            sv.Add(ValueFactoryTest1._mf_msg, "def");
            sv.Add(ValueFactoryTest1._mf_code, 29);
            Excp1 e1 = ( Excp1 )vf.ImportCustomValue(sv);

            Assert.AreEqual("def", e1.msg);
            Assert.AreEqual(29, e1.code);
            e1 = null;

            sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp2, vf);
            Excp2 e2 = ( Excp2 )vf.ImportCustomValue(sv);

            Assert.IsNotNull(e2);
            e2 = null;

            sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp3, vf);
            Excp3 e3 = ( Excp3 )vf.ImportCustomValue(sv);

            Assert.IsNotNull(e3);
            e3 = null;

            sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp4, vf);
            Excp4 e4 = ( Excp4 )vf.ImportCustomValue(sv);

            Assert.IsNotNull(e4);
            e4 = null;

            // Import exception with object as param
            testExcp5Import(msg, code, ConstsTest1.BOOL2);
            testExcp5Import(msg, code, ConstsTest1.BYTE5);
            testExcp5Import(msg, code, ConstsTest1.SHORT5);
            testExcp5Import(msg, code, ConstsTest1.INT5);
            testExcp5Import(msg, code, ConstsTest1.LONG5);
            testExcp5Import(msg, code, ConstsTest1.FLOAT5);
            testExcp5Import(msg, code, ConstsTest1.DOUBLE5);
            testExcp5Import(msg, code, ConstsTest1.STRING3);

            // Import exception with array of object as param
            testExcp6Import(msg, code, boolObject);
            testExcp6Import(msg, code, byteObject);
            testExcp6Import(msg, code, shortObject);
            testExcp6Import(msg, code, intObject);
            testExcp6Import(msg, code, longObject);
            testExcp6Import(msg, code, floatObject);
            testExcp6Import(msg, code, doubleObject);
            testExcp6Import(msg, code, stringObject);
        }