Ejemplo n.º 1
0
        internal static Ice.Current CreateCurrent(int requestId, Ice.InputStream requestFrame,
                                                  Ice.ObjectAdapter adapter, Ice.Connection?connection = null)
        {
            var identity = new Ice.Identity(requestFrame);

            // For compatibility with the old FacetPath.
            string[] facetPath = requestFrame.ReadStringArray();
            if (facetPath.Length > 1)
            {
                throw new Ice.MarshalException();
            }
            string facet     = facetPath.Length == 0 ? "" : facetPath[0];
            string operation = requestFrame.ReadString();
            var    mode      = requestFrame.ReadByte();

            if (mode > 2)
            {
                throw new Ice.MarshalException(
                          $"received invalid operation mode `{mode}' with operation `{operation}'");
            }
            bool idempotent = mode > 0;
            var  context    = requestFrame.ReadContext();

            Ice.EncodingVersion encoding = requestFrame.StartEncapsulation();

            return(new Ice.Current(adapter, identity, facet, operation, idempotent, context,
                                   requestId, connection, encoding));
        }
Ejemplo n.º 2
0
 public IceInternal.Endpoint Read(Ice.InputStream s)
 {
     Ice.EndpointType type = (Ice.EndpointType)s.ReadShort();
     Debug.Assert(type == _factory.Type());
     IceInternal.Endpoint endpoint = new Endpoint(_factory.Read(s));
     return(endpoint);
 }
Ejemplo n.º 3
0
        internal WSEndpoint(TransportInstance instance, Endpoint del, Ice.InputStream s)
        {
            _instance = instance;
            _delegate = del;

            _resource = s.ReadString();
        }
Ejemplo n.º 4
0
        public void opString(Ice.AsyncResult result)
        {
            string cmp = testString;
            if(_useCookie)
            {
                Cookie cookie = (Cookie)result.AsyncState;
                cmp = cookie.getString();
            }

            byte[] outEncaps;
            if(result.getProxy().end_ice_invoke(out outEncaps, result))
            {
                Ice.InputStream inS = new Ice.InputStream(_communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(cmp));
                s = inS.readString();
                test(s.Equals(cmp));
                inS.endEncapsulation();
                callback.called();
            }
            else
            {
                test(false);
            }
        }
Ejemplo n.º 5
0
 public IPEndpoint(TransportInstance instance, Ice.InputStream s)
 {
     Instance      = instance;
     Host          = s.ReadString();
     Port          = s.ReadInt();
     SourceAddr    = null;
     ConnectionId_ = "";
 }
Ejemplo n.º 6
0
 public UdpEndpoint(TransportInstance instance, Ice.InputStream s) :
     base(instance, s)
 {
     // Not transmitted.
     //_connect = s.readBool();
     _connect  = false;
     _compress = s.ReadBool();
 }
Ejemplo n.º 7
0
        private static void PrintRequestHeader(System.IO.StringWriter s, Ice.InputStream str)
        {
            PrintIdentityFacetOperation(s, str);

            try
            {
                byte mode = str.ReadByte();
                s.Write("\noperation mode = " + (int)mode + ' ');
                switch (mode)
                {
                case 0:
                {
                    s.Write("(non-idempotent)");
                    break;
                }

                case 1:
                {
                    s.Write("(idempotent/nonmutating)");
                    break;
                }

                case 2:
                {
                    s.Write("(idempotent)");
                    break;
                }

                default:
                {
                    s.Write("(unknown)");
                    break;
                }
                }

                int sz = str.ReadSize();
                s.Write("\ncontext = ");
                while (sz-- > 0)
                {
                    string key = str.ReadString();
                    string val = str.ReadString();
                    s.Write(key + '/' + val);
                    if (sz > 0)
                    {
                        s.Write(", ");
                    }
                }

                Ice.Encoding v = str.SkipEncapsulation();
                s.Write("\nencoding = ");
                s.Write(v.ToString());
            }
            catch (System.IO.IOException)
            {
                Debug.Assert(false);
            }
        }
Ejemplo n.º 8
0
 public override Task<Ice.Object_Ice_invokeResult> ice_invokeAsync(byte[] inParams, Ice.Current current)
 {
     Ice.Communicator communicator = current.adapter.getCommunicator();
     Ice.InputStream inS = new Ice.InputStream(communicator, inParams);
     inS.startEncapsulation();
     Ice.OutputStream outS = new Ice.OutputStream(communicator);
     outS.startEncapsulation();
     if(current.operation.Equals("opOneway"))
     {
         return Task.FromResult<Ice.Object_Ice_invokeResult>(new Ice.Object_Ice_invokeResult(true, new byte[0]));
     }
     else if(current.operation.Equals("opString"))
     {
         string s = inS.readString();
         outS.writeString(s);
         outS.writeString(s);
         outS.endEncapsulation();
         return Task.FromResult<Ice.Object_Ice_invokeResult>(new Ice.Object_Ice_invokeResult(true, outS.finished()));
     }
     else if(current.operation.Equals("opException"))
     {
         Test.MyException ex = new Test.MyException();
         outS.writeException(ex);
         outS.endEncapsulation();
         return Task.FromResult<Ice.Object_Ice_invokeResult>(new Ice.Object_Ice_invokeResult(false, outS.finished()));
     }
     else if(current.operation.Equals("shutdown"))
     {
         communicator.shutdown();
         return Task.FromResult<Ice.Object_Ice_invokeResult>(new Ice.Object_Ice_invokeResult(true, null));
     }
     else if(current.operation.Equals("ice_isA"))
     {
         string s = inS.readString();
         if(s.Equals("::Test::MyClass"))
         {
             outS.writeBool(true);
         }
         else
         {
             outS.writeBool(false);
         }
         outS.endEncapsulation();
         return Task.FromResult<Ice.Object_Ice_invokeResult>(new Ice.Object_Ice_invokeResult(true, outS.finished()));
     }
     else
     {
         Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
         ex.id = current.id;
         ex.facet = current.facet;
         ex.operation = current.operation;
         throw ex;
     }
 }
Ejemplo n.º 9
0
        private static void PrintRequest(System.IO.StringWriter s, Ice.InputStream str)
        {
            int requestId = str.ReadInt();

            s.Write("\nrequest id = " + requestId);
            if (requestId == 0)
            {
                s.Write(" (oneway)");
            }

            PrintRequestHeader(s, str);
        }
Ejemplo n.º 10
0
        private static void PrintBatchRequest(System.IO.StringWriter s, Ice.InputStream str)
        {
            int batchRequestNum = str.ReadInt();

            s.Write("\nnumber of requests = " + batchRequestNum);

            for (int i = 0; i < batchRequestNum; ++i)
            {
                s.Write("\nrequest #" + i + ':');
                PrintRequestHeader(s, str);
            }
        }
Ejemplo n.º 11
0
        private static void PrintReply(System.IO.StringWriter s, Ice.InputStream str)
        {
            int requestId = str.ReadInt();

            s.Write("\nrequest id = " + requestId);

            var replyStatus = (ReplyStatus)str.ReadByte();

            s.Write($"\nreply status = {replyStatus}");

            if (replyStatus == ReplyStatus.OK || replyStatus == ReplyStatus.UserException)
            {
                _ = str.SkipEncapsulation();
                s.Write("\nencoding = ");
            }
        }
Ejemplo n.º 12
0
        internal static void TraceRecv(Ice.InputStream str, Ice.ILogger logger, TraceLevels tl)
        {
            if (tl.Protocol >= 1)
            {
                int p = str.Pos;
                str.Pos = 0;

                using (var s = new System.IO.StringWriter(CultureInfo.CurrentCulture))
                {
                    Ice1Definitions.MessageType type = PrintMessage(s, str);

                    logger.Trace(tl.ProtocolCat, "received " + GetMessageTypeAsString(type) + " " + s.ToString());
                }
                str.Pos = p;
            }
        }
Ejemplo n.º 13
0
        internal static void Trace(string heading, Ice.InputStream str, Ice.ILogger logger, TraceLevels tl)
        {
            if (tl.Protocol >= 1)
            {
                int p = str.Pos;
                str.Pos = 0;

                using (var s = new System.IO.StringWriter(CultureInfo.CurrentCulture))
                {
                    s.Write(heading);
                    PrintMessage(s, str);

                    logger.Trace(tl.ProtocolCat, s.ToString());
                }
                str.Pos = p;
            }
        }
Ejemplo n.º 14
0
        private static byte PrintMessage(System.IO.StringWriter s, Ice.InputStream str)
        {
            byte type = PrintHeader(s, str);

            switch (type)
            {
            case Ice1Definitions.CloseConnectionMessage:
            case Ice1Definitions.ValidateConnectionMessage:
            {
                // We're done.
                break;
            }

            case Ice1Definitions.RequestMessage:
            {
                PrintRequest(s, str);
                break;
            }

            case Ice1Definitions.RequestBatchMessage:
            {
                PrintBatchRequest(s, str);
                break;
            }

            case Ice1Definitions.ReplyMessage:
            {
                PrintReply(s, str);
                break;
            }

            default:
            {
                s.Write("(unknown)");
                break;
            }
            }

            return(type);
        }
Ejemplo n.º 15
0
        private static void PrintIdentityFacetOperation(System.IO.StringWriter s, Ice.InputStream str)
        {
            try
            {
                Ice.ToStringMode toStringMode = str.Communicator.ToStringMode;

                var identity = new Ice.Identity(str);
                s.Write("\nidentity = " + identity.ToString(toStringMode));

                string[] facet = str.ReadStringArray();
                s.Write("\nfacet = ");
                if (facet.Length > 0)
                {
                    s.Write(IceUtilInternal.StringUtil.EscapeString(facet[0], "", toStringMode));
                }

                string operation = str.ReadString();
                s.Write("\noperation = " + operation);
            }
            catch (System.IO.IOException)
            {
                Debug.Assert(false);
            }
        }
Ejemplo n.º 16
0
 protected virtual void readImpl__(InputStream is__)
 {
 }
Ejemplo n.º 17
0
 public virtual void read__(InputStream is__)
 {
     is__.startException();
     readImpl__(is__);
     is__.endException(false);
 }
Ejemplo n.º 18
0
    static public int run(Ice.Communicator communicator)
#endif
    {
        MyClassFactoryWrapper factoryWrapper = new MyClassFactoryWrapper();

        communicator.getValueFactoryManager().add(factoryWrapper.create, Test.MyClass.ice_staticId());
        communicator.getValueFactoryManager().add(MyInterfaceFactory, Test.MyInterfaceDisp_.ice_staticId());

        Ice.InputStream  @in;
        Ice.OutputStream @out;

        Write("testing primitive types... ");
        Flush();

        {
            byte[] data = new byte[0];
            @in = new Ice.InputStream(communicator, data);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.startEncapsulation();
            @out.writeBool(true);
            @out.endEncapsulation();
            byte[] data = @out.finished();

            @in = new Ice.InputStream(communicator, data);
            @in.startEncapsulation();
            test(@in.readBool());
            @in.endEncapsulation();

            @in = new Ice.InputStream(communicator, data);
            @in.startEncapsulation();
            test(@in.readBool());
            @in.endEncapsulation();
        }

        {
            byte[] data = new byte[0];
            @in = new Ice.InputStream(communicator, data);
            try
            {
                @in.readBool();
                test(false);
            }
            catch (Ice.UnmarshalOutOfBoundsException)
            {
            }
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeBool(true);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readBool());
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeByte((byte)1);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readByte() == (byte)1);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeShort((short)2);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readShort() == (short)2);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeInt(3);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readInt() == 3);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeLong(4);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readLong() == 4);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeFloat((float)5.0);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readFloat() == (float)5.0);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeDouble(6.0);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readDouble() == 6.0);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeString("hello world");
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readString().Equals("hello world"));
        }

        WriteLine("ok");

        Write("testing constructed types... ");
        Flush();

        {
            int max = 2;
            @out = new Ice.OutputStream(communicator);
            @out.writeEnum((int)Test.MyEnum.enum3, max);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyEnum e = (Test.MyEnum)@in.readEnum(max);
            test(e == Test.MyEnum.enum3);
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.SmallStruct s = new Test.SmallStruct();
            s.bo  = true;
            s.by  = (byte)1;
            s.sh  = (short)2;
            s.i   = 3;
            s.l   = 4;
            s.f   = (float)5.0;
            s.d   = 6.0;
            s.str = "7";
            s.e   = Test.MyEnum.enum2;
            s.p   = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
            s.write__(@out);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.SmallStruct s2 = new Test.SmallStruct();
            s2.read__(@in);
            test(s2.Equals(s));
        }

        {
            @out = new Ice.OutputStream(communicator);
            OptionalClass o = new OptionalClass();
            o.bo = true;
            o.by = (byte)5;
            o.sh = 4;
            o.i  = 3;
            @out.writeObject(o);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            TestReadObjectCallback cb = new TestReadObjectCallback();
            @in.readObject(cb.invoke);
            @in.readPendingObjects();
            OptionalClass o2 = (OptionalClass)cb.obj;
            test(o2.bo == o.bo);
            test(o2.by == o.by);
            if (communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0"))
            {
                test(!o2.sh.HasValue);
                test(!o2.i.HasValue);
            }
            else
            {
                test(o2.sh.Value == o.sh.Value);
                test(o2.i.Value == o.i.Value);
            }
        }

        {
            @out = new Ice.OutputStream(communicator, Ice.Util.Encoding_1_0);
            OptionalClass o = new OptionalClass();
            o.bo = true;
            o.by = 5;
            o.sh = 4;
            o.i  = 3;
            @out.writeObject(o);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, Ice.Util.Encoding_1_0, data);
            TestReadObjectCallback cb = new TestReadObjectCallback();
            @in.readObject(cb.invoke);
            @in.readPendingObjects();
            OptionalClass o2 = (OptionalClass)cb.obj;
            test(o2.bo == o.bo);
            test(o2.by == o.by);
            test(!o2.sh.HasValue);
            test(!o2.i.HasValue);
        }

        {
            bool[] arr =
            {
                true,
                false,
                true,
                false
            };
            @out = new Ice.OutputStream(communicator);
            Ice.BoolSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            bool[] arr2 = Ice.BoolSeqHelper.read(@in);
            test(Compare(arr2, arr));

            bool[][] arrS =
            {
                arr,
                new bool[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.BoolSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            bool[][] arr2S = Test.BoolSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            byte[] arr =
            {
                (byte)0x01,
                (byte)0x11,
                (byte)0x12,
                (byte)0x22
            };
            @out = new Ice.OutputStream(communicator);
            Ice.ByteSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            byte[] arr2 = Ice.ByteSeqHelper.read(@in);
            test(Compare(arr2, arr));

            byte[][] arrS =
            {
                arr,
                new byte[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.ByteSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            byte[][] arr2S = Test.ByteSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

#if !COMPACT && !SILVERLIGHT
        {
            Serialize.Small small = new Serialize.Small();
            small.i = 99;
            @out    = new Ice.OutputStream(communicator);
            @out.writeSerializable(small);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Serialize.Small small2 = (Serialize.Small)@in.readSerializable();
            test(small2.i == 99);
        }
#endif

        {
            short[] arr =
            {
                (short)0x01,
                (short)0x11,
                (short)0x12,
                (short)0x22
            };
            @out = new Ice.OutputStream(communicator);
            Ice.ShortSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            short[] arr2 = Ice.ShortSeqHelper.read(@in);
            test(Compare(arr2, arr));

            short[][] arrS =
            {
                arr,
                new short[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.ShortSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            short[][] arr2S = Test.ShortSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            int[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            Ice.IntSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            int[] arr2 = Ice.IntSeqHelper.read(@in);
            test(Compare(arr2, arr));

            int[][] arrS =
            {
                arr,
                new int[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.IntSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            int[][] arr2S = Test.IntSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            long[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            Ice.LongSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            long[] arr2 = Ice.LongSeqHelper.read(@in);
            test(Compare(arr2, arr));

            long[][] arrS =
            {
                arr,
                new long[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.LongSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            long[][] arr2S = Test.LongSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            float[] arr =
            {
                (float)1,
                (float)2,
                (float)3,
                (float)4
            };
            @out = new Ice.OutputStream(communicator);
            Ice.FloatSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            float[] arr2 = Ice.FloatSeqHelper.read(@in);
            test(Compare(arr2, arr));

            float[][] arrS =
            {
                arr,
                new float[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.FloatSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            float[][] arr2S = Test.FloatSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            double[] arr =
            {
                (double)1,
                (double)2,
                (double)3,
                (double)4
            };
            @out = new Ice.OutputStream(communicator);
            Ice.DoubleSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            double[] arr2 = Ice.DoubleSeqHelper.read(@in);
            test(Compare(arr2, arr));

            double[][] arrS =
            {
                arr,
                new double[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.DoubleSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            double[][] arr2S = Test.DoubleSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            @out = new Ice.OutputStream(communicator);
            Ice.StringSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            string[] arr2 = Ice.StringSeqHelper.read(@in);
            test(Compare(arr2, arr));

            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.StringSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            string[][] arr2S = Test.StringSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = new Ice.OutputStream(communicator);
            Test.MyEnumSHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyEnum[] arr2 = Test.MyEnumSHelper.read(@in);
            test(Compare(arr2, arr));

            Test.MyEnum[][] arrS =
            {
                arr,
                new Test.MyEnum[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.MyEnumSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            Test.MyEnum[][] arr2S = Test.MyEnumSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        Test.SmallStruct[] smallStructArray = new Test.SmallStruct[3];
        for (int i = 0; i < smallStructArray.Length; ++i)
        {
            smallStructArray[i]     = new Test.SmallStruct();
            smallStructArray[i].bo  = true;
            smallStructArray[i].by  = (byte)1;
            smallStructArray[i].sh  = (short)2;
            smallStructArray[i].i   = 3;
            smallStructArray[i].l   = 4;
            smallStructArray[i].f   = (float)5.0;
            smallStructArray[i].d   = 6.0;
            smallStructArray[i].str = "7";
            smallStructArray[i].e   = Test.MyEnum.enum2;
            smallStructArray[i].p   = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
        }

        Test.MyClass[] myClassArray = new Test.MyClass[4];
        for (int i = 0; i < myClassArray.Length; ++i)
        {
            myClassArray[i]         = new Test.MyClass();
            myClassArray[i].c       = myClassArray[i];
            myClassArray[i].o       = myClassArray[i];
            myClassArray[i].s       = new Test.SmallStruct();
            myClassArray[i].s.e     = Test.MyEnum.enum2;
            myClassArray[i].seq1    = new bool[] { true, false, true, false };
            myClassArray[i].seq2    = new byte[] { (byte)1, (byte)2, (byte)3, (byte)4 };
            myClassArray[i].seq3    = new short[] { (short)1, (short)2, (short)3, (short)4 };
            myClassArray[i].seq4    = new int[] { 1, 2, 3, 4 };
            myClassArray[i].seq5    = new long[] { 1, 2, 3, 4 };
            myClassArray[i].seq6    = new float[] { (float)1, (float)2, (float)3, (float)4 };
            myClassArray[i].seq7    = new double[] { (double)1, (double)2, (double)3, (double)4 };
            myClassArray[i].seq8    = new string[] { "string1", "string2", "string3", "string4" };
            myClassArray[i].seq9    = new Test.MyEnum[] { Test.MyEnum.enum3, Test.MyEnum.enum2, Test.MyEnum.enum1 };
            myClassArray[i].seq10   = new Test.MyClass[4]; // null elements.
            myClassArray[i].d       = new System.Collections.Generic.Dictionary <string, Test.MyClass>();
            myClassArray[i].d["hi"] = myClassArray[i];
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.MyClassSHelper.write(@out, myClassArray);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyClass[] arr2 = Test.MyClassSHelper.read(@in);
            @in.readPendingObjects();
            test(arr2.Length == myClassArray.Length);
            for (int i = 0; i < arr2.Length; ++i)
            {
                test(arr2[i] != null);
                test(arr2[i].c == arr2[i]);
                test(arr2[i].o == arr2[i]);
                test(arr2[i].s.e == Test.MyEnum.enum2);
                test(Compare(arr2[i].seq1, myClassArray[i].seq1));
                test(Compare(arr2[i].seq2, myClassArray[i].seq2));
                test(Compare(arr2[i].seq3, myClassArray[i].seq3));
                test(Compare(arr2[i].seq4, myClassArray[i].seq4));
                test(Compare(arr2[i].seq5, myClassArray[i].seq5));
                test(Compare(arr2[i].seq6, myClassArray[i].seq6));
                test(Compare(arr2[i].seq7, myClassArray[i].seq7));
                test(Compare(arr2[i].seq8, myClassArray[i].seq8));
                test(Compare(arr2[i].seq9, myClassArray[i].seq9));
                test(arr2[i].d["hi"].Equals(arr2[i]));
            }

            Test.MyClass[][] arrS =
            {
                myClassArray,
                new Test.MyClass[0],
                myClassArray
            };
            @out = new Ice.OutputStream(communicator);
            Test.MyClassSSHelper.write(@out, arrS);
            data = @out.finished();
            @in  = new Ice.InputStream(communicator, data);
            Test.MyClass[][] arr2S = Test.MyClassSSHelper.read(@in);
            test(arr2S.Length == arrS.Length);
            test(arr2S[0].Length == arrS[0].Length);
            test(arr2S[1].Length == arrS[1].Length);
            test(arr2S[2].Length == arrS[2].Length);
        }

        {
            Test.MyInterface i = new MyInterfaceI();
            @out = new Ice.OutputStream(communicator);
            @out.writeObject(i);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            TestReadObjectCallback cb = new TestReadObjectCallback();
            @in.readObject(cb.invoke);
            @in.readPendingObjects();
            test(cb.obj != null);
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.MyClass obj = new Test.MyClass();
            obj.s   = new Test.SmallStruct();
            obj.s.e = Test.MyEnum.enum2;
            TestObjectWriter writer = new TestObjectWriter(obj);
            @out.writeObject(writer);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            test(writer.called);
            factoryWrapper.setFactory(TestObjectFactory);
            @in = new Ice.InputStream(communicator, data);
            TestReadObjectCallback cb = new TestReadObjectCallback();
            @in.readObject(cb.invoke);
            @in.readPendingObjects();
            test(cb.obj != null);
            test(cb.obj is TestObjectReader);
            TestObjectReader reader = (TestObjectReader)cb.obj;
            test(reader.called);
            test(reader.obj != null);
            test(reader.obj.s.e == Test.MyEnum.enum2);
            factoryWrapper.setFactory(null);
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.MyException ex = new Test.MyException();

            Test.MyClass c = new Test.MyClass();
            c.c     = c;
            c.o     = c;
            c.s     = new Test.SmallStruct();
            c.s.e   = Test.MyEnum.enum2;
            c.seq1  = new bool[] { true, false, true, false };
            c.seq2  = new byte[] { (byte)1, (byte)2, (byte)3, (byte)4 };
            c.seq3  = new short[] { (short)1, (short)2, (short)3, (short)4 };
            c.seq4  = new int[] { 1, 2, 3, 4 };
            c.seq5  = new long[] { 1, 2, 3, 4 };
            c.seq6  = new float[] { (float)1, (float)2, (float)3, (float)4 };
            c.seq7  = new double[] { (double)1, (double)2, (double)3, (double)4 };
            c.seq8  = new string[] { "string1", "string2", "string3", "string4" };
            c.seq9  = new Test.MyEnum[] { Test.MyEnum.enum3, Test.MyEnum.enum2, Test.MyEnum.enum1 };
            c.seq10 = new Test.MyClass[4]; // null elements.
            c.d     = new Dictionary <string, Test.MyClass>();
            c.d.Add("hi", c);

            ex.c = c;

            @out.writeException(ex);
            byte[] data = @out.finished();

            @in = new Ice.InputStream(communicator, data);
            try
            {
                @in.throwException();
                test(false);
            }
            catch (Test.MyException ex1)
            {
                test(ex1.c.s.e == c.s.e);
                test(Compare(ex1.c.seq1, c.seq1));
                test(Compare(ex1.c.seq2, c.seq2));
                test(Compare(ex1.c.seq3, c.seq3));
                test(Compare(ex1.c.seq4, c.seq4));
                test(Compare(ex1.c.seq5, c.seq5));
                test(Compare(ex1.c.seq6, c.seq6));
                test(Compare(ex1.c.seq7, c.seq7));
                test(Compare(ex1.c.seq8, c.seq8));
                test(Compare(ex1.c.seq9, c.seq9));
            }
            catch (Ice.UserException)
            {
                test(false);
            }
        }

        {
            Dictionary <byte, bool> dict = new Dictionary <byte, bool>();
            dict.Add((byte)4, true);
            dict.Add((byte)1, false);
            @out = new Ice.OutputStream(communicator);
            Test.ByteBoolDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary <byte, bool> dict2 = Test.ByteBoolDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary <short, int> dict = new Dictionary <short, int>();
            dict.Add((short)1, 9);
            dict.Add((short)4, 8);
            @out = new Ice.OutputStream(communicator);
            Test.ShortIntDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary <short, int> dict2 = Test.ShortIntDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary <long, float> dict = new Dictionary <long, float>();
            dict.Add((long)123809828, (float)0.51f);
            dict.Add((long)123809829, (float)0.56f);
            @out = new Ice.OutputStream(communicator);
            Test.LongFloatDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary <long, float> dict2 = Test.LongFloatDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary <string, string> dict = new Dictionary <string, string>();
            dict.Add("key1", "value1");
            dict.Add("key2", "value2");
            @out = new Ice.OutputStream(communicator);
            Test.StringStringDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary <string, string> dict2 = Test.StringStringDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary <string, Test.MyClass> dict = new Dictionary <string, Test.MyClass>();
            Test.MyClass c;
            c     = new Test.MyClass();
            c.s   = new Test.SmallStruct();
            c.s.e = Test.MyEnum.enum2;
            dict.Add("key1", c);
            c     = new Test.MyClass();
            c.s   = new Test.SmallStruct();
            c.s.e = Test.MyEnum.enum3;
            dict.Add("key2", c);
            @out = new Ice.OutputStream(communicator);
            Test.StringMyClassDHelper.write(@out, dict);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary <string, Test.MyClass> dict2 = Test.StringMyClassDHelper.read(@in);
            @in.readPendingObjects();
            test(dict2.Count == dict.Count);
            test(dict2["key1"].s.e == Test.MyEnum.enum2);
            test(dict2["key2"].s.e == Test.MyEnum.enum3);
        }

        {
            bool[] arr =
            {
                true,
                false,
                true,
                false
            };
            @out = new Ice.OutputStream(communicator);
            List <bool> l = new List <bool>(arr);
            Test.BoolListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List <bool> l2 = Test.BoolListHelper.read(@in);
            test(Compare(l, l2));
        }

        {
            byte[] arr =
            {
                (byte)0x01,
                (byte)0x11,
                (byte)0x12,
                (byte)0x22
            };
            @out = new Ice.OutputStream(communicator);
            List <byte> l = new List <byte>(arr);
            Test.ByteListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List <byte> l2 = Test.ByteListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = new Ice.OutputStream(communicator);
            List <Test.MyEnum> l = new List <Test.MyEnum>(arr);
            Test.MyEnumListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List <Test.MyEnum> l2 = Test.MyEnumListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            List <Test.SmallStruct> l = new List <Test.SmallStruct>(smallStructArray);
            Test.SmallStructListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List <Test.SmallStruct> l2 = Test.SmallStructListHelper.read(@in);
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i].Equals(smallStructArray[i]));
            }
        }

        {
            @out = new Ice.OutputStream(communicator);
            List <Test.MyClass> l = new List <Test.MyClass>(myClassArray);
            Test.MyClassListHelper.write(@out, l);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List <Test.MyClass> l2 = Test.MyClassListHelper.read(@in);
            @in.readPendingObjects();
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i] != null);
                test(l2[i].c == l2[i]);
                test(l2[i].o == l2[i]);
                test(l2[i].s.e == Test.MyEnum.enum2);
                test(Compare(l2[i].seq1, l[i].seq1));
                test(Compare(l2[i].seq2, l[i].seq2));
                test(Compare(l2[i].seq3, l[i].seq3));
                test(Compare(l2[i].seq4, l[i].seq4));
                test(Compare(l2[i].seq5, l[i].seq5));
                test(Compare(l2[i].seq6, l[i].seq6));
                test(Compare(l2[i].seq7, l[i].seq7));
                test(Compare(l2[i].seq8, l[i].seq8));
                test(Compare(l2[i].seq9, l[i].seq9));
                test(l2[i].d["hi"].Equals(l2[i]));
            }
        }

        {
            Test.MyClassPrx[] arr = new Test.MyClassPrx[2];
            arr[0] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("zero"));
            arr[1] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("one"));
            @out   = new Ice.OutputStream(communicator);
            List <Test.MyClassPrx> l = new List <Test.MyClassPrx>(arr);
            Test.MyClassProxyListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List <Test.MyClassPrx> l2 = Test.MyClassProxyListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            short[] arr =
            {
                (short)0x01,
                (short)0x11,
                (short)0x12,
                (short)0x22
            };
            @out = new Ice.OutputStream(communicator);
            LinkedList <short> l = new LinkedList <short>(arr);
            Test.ShortLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            LinkedList <short> l2 = Test.ShortLinkedListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            int[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            LinkedList <int> l = new LinkedList <int>(arr);
            Test.IntLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            LinkedList <int> l2 = Test.IntLinkedListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = new Ice.OutputStream(communicator);
            LinkedList <Test.MyEnum> l = new LinkedList <Test.MyEnum>(arr);
            Test.MyEnumLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            LinkedList <Test.MyEnum> l2 = Test.MyEnumLinkedListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            LinkedList <Test.SmallStruct> l = new LinkedList <Test.SmallStruct>(smallStructArray);
            Test.SmallStructLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            LinkedList <Test.SmallStruct> l2 = Test.SmallStructLinkedListHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator <Test.SmallStruct> e  = l.GetEnumerator();
            IEnumerator <Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            long[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            Stack <long> l = new Stack <long>(arr);
            Test.LongStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack <long> l2 = Test.LongStackHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            float[] arr =
            {
                (float)1,
                (float)2,
                (float)3,
                (float)4
            };
            @out = new Ice.OutputStream(communicator);
            Stack <float> l = new Stack <float>(arr);
            Test.FloatStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack <float> l2 = Test.FloatStackHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            Stack <Test.SmallStruct> l = new Stack <Test.SmallStruct>(smallStructArray);
            Test.SmallStructStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack <Test.SmallStruct> l2 = Test.SmallStructStackHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator <Test.SmallStruct> e  = l.GetEnumerator();
            IEnumerator <Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            Test.MyClassPrx[] arr = new Test.MyClassPrx[2];
            arr[0] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("zero"));
            arr[1] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("one"));
            @out   = new Ice.OutputStream(communicator);
            Stack <Test.MyClassPrx> l = new Stack <Test.MyClassPrx>(arr);
            Test.MyClassProxyStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack <Test.MyClassPrx> l2 = Test.MyClassProxyStackHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            double[] arr =
            {
                (double)1,
                (double)2,
                (double)3,
                (double)4
            };
            @out = new Ice.OutputStream(communicator);
            Queue <double> l = new Queue <double>(arr);
            Test.DoubleQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Queue <double> l2 = Test.DoubleQueueHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            @out = new Ice.OutputStream(communicator);
            Queue <string> l = new Queue <string>(arr);
            Test.StringQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Queue <string> l2 = Test.StringQueueHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            Queue <Test.SmallStruct> l = new Queue <Test.SmallStruct>(smallStructArray);
            Test.SmallStructQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Queue <Test.SmallStruct> l2 = Test.SmallStructQueueHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator <Test.SmallStruct> e  = l.GetEnumerator();
            IEnumerator <Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            bool[] arr =
            {
                true,
                false,
                true,
                false
            };
            @out = new Ice.OutputStream(communicator);
            Test.BoolCollection l = new Test.BoolCollection(arr);
            Test.BoolCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.BoolCollection l2 = Test.BoolCollectionHelper.read(@in);
            test(Compare(l, l2));
        }

        {
            int[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            Test.IntCollection l = new Test.IntCollection(arr);
            Test.IntCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.IntCollection l2 = Test.IntCollectionHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            @out = new Ice.OutputStream(communicator);
            Test.StringCollection l = new Test.StringCollection(arr);
            Test.StringCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.StringCollection l2 = Test.StringCollectionHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = new Ice.OutputStream(communicator);
            Test.MyEnumCollection l = new Test.MyEnumCollection(arr);
            Test.MyEnumCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyEnumCollection l2 = Test.MyEnumCollectionHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.SmallStructCollection l = new Test.SmallStructCollection(smallStructArray);
            Test.SmallStructCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.SmallStructCollection l2 = Test.SmallStructCollectionHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator <Test.SmallStruct> e  = l.GetEnumerator();
            IEnumerator <Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.MyClassCollection l = new Test.MyClassCollection(myClassArray);
            Test.MyClassCollectionHelper.write(@out, l);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyClassCollection l2 = Test.MyClassCollectionHelper.read(@in);
            @in.readPendingObjects();
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i] != null);
                test(l2[i].c == l2[i]);
                test(l2[i].o == l2[i]);
                test(l2[i].s.e == Test.MyEnum.enum2);
                test(Compare(l2[i].seq1, l[i].seq1));
                test(Compare(l2[i].seq2, l[i].seq2));
                test(Compare(l2[i].seq3, l[i].seq3));
                test(Compare(l2[i].seq4, l[i].seq4));
                test(Compare(l2[i].seq5, l[i].seq5));
                test(Compare(l2[i].seq6, l[i].seq6));
                test(Compare(l2[i].seq7, l[i].seq7));
                test(Compare(l2[i].seq8, l[i].seq8));
                test(Compare(l2[i].seq9, l[i].seq9));
                test(l2[i].d["hi"].Equals(l2[i]));
            }
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            List <string[]> l = new List <string[]>(arrS);
            Test.StringSListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List <string[]> l2 = Test.StringSListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Stack <string[]> l = new Stack <string[]>(arrS);
            Test.StringSStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack <string[]> l2 = Test.StringSStackHelper.read(@in);
            test(Compare(l2, l));
        }
#if !SILVERLIGHT
        {
#if COMPACT
            SortedList <string, string> dict = new SortedList <string, string>();
#else
            SortedDictionary <string, string> dict = new SortedDictionary <string, string>();
#endif
            dict.Add("key1", "value1");
            dict.Add("key2", "value2");
            @out = new Ice.OutputStream(communicator);
            Test.SortedStringStringDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            IDictionary <string, string> dict2 = Test.SortedStringStringDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Test.StringIntDCollection dict = new Test.StringIntDCollection();
            dict.Add("key1", 1);
            dict.Add("key2", 2);
            @out = new Ice.OutputStream(communicator);
            Test.StringIntDCollectionHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.StringIntDCollection dict2 = Test.StringIntDCollectionHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }
#endif
        WriteLine("ok");
#if !SILVERLIGHT
        return(0);
#endif
    }
Ejemplo n.º 19
0
    public static Test.MyClassPrx allTests(Ice.Communicator communicator)
#endif
    {
        Ice.ObjectPrx   baseProxy = communicator.stringToProxy("test:default -p 12010");
        Test.MyClassPrx cl        = Test.MyClassPrxHelper.checkedCast(baseProxy);
        Test.MyClassPrx oneway    = Test.MyClassPrxHelper.uncheckedCast(cl.ice_oneway());

        Write("testing ice_invoke... ");
        Flush();

        {
            byte[] inEncaps, outEncaps;
            if (!oneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps))
            {
                test(false);
            }

            Ice.OutputStream outS = Ice.Util.createOutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            inEncaps = outS.finished();

            if (cl.ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, out outEncaps))
            {
                Ice.InputStream inS = Ice.Util.createInputStream(communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }
        }

        {
            byte[] outEncaps;
            if (cl.ice_invoke("opException", Ice.OperationMode.Normal, null, out outEncaps))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = Ice.Util.createInputStream(communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch (Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }

        WriteLine("ok");

        Write("testing asynchronous ice_invoke... ");
        Flush();

        {
            byte[]          inEncaps, outEncaps;
            Ice.AsyncResult result = oneway.begin_ice_invoke("opOneway", Ice.OperationMode.Normal, null);
            if (!oneway.end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }

            Ice.OutputStream outS = Ice.Util.createOutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            inEncaps = outS.finished();

            // begin_ice_invoke with no callback
            result = cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps);
            if (cl.end_ice_invoke(out outEncaps, result))
            {
                Ice.InputStream inS = Ice.Util.createInputStream(communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, cb.opString, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, cb.opString, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps).whenCompleted(cb.opStringNC, null);
            cb.check();
        }

        {
            // begin_ice_invoke with no callback
            Ice.AsyncResult result = cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null);
            byte[]          outEncaps;
            if (cl.end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = Ice.Util.createInputStream(communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch (Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null).whenCompleted(cb.opExceptionNC, null);
            cb.check();
        }

        WriteLine("ok");

#if SILVERLIGHT
        cl.shutdown();
#else
        return(cl);
#endif
    }
Ejemplo n.º 20
0
 public virtual void read__(InputStream is__)
 {
     is__.startValue();
     readImpl__(is__);
     is__.endValue(false);
 }
Ejemplo n.º 21
0
    static public int run(Ice.Communicator communicator)
    {
        MyClassFactoryWrapper factoryWrapper = new MyClassFactoryWrapper();

        communicator.getValueFactoryManager().add(factoryWrapper.create, MyClass.ice_staticId());

        Ice.InputStream  inS;
        Ice.OutputStream outS;

        Write("testing primitive types... ");
        Flush();

        {
            byte[] data = new byte[0];
            inS = new Ice.InputStream(communicator, data);
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeBool(true);
            outS.endEncapsulation();
            var data = outS.finished();

            inS = new Ice.InputStream(communicator, data);
            inS.startEncapsulation();
            test(inS.readBool());
            inS.endEncapsulation();

            inS = new Ice.InputStream(communicator, data);
            inS.startEncapsulation();
            test(inS.readBool());
            inS.endEncapsulation();
        }

        {
            var data = new byte[0];
            inS = new Ice.InputStream(communicator, data);
            try
            {
                inS.readBool();
                test(false);
            }
            catch (Ice.UnmarshalOutOfBoundsException)
            {
            }
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.writeBool(true);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            test(inS.readBool());
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.writeByte(1);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            test(inS.readByte() == 1);
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.writeShort(2);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            test(inS.readShort() == 2);
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.writeInt(3);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            test(inS.readInt() == 3);
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.writeLong(4);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            test(inS.readLong() == 4);
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.writeFloat((float)5.0);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            test(inS.readFloat() == (float)5.0);
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.writeDouble(6.0);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            test(inS.readDouble() == 6.0);
        }

        {
            outS = new Ice.OutputStream(communicator);
            outS.writeString("hello world");
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            test(inS.readString().Equals("hello world"));
        }

        WriteLine("ok");

        Write("testing constructed types... ");
        Flush();

        {
            outS = new Ice.OutputStream(communicator);
            MyEnumHelper.write(outS, MyEnum.enum3);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var e = MyEnumHelper.read(inS);
            test(e == MyEnum.enum3);
        }

        {
            outS = new Ice.OutputStream(communicator);
            var s = new SmallStruct();
            s.bo  = true;
            s.by  = 1;
            s.sh  = 2;
            s.i   = 3;
            s.l   = 4;
            s.f   = 5.0f;
            s.d   = 6.0;
            s.str = "7";
            s.e   = MyEnum.enum2;
            s.p   = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
            SmallStruct.write(outS, s);
            var data = outS.finished();
            var s2   = SmallStruct.read(new Ice.InputStream(communicator, data));
            test(s2.Equals(s));
        }

        {
            outS = new Ice.OutputStream(communicator);
            var o = new OptionalClass();
            o.bo = true;
            o.by = 5;
            o.sh = 4;
            o.i  = 3;
            outS.writeValue(o);
            outS.writePendingValues();
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            TestReadValueCallback cb = new TestReadValueCallback();
            inS.readValue(cb.invoke);
            inS.readPendingValues();
            var o2 = (OptionalClass)cb.obj;
            test(o2.bo == o.bo);
            test(o2.by == o.by);
            if (communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0"))
            {
                test(!o2.sh.HasValue);
                test(!o2.i.HasValue);
            }
            else
            {
                test(o2.sh.Value == o.sh.Value);
                test(o2.i.Value == o.i.Value);
            }
        }

        {
            outS = new Ice.OutputStream(communicator, Ice.Util.Encoding_1_0);
            var o = new OptionalClass();
            o.bo = true;
            o.by = 5;
            o.sh = 4;
            o.i  = 3;
            outS.writeValue(o);
            outS.writePendingValues();
            byte[] data = outS.finished();
            inS = new Ice.InputStream(communicator, Ice.Util.Encoding_1_0, data);
            var cb = new TestReadValueCallback();
            inS.readValue(cb.invoke);
            inS.readPendingValues();
            var o2 = (OptionalClass)cb.obj;
            test(o2.bo == o.bo);
            test(o2.by == o.by);
            test(!o2.sh.HasValue);
            test(!o2.i.HasValue);
        }

        {
            bool[] arr = { true, false, true, false };
            outS = new Ice.OutputStream(communicator);
            Ice.BoolSeqHelper.write(outS, arr);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = Ice.BoolSeqHelper.read(inS);
            test(Compare(arr2, arr));

            bool[][] arrS = { arr, new bool[0], arr };
            outS = new Ice.OutputStream(communicator);
            BoolSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = BoolSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        {
            byte[] arr = { 0x01, 0x11, 0x12, 0x22 };
            outS = new Ice.OutputStream(communicator);
            Ice.ByteSeqHelper.write(outS, arr);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = Ice.ByteSeqHelper.read(inS);
            test(Compare(arr2, arr));

            byte[][] arrS = { arr, new byte[0], arr };
            outS = new Ice.OutputStream(communicator);
            ByteSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = ByteSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        {
            Serialize.Small small = new Serialize.Small();
            small.i = 99;
            outS    = new Ice.OutputStream(communicator);
            outS.writeSerializable(small);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var small2 = (Serialize.Small)inS.readSerializable();
            test(small2.i == 99);
        }

        {
            short[] arr = { 0x01, 0x11, 0x12, 0x22 };
            outS = new Ice.OutputStream(communicator);
            Ice.ShortSeqHelper.write(outS, arr);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = Ice.ShortSeqHelper.read(inS);
            test(Compare(arr2, arr));

            short[][] arrS = { arr, new short[0], arr };
            outS = new Ice.OutputStream(communicator);
            ShortSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = ShortSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        {
            int[] arr = { 0x01, 0x11, 0x12, 0x22 };
            outS = new Ice.OutputStream(communicator);
            Ice.IntSeqHelper.write(outS, arr);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = Ice.IntSeqHelper.read(inS);
            test(Compare(arr2, arr));

            int[][] arrS = { arr, new int[0], arr };
            outS = new Ice.OutputStream(communicator);
            IntSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = IntSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        {
            long[] arr = { 0x01, 0x11, 0x12, 0x22 };
            outS = new Ice.OutputStream(communicator);
            Ice.LongSeqHelper.write(outS, arr);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = Ice.LongSeqHelper.read(inS);
            test(Compare(arr2, arr));

            long[][] arrS = { arr, new long[0], arr };
            outS = new Ice.OutputStream(communicator);
            LongSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = LongSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        {
            float[] arr = { 1, 2, 3, 4 };
            outS = new Ice.OutputStream(communicator);
            Ice.FloatSeqHelper.write(outS, arr);
            byte[] data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            float[] arr2 = Ice.FloatSeqHelper.read(inS);
            test(Compare(arr2, arr));

            float[][] arrS = { arr, new float[0], arr };
            outS = new Ice.OutputStream(communicator);
            FloatSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = FloatSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        {
            double[] arr =
            {
                (double)1,
                (double)2,
                (double)3,
                (double)4
            };
            outS = new Ice.OutputStream(communicator);
            Ice.DoubleSeqHelper.write(outS, arr);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = Ice.DoubleSeqHelper.read(inS);
            test(Compare(arr2, arr));

            double[][] arrS = { arr, new double[0], arr };
            outS = new Ice.OutputStream(communicator);
            DoubleSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = DoubleSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        {
            string[] arr = { "string1", "string2", "string3", "string4" };
            outS = new Ice.OutputStream(communicator);
            Ice.StringSeqHelper.write(outS, arr);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = Ice.StringSeqHelper.read(inS);
            test(Compare(arr2, arr));

            string[][] arrS = { arr, new string[0], arr };
            outS = new Ice.OutputStream(communicator);
            StringSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = StringSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        {
            MyEnum[] arr = { MyEnum.enum3, MyEnum.enum2, MyEnum.enum1, MyEnum.enum2 };
            outS = new Ice.OutputStream(communicator);
            MyEnumSHelper.write(outS, arr);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = MyEnumSHelper.read(inS);
            test(Compare(arr2, arr));

            MyEnum[][] arrS = { arr, new MyEnum[0], arr };
            outS = new Ice.OutputStream(communicator);
            MyEnumSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = MyEnumSSHelper.read(inS);
            test(Compare(arr2S, arrS));
        }

        var smallStructArray = new SmallStruct[3];

        for (int i = 0; i < smallStructArray.Length; ++i)
        {
            smallStructArray[i]     = new SmallStruct();
            smallStructArray[i].bo  = true;
            smallStructArray[i].by  = 1;
            smallStructArray[i].sh  = 2;
            smallStructArray[i].i   = 3;
            smallStructArray[i].l   = 4;
            smallStructArray[i].f   = 5.0f;
            smallStructArray[i].d   = 6.0;
            smallStructArray[i].str = "7";
            smallStructArray[i].e   = MyEnum.enum2;
            smallStructArray[i].p   = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
        }

        var myClassArray = new MyClass[4];

        for (int i = 0; i < myClassArray.Length; ++i)
        {
            myClassArray[i]         = new MyClass();
            myClassArray[i].c       = myClassArray[i];
            myClassArray[i].o       = myClassArray[i];
            myClassArray[i].s       = new SmallStruct();
            myClassArray[i].s.e     = MyEnum.enum2;
            myClassArray[i].seq1    = new bool[] { true, false, true, false };
            myClassArray[i].seq2    = new byte[] { 1, 2, 3, 4 };
            myClassArray[i].seq3    = new short[] { 1, 2, 3, 4 };
            myClassArray[i].seq4    = new int[] { 1, 2, 3, 4 };
            myClassArray[i].seq5    = new long[] { 1, 2, 3, 4 };
            myClassArray[i].seq6    = new float[] { 1, 2, 3, 4 };
            myClassArray[i].seq7    = new double[] { 1, 2, 3, 4 };
            myClassArray[i].seq8    = new string[] { "string1", "string2", "string3", "string4" };
            myClassArray[i].seq9    = new MyEnum[] { MyEnum.enum3, MyEnum.enum2, MyEnum.enum1 };
            myClassArray[i].seq10   = new MyClass[4]; // null elements.
            myClassArray[i].d       = new Dictionary <string, Test.MyClass>();
            myClassArray[i].d["hi"] = myClassArray[i];
        }

        {
            outS = new Ice.OutputStream(communicator);
            MyClassSHelper.write(outS, myClassArray);
            outS.writePendingValues();
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var arr2 = MyClassSHelper.read(inS);
            inS.readPendingValues();
            test(arr2.Length == myClassArray.Length);
            for (int i = 0; i < arr2.Length; ++i)
            {
                test(arr2[i] != null);
                test(arr2[i].c == arr2[i]);
                test(arr2[i].o == arr2[i]);
                test(arr2[i].s.e == MyEnum.enum2);
                test(Compare(arr2[i].seq1, myClassArray[i].seq1));
                test(Compare(arr2[i].seq2, myClassArray[i].seq2));
                test(Compare(arr2[i].seq3, myClassArray[i].seq3));
                test(Compare(arr2[i].seq4, myClassArray[i].seq4));
                test(Compare(arr2[i].seq5, myClassArray[i].seq5));
                test(Compare(arr2[i].seq6, myClassArray[i].seq6));
                test(Compare(arr2[i].seq7, myClassArray[i].seq7));
                test(Compare(arr2[i].seq8, myClassArray[i].seq8));
                test(Compare(arr2[i].seq9, myClassArray[i].seq9));
                test(arr2[i].d["hi"].Equals(arr2[i]));
            }

            MyClass[][] arrS = { myClassArray, new MyClass[0], myClassArray };
            outS = new Ice.OutputStream(communicator);
            MyClassSSHelper.write(outS, arrS);
            data = outS.finished();
            inS  = new Ice.InputStream(communicator, data);
            var arr2S = MyClassSSHelper.read(inS);
            test(arr2S.Length == arrS.Length);
            test(arr2S[0].Length == arrS[0].Length);
            test(arr2S[1].Length == arrS[1].Length);
            test(arr2S[2].Length == arrS[2].Length);
        }

        {
            outS = new Ice.OutputStream(communicator);
            var obj = new MyClass();
            obj.s   = new SmallStruct();
            obj.s.e = MyEnum.enum2;
            var writer = new TestValueWriter(obj);
            outS.writeValue(writer);
            outS.writePendingValues();
            var data = outS.finished();
            test(writer.called);
            factoryWrapper.setFactory(TestObjectFactory);
            inS = new Ice.InputStream(communicator, data);
            var cb = new TestReadValueCallback();
            inS.readValue(cb.invoke);
            inS.readPendingValues();
            test(cb.obj != null);
            test(cb.obj is TestValueReader);
            var reader = (TestValueReader)cb.obj;
            test(reader.called);
            test(reader.obj != null);
            test(reader.obj.s.e == MyEnum.enum2);
            factoryWrapper.setFactory(null);
        }

        {
            outS = new Ice.OutputStream(communicator);
            var ex = new MyException();

            var c = new MyClass();
            c.c     = c;
            c.o     = c;
            c.s     = new SmallStruct();
            c.s.e   = MyEnum.enum2;
            c.seq1  = new bool[] { true, false, true, false };
            c.seq2  = new byte[] { 1, 2, 3, 4 };
            c.seq3  = new short[] { 1, 2, 3, 4 };
            c.seq4  = new int[] { 1, 2, 3, 4 };
            c.seq5  = new long[] { 1, 2, 3, 4 };
            c.seq6  = new float[] { 1, 2, 3, 4 };
            c.seq7  = new double[] { 1, 2, 3, 4 };
            c.seq8  = new string[] { "string1", "string2", "string3", "string4" };
            c.seq9  = new MyEnum[] { MyEnum.enum3, MyEnum.enum2, MyEnum.enum1 };
            c.seq10 = new MyClass[4]; // null elements.
            c.d     = new Dictionary <string, MyClass>();
            c.d.Add("hi", c);

            ex.c = c;

            outS.writeException(ex);
            var data = outS.finished();

            inS = new Ice.InputStream(communicator, data);
            try
            {
                inS.throwException();
                test(false);
            }
            catch (MyException ex1)
            {
                test(ex1.c.s.e == c.s.e);
                test(Compare(ex1.c.seq1, c.seq1));
                test(Compare(ex1.c.seq2, c.seq2));
                test(Compare(ex1.c.seq3, c.seq3));
                test(Compare(ex1.c.seq4, c.seq4));
                test(Compare(ex1.c.seq5, c.seq5));
                test(Compare(ex1.c.seq6, c.seq6));
                test(Compare(ex1.c.seq7, c.seq7));
                test(Compare(ex1.c.seq8, c.seq8));
                test(Compare(ex1.c.seq9, c.seq9));
            }
            catch (Ice.UserException)
            {
                test(false);
            }
        }

        {
            var dict = new Dictionary <byte, bool>();
            dict.Add(4, true);
            dict.Add(1, false);
            outS = new Ice.OutputStream(communicator);
            ByteBoolDHelper.write(outS, dict);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var dict2 = ByteBoolDHelper.read(inS);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            var dict = new Dictionary <short, int>();
            dict.Add(1, 9);
            dict.Add(4, 8);
            outS = new Ice.OutputStream(communicator);
            ShortIntDHelper.write(outS, dict);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var dict2 = ShortIntDHelper.read(inS);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            var dict = new Dictionary <long, float>();
            dict.Add(123809828, 0.51f);
            dict.Add(123809829, 0.56f);
            outS = new Ice.OutputStream(communicator);
            LongFloatDHelper.write(outS, dict);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var dict2 = LongFloatDHelper.read(inS);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            var dict = new Dictionary <string, string>();
            dict.Add("key1", "value1");
            dict.Add("key2", "value2");
            outS = new Ice.OutputStream(communicator);
            StringStringDHelper.write(outS, dict);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var dict2 = StringStringDHelper.read(inS);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            var dict = new Dictionary <string, MyClass>();
            var c    = new MyClass();
            c.s   = new SmallStruct();
            c.s.e = MyEnum.enum2;
            dict.Add("key1", c);
            c     = new MyClass();
            c.s   = new SmallStruct();
            c.s.e = MyEnum.enum3;
            dict.Add("key2", c);
            outS = new Ice.OutputStream(communicator);
            StringMyClassDHelper.write(outS, dict);
            outS.writePendingValues();
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var dict2 = StringMyClassDHelper.read(inS);
            inS.readPendingValues();
            test(dict2.Count == dict.Count);
            test(dict2["key1"].s.e == MyEnum.enum2);
            test(dict2["key2"].s.e == MyEnum.enum3);
        }

        {
            bool[] arr = { true, false, true, false };
            outS = new Ice.OutputStream(communicator);
            var l = new List <bool>(arr);
            BoolListHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = BoolListHelper.read(inS);
            test(Compare(l, l2));
        }

        {
            byte[] arr = { 0x01, 0x11, 0x12, 0x22 };
            outS = new Ice.OutputStream(communicator);
            var l = new List <byte>(arr);
            ByteListHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = ByteListHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            MyEnum[] arr = { MyEnum.enum3, MyEnum.enum2, MyEnum.enum1, MyEnum.enum2 };
            outS = new Ice.OutputStream(communicator);
            var l = new List <MyEnum>(arr);
            MyEnumListHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = MyEnumListHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            outS = new Ice.OutputStream(communicator);
            var l = new List <SmallStruct>(smallStructArray);
            SmallStructListHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = SmallStructListHelper.read(inS);
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i].Equals(smallStructArray[i]));
            }
        }

        {
            outS = new Ice.OutputStream(communicator);
            var l = new List <MyClass>(myClassArray);
            MyClassListHelper.write(outS, l);
            outS.writePendingValues();
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = MyClassListHelper.read(inS);
            inS.readPendingValues();
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i] != null);
                test(l2[i].c == l2[i]);
                test(l2[i].o == l2[i]);
                test(l2[i].s.e == MyEnum.enum2);
                test(Compare(l2[i].seq1, l[i].seq1));
                test(Compare(l2[i].seq2, l[i].seq2));
                test(Compare(l2[i].seq3, l[i].seq3));
                test(Compare(l2[i].seq4, l[i].seq4));
                test(Compare(l2[i].seq5, l[i].seq5));
                test(Compare(l2[i].seq6, l[i].seq6));
                test(Compare(l2[i].seq7, l[i].seq7));
                test(Compare(l2[i].seq8, l[i].seq8));
                test(Compare(l2[i].seq9, l[i].seq9));
                test(l2[i].d["hi"].Equals(l2[i]));
            }
        }

        {
            var arr = new MyClassPrx[2];
            arr[0] = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("zero"));
            arr[1] = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("one"));
            outS   = new Ice.OutputStream(communicator);
            var l = new List <MyClassPrx>(arr);
            MyClassProxyListHelper.write(outS, l);
            byte[] data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = MyClassProxyListHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            short[] arr = { 0x01, 0x11, 0x12, 0x22 };
            outS = new Ice.OutputStream(communicator);
            var l = new LinkedList <short>(arr);
            ShortLinkedListHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = ShortLinkedListHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            int[] arr = { 0x01, 0x11, 0x12, 0x22 };
            outS = new Ice.OutputStream(communicator);
            LinkedList <int> l = new LinkedList <int>(arr);
            Test.IntLinkedListHelper.write(outS, l);
            byte[] data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            LinkedList <int> l2 = Test.IntLinkedListHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            MyEnum[] arr = { MyEnum.enum3, MyEnum.enum2, MyEnum.enum1, MyEnum.enum2 };
            outS = new Ice.OutputStream(communicator);
            LinkedList <Test.MyEnum> l = new LinkedList <Test.MyEnum>(arr);
            Test.MyEnumLinkedListHelper.write(outS, l);
            byte[] data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            LinkedList <Test.MyEnum> l2 = Test.MyEnumLinkedListHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            outS = new Ice.OutputStream(communicator);
            var l = new LinkedList <Test.SmallStruct>(smallStructArray);
            SmallStructLinkedListHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = SmallStructLinkedListHelper.read(inS);
            test(l2.Count == l.Count);
            var e  = l.GetEnumerator();
            var e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            long[] arr = { 0x01, 0x11, 0x12, 0x22 };
            outS = new Ice.OutputStream(communicator);
            var l = new Stack <long>(arr);
            LongStackHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = LongStackHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            float[] arr = { 1, 2, 3, 4 };
            outS = new Ice.OutputStream(communicator);
            var l = new Stack <float>(arr);
            FloatStackHelper.write(outS, l);
            byte[] data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = FloatStackHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            outS = new Ice.OutputStream(communicator);
            var l = new Stack <SmallStruct>(smallStructArray);
            SmallStructStackHelper.write(outS, l);
            byte[] data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = SmallStructStackHelper.read(inS);
            test(l2.Count == l.Count);
            var e  = l.GetEnumerator();
            var e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            var arr = new MyClassPrx[2];
            arr[0] = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("zero"));
            arr[1] = MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("one"));
            outS   = new Ice.OutputStream(communicator);
            var l = new Stack <MyClassPrx>(arr);
            MyClassProxyStackHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = MyClassProxyStackHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            double[] arr = { 1, 2, 3, 4 };
            outS = new Ice.OutputStream(communicator);
            var l = new Queue <double>(arr);
            DoubleQueueHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = DoubleQueueHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            string[] arr = { "string1", "string2", "string3", "string4" };
            outS = new Ice.OutputStream(communicator);
            var l = new Queue <string>(arr);
            StringQueueHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = StringQueueHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            outS = new Ice.OutputStream(communicator);
            var l = new Queue <SmallStruct>(smallStructArray);
            SmallStructQueueHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = SmallStructQueueHelper.read(inS);
            test(l2.Count == l.Count);
            var e  = l.GetEnumerator();
            var e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            string[]   arr  = { "string1", "string2", "string3", "string4" };
            string[][] arrS = { arr, new string[0], arr };
            outS = new Ice.OutputStream(communicator);
            var l = new List <string[]>(arrS);
            StringSListHelper.write(outS, l);
            byte[] data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = StringSListHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            string[]   arr  = { "string1", "string2", "string3", "string4" };
            string[][] arrS = { arr, new string[0], arr };
            outS = new Ice.OutputStream(communicator);
            var l = new Stack <string[]>(arrS);
            StringSStackHelper.write(outS, l);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var l2 = StringSStackHelper.read(inS);
            test(Compare(l2, l));
        }

        {
            var dict = new SortedDictionary <string, string>();
            dict.Add("key1", "value1");
            dict.Add("key2", "value2");
            outS = new Ice.OutputStream(communicator);
            SortedStringStringDHelper.write(outS, dict);
            var data = outS.finished();
            inS = new Ice.InputStream(communicator, data);
            var dict2 = SortedStringStringDHelper.read(inS);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        WriteLine("ok");
        return(0);
    }
Ejemplo n.º 22
0
 /// <summary>
 /// Read the instance's data members.
 /// </summary>
 /// <param name="inStream">The input stream to read from.</param>
 public abstract void read(InputStream inStream);
Ejemplo n.º 23
0
        private static Ice1Definitions.MessageType PrintHeader(System.IO.StringWriter s, Ice.InputStream str)
        {
            try
            {
                str.ReadByte(); // Don't bother printing the magic number
                str.ReadByte();
                str.ReadByte();
                str.ReadByte();

                /* byte pMajor = */
                str.ReadByte();
                /* byte pMinor = */
                str.ReadByte();
                //s.Write("\nprotocol version = " + (int)pMajor + "." + (int)pMinor);

                /* byte eMajor = */
                str.ReadByte();
                /* byte eMinor = */
                str.ReadByte();
                //s.Write("\nencoding version = " + (int)eMajor + "." + (int)eMinor);

                var type = (Ice1Definitions.MessageType)str.ReadByte();
                s.Write("\nmessage type = " + (int)type + " (" + GetMessageTypeAsString(type) + ')');

                byte compress = str.ReadByte();
                s.Write("\ncompression status = " + (int)compress + ' ');
                switch (compress)
                {
                case 0:
                {
                    s.Write("(not compressed; do not compress response, if any)");
                    break;
                }

                case 1:
                {
                    s.Write("(not compressed; compress response, if any)");
                    break;
                }

                case 2:
                {
                    s.Write("(compressed; compress response, if any)");
                    break;
                }

                default:
                {
                    s.Write("(unknown)");
                    break;
                }
                }

                int size = str.ReadInt();
                s.Write("\nmessage size = " + size);
                return(type);
            }
            catch (System.IO.IOException)
            {
                Debug.Assert(false);
                return(0);
            }
        }
Ejemplo n.º 24
0
 internal EncapsDecoder10(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f,
                          ClassResolver cr)
     : base(stream, encaps, sliceValues, f, cr)
 {
     _sliceType = SliceType.NoSlice;
 }
Ejemplo n.º 25
0
            private int _valueIdIndex; // The ID of the next instance to unmarshal.

            #endregion Fields

            #region Constructors

            internal EncapsDecoder11(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f,
                                     ClassResolver cr, CompactIdResolver r)
                : base(stream, encaps, sliceValues, f, cr)
            {
                _compactIdResolver = r;
                _current = null;
                _valueIdIndex = 1;
            }
Ejemplo n.º 26
0
 internal EncapsDecoder(InputStream stream, Encaps encaps, bool sliceValues, ValueFactoryManager f,
                        ClassResolver cr)
 {
     _stream = stream;
     _encaps = encaps;
     _sliceValues = sliceValues;
     _valueFactoryManager = f;
     _classResolver = cr;
     _typeIdIndex = 0;
     _unmarshaledMap = new Dictionary<int, Ice.Object>();
 }
Ejemplo n.º 27
0
        /// <summary>
        /// Swaps the contents of one stream with another.
        /// </summary>
        /// <param name="other">The other stream.</param>
        public void swap(InputStream other)
        {
            Debug.Assert(instance_ == other.instance_);

            IceInternal.Buffer tmpBuf = other._buf;
            other._buf = _buf;
            _buf = tmpBuf;

            EncodingVersion tmpEncoding = other._encoding;
            other._encoding = _encoding;
            _encoding = tmpEncoding;

            bool tmpTraceSlicing = other._traceSlicing;
            other._traceSlicing = _traceSlicing;
            _traceSlicing = tmpTraceSlicing;

            object tmpClosure = other._closure;
            other._closure = _closure;
            _closure = tmpClosure;

            bool tmpSliceValues = other._sliceValues;
            other._sliceValues = _sliceValues;
            _sliceValues = tmpSliceValues;

            //
            // Swap is never called for InputStreams that have encapsulations being read. However,
            // encapsulations might still be set in case un-marshalling failed. We just
            // reset the encapsulations if there are still some set.
            //
            resetEncapsulation();
            other.resetEncapsulation();

            int tmpStartSeq = other._startSeq;
            other._startSeq = _startSeq;
            _startSeq = tmpStartSeq;

            int tmpMinSeqSize = other._minSeqSize;
            other._minSeqSize = _minSeqSize;
            _minSeqSize = tmpMinSeqSize;

            ValueFactoryManager tmpVfm = other._valueFactoryManager;
            other._valueFactoryManager = _valueFactoryManager;
            _valueFactoryManager = tmpVfm;

            Logger tmpLogger = other._logger;
            other._logger = _logger;
            _logger = tmpLogger;

            CompactIdResolver tmpCompactIdResolver = other._compactIdResolver;
            other._compactIdResolver = _compactIdResolver;
            _compactIdResolver = tmpCompactIdResolver;

            ClassResolver tmpClassResolver = other._classResolver;
            other._classResolver = _classResolver;
            _classResolver = tmpClassResolver;
        }
Ejemplo n.º 28
0
 public TcpEndpoint(TransportInstance instance, Ice.InputStream s) :
     base(instance, s)
 {
     _timeout  = s.ReadInt();
     _compress = s.ReadBool();
 }
Ejemplo n.º 29
0
    public static TestIntfPrx allTests(Ice.Communicator communicator)
#endif
    {
        string sref = "test:default -p 12010";

        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);
        TestIntfPrx proxy = TestIntfPrxHelper.uncheckedCast(obj);

        test(proxy != null);

        Console.Out.Write("testing enum values... ");
        Console.Out.Flush();

        test((int)ByteEnum.benum1 == 0);
        test((int)ByteEnum.benum2 == 1);
        test((int)ByteEnum.benum3 == ByteConst1.value);
        test((int)ByteEnum.benum4 == ByteConst1.value + 1);
        test((int)ByteEnum.benum5 == ShortConst1.value);
        test((int)ByteEnum.benum6 == ShortConst1.value + 1);
        test((int)ByteEnum.benum7 == IntConst1.value);
        test((int)ByteEnum.benum8 == IntConst1.value + 1);
        test((int)ByteEnum.benum9 == LongConst1.value);
        test((int)ByteEnum.benum10 == LongConst1.value + 1);
        test((int)ByteEnum.benum11 == ByteConst2.value);

        test((int)ShortEnum.senum1 == 3);
        test((int)ShortEnum.senum2 == 4);
        test((int)ShortEnum.senum3 == ByteConst1.value);
        test((int)ShortEnum.senum4 == ByteConst1.value + 1);
        test((int)ShortEnum.senum5 == ShortConst1.value);
        test((int)ShortEnum.senum6 == ShortConst1.value + 1);
        test((int)ShortEnum.senum7 == IntConst1.value);
        test((int)ShortEnum.senum8 == IntConst1.value + 1);
        test((int)ShortEnum.senum9 == LongConst1.value);
        test((int)ShortEnum.senum10 == LongConst1.value + 1);
        test((int)ShortEnum.senum11 == ShortConst2.value);

        test((int)IntEnum.ienum1 == 0);
        test((int)IntEnum.ienum2 == 1);
        test((int)IntEnum.ienum3 == ByteConst1.value);
        test((int)IntEnum.ienum4 == ByteConst1.value + 1);
        test((int)IntEnum.ienum5 == ShortConst1.value);
        test((int)IntEnum.ienum6 == ShortConst1.value + 1);
        test((int)IntEnum.ienum7 == IntConst1.value);
        test((int)IntEnum.ienum8 == IntConst1.value + 1);
        test((int)IntEnum.ienum9 == LongConst1.value);
        test((int)IntEnum.ienum10 == LongConst1.value + 1);
        test((int)IntEnum.ienum11 == IntConst2.value);
        test((int)IntEnum.ienum12 == LongConst2.value);

        test((int)SimpleEnum.red == 0);
        test((int)SimpleEnum.green == 1);
        test((int)SimpleEnum.blue == 2);

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum streaming... ");
        Console.Out.Flush();

        Ice.OutputStream ostr;
        byte[]           bytes;

        bool encoding_1_0 = communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0");

        ostr = Ice.Util.createOutputStream(communicator);
        ByteEnumHelper.write(ostr, ByteEnum.benum11);
        bytes = ostr.finished();
        test(bytes.Length == 1); // ByteEnum should require one byte

        ostr = Ice.Util.createOutputStream(communicator);
        ShortEnumHelper.write(ostr, ShortEnum.senum11);
        bytes = ostr.finished();
        test(bytes.Length == (encoding_1_0 ? 2 : 5));

        ostr = Ice.Util.createOutputStream(communicator);
        IntEnumHelper.write(ostr, IntEnum.ienum11);
        bytes = ostr.finished();
        test(bytes.Length == (encoding_1_0 ? 4 : 5));

        ostr = Ice.Util.createOutputStream(communicator);
        SimpleEnumHelper.write(ostr, SimpleEnum.blue);
        bytes = ostr.finished();
        test(bytes.Length == 1); // SimpleEnum should require one byte

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum operations... ");
        Console.Out.Flush();

        ByteEnum byteEnum;

        test(proxy.opByte(ByteEnum.benum1, out byteEnum) == ByteEnum.benum1);
        test(byteEnum == ByteEnum.benum1);
        test(proxy.opByte(ByteEnum.benum11, out byteEnum) == ByteEnum.benum11);
        test(byteEnum == ByteEnum.benum11);

        ShortEnum shortEnum;

        test(proxy.opShort(ShortEnum.senum1, out shortEnum) == ShortEnum.senum1);
        test(shortEnum == ShortEnum.senum1);
        test(proxy.opShort(ShortEnum.senum11, out shortEnum) == ShortEnum.senum11);
        test(shortEnum == ShortEnum.senum11);

        IntEnum intEnum;

        test(proxy.opInt(IntEnum.ienum1, out intEnum) == IntEnum.ienum1);
        test(intEnum == IntEnum.ienum1);
        test(proxy.opInt(IntEnum.ienum11, out intEnum) == IntEnum.ienum11);
        test(intEnum == IntEnum.ienum11);
        test(proxy.opInt(IntEnum.ienum12, out intEnum) == IntEnum.ienum12);
        test(intEnum == IntEnum.ienum12);

        SimpleEnum s;

        test(proxy.opSimple(SimpleEnum.green, out s) == SimpleEnum.green);
        test(s == SimpleEnum.green);

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum exceptions... ");
        Console.Out.Flush();

        try
        {
            ostr = Ice.Util.createOutputStream(communicator);
            ostr.writeByte((byte)128); // Invalid enumerator
            Ice.InputStream istr = Ice.Util.createInputStream(communicator, ostr.finished());
            ByteEnumHelper.read(istr);
            test(false);
        }
        catch (Ice.MarshalException)
        {
        }

        try
        {
            ostr = Ice.Util.createOutputStream(communicator);
            ostr.writeShort((short)-1); // Negative enumerators are not supported
            Ice.InputStream istr = Ice.Util.createInputStream(communicator, ostr.finished());
            ShortEnumHelper.read(istr);
            test(false);
        }
        catch (Ice.MarshalException)
        {
        }

        try
        {
            ostr = Ice.Util.createOutputStream(communicator);
            ostr.writeShort((short)0); // Invalid enumerator
            Ice.InputStream istr = Ice.Util.createInputStream(communicator, ostr.finished());
            ShortEnumHelper.read(istr);
            test(false);
        }
        catch (Ice.MarshalException)
        {
        }

        try
        {
            ostr = Ice.Util.createOutputStream(communicator);
            ostr.writeShort((short)32767); // Invalid enumerator
            Ice.InputStream istr = Ice.Util.createInputStream(communicator, ostr.finished());
            ShortEnumHelper.read(istr);
            test(false);
        }
        catch (Ice.MarshalException)
        {
        }

        try
        {
            ostr = Ice.Util.createOutputStream(communicator);
            ostr.writeInt(-1); // Negative enumerators are not supported
            Ice.InputStream istr = Ice.Util.createInputStream(communicator, ostr.finished());
            IntEnumHelper.read(istr);
            test(false);
        }
        catch (Ice.MarshalException)
        {
        }

        Console.Out.WriteLine("ok");
#if SILVERLIGHT
        proxy.shutdown();
#else
        return(proxy);
#endif
    }
Ejemplo n.º 30
0
 public override void read__(InputStream istr)
 {
     read(istr);
 }
Ejemplo n.º 31
0
        public virtual void read__(InputStream inS__, bool rid__)
        {
            if(rid__)
            {
                /* string myId = */ inS__.readTypeId();
            }

            inS__.startSlice();

            // For compatibility with the old AFM.
            int sz = inS__.readSize();
            if(sz != 0)
            {
                throw new MarshalException();
            }

            inS__.endSlice();
        }
Ejemplo n.º 32
0
        public void opException(Ice.AsyncResult result)
        {
            if(_useCookie)
            {
                Cookie cookie = (Cookie)result.AsyncState;
                test(cookie.getString().Equals(testString));
            }

            byte[] outEncaps;
            if(result.getProxy().end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(_communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch(Test.MyException)
                {
                    inS.endEncapsulation();
                    callback.called();
                }
                catch(System.Exception)
                {
                    test(false);
                }
            }
        }
Ejemplo n.º 33
0
        public override int run(string[] args)
        {
            if(args.Length > 0)
            {
                Console.Error.WriteLine(appName() + ": too many arguments");
                return 1;
            }

            var obj = communicator().propertyToProxy("Printer.Proxy");

            menu();

            string line = null;
            do
            {
                try
                {
                    Console.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if(line == null)
                    {
                        break;
                    }

                    byte[] outParams;

                    if(line.Equals("1"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        outStream.writeString("The streaming API works!");
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if(!obj.ice_invoke("printString", Ice.OperationMode.Normal, outStream.finished(),
                                           out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if(line.Equals("2"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        string[] arr = { "The", "streaming", "API", "works!" };
                        StringSeqHelper.write(outStream, arr);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if(!obj.ice_invoke("printStringSequence", Ice.OperationMode.Normal, outStream.finished(),
                                           out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if(line.Equals("3"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        var dict = new Dictionary<string, string>()
                            {
                                { "The", "streaming" },
                                { "API", "works!"}
                            };
                        StringDictHelper.write(outStream, dict);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if(!obj.ice_invoke("printDictionary", Ice.OperationMode.Normal, outStream.finished(),
                                           out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if(line.Equals("4"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        ColorHelper.write(outStream, Color.green);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if(!obj.ice_invoke("printEnum", Ice.OperationMode.Normal, outStream.finished(), out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if(line.Equals("5"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        var s = new Structure("read", Color.red);
                        Structure.write(outStream, s);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if(!obj.ice_invoke("printStruct", Ice.OperationMode.Normal, outStream.finished(),
                                           out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if(line.Equals("6"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        Structure[] arr =
                            {
                                new Structure("red", Color.red),
                                new Structure("green", Color.green),
                                new Structure("blue", Color.blue)
                            };
                        StructureSeqHelper.write(outStream, arr);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if(!obj.ice_invoke("printStructSequence", Ice.OperationMode.Normal, outStream.finished(),
                                           out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if(line.Equals("7"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        var c = new C(new Structure("blue", Color.blue));
                        outStream.writeValue(c);
                        outStream.writePendingValues();
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if(!obj.ice_invoke("printClass", Ice.OperationMode.Normal, outStream.finished(), out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if(line.Equals("8"))
                    {
                        //
                        // Invoke operation.
                        //
                        if(!obj.ice_invoke("getValues", Ice.OperationMode.Normal, null, out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                            continue;
                        }

                        //
                        // Unmarshal the results.
                        //
                        var inStream = new Ice.InputStream(communicator(), outParams);
                        inStream.startEncapsulation();
                        var cb = new ReadValueCallback();
                        inStream.readValue(cb.invoke);
                        var str = inStream.readString();
                        inStream.readPendingValues();
                        var c = cb.obj as C;
                        Console.Error.WriteLine("Got string `" + str + "' and class: s.name=" + c.s.name +
                                                ", s.value=" + c.s.value);
                    }
                    else if(line.Equals("9"))
                    {
                        //
                        // Invoke operation.
                        //
                        if(obj.ice_invoke("throwPrintFailure", Ice.OperationMode.Normal, null, out outParams))
                        {
                            Console.Error.WriteLine("Expected exception");
                            continue;
                        }

                        var inStream = new Ice.InputStream(communicator(), outParams);
                        inStream.startEncapsulation();
                        try
                        {
                            inStream.throwException();
                        }
                        catch(PrintFailure)
                        {
                            // Expected.
                        }
                        catch(Ice.UserException)
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                        inStream.endEncapsulation();
                    }
                    else if(line.Equals("s"))
                    {
                        obj.ice_invoke("shutdown", Ice.OperationMode.Normal, null, out outParams);
                    }
                    else if(line.Equals("x"))
                    {
                        // Nothing to do.
                    }
                    else if(line.Equals("?"))
                    {
                        menu();
                    }
                    else
                    {
                        Console.Error.WriteLine("unknown command `" + line + "'");
                        menu();
                    }
                }
                catch(Ice.LocalException ex)
                {
                    Console.Error.WriteLine(ex);
                }
            }
            while(!line.Equals("x"));

            return 0;
        }
Ejemplo n.º 34
0
 public void opExceptionNC(bool ok, byte[] outEncaps)
 {
     if(ok)
     {
         test(false);
     }
     else
     {
         Ice.InputStream inS = new Ice.InputStream(_communicator, outEncaps);
         inS.startEncapsulation();
         try
         {
             inS.throwException();
         }
         catch(Test.MyException)
         {
             inS.endEncapsulation();
             callback.called();
         }
         catch(System.Exception)
         {
             test(false);
         }
     }
 }
Ejemplo n.º 35
0
 protected override void readImpl__(InputStream is__)
 {
     is__.startSlice();
     is__.endSlice();
 }
Ejemplo n.º 36
0
    public static Test.MyClassPrx allTests(Ice.Communicator communicator)
#endif
    {
        Ice.ObjectPrx baseProxy = communicator.stringToProxy("test:default -p 12010");
        Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy);
        Test.MyClassPrx oneway = Test.MyClassPrxHelper.uncheckedCast(cl.ice_oneway());
        Test.MyClassPrx batchOneway = Test.MyClassPrxHelper.uncheckedCast(cl.ice_batchOneway());

        Write("testing ice_invoke... ");
        Flush();

        {
            byte[] inEncaps, outEncaps;
            if(!oneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps))
            {
                test(false);
            }

            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            batchOneway.ice_flushBatchRequests();

            Ice.OutputStream outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            inEncaps = outS.finished();

            if(cl.ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, out outEncaps))
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }
        }

        {
            byte[] outEncaps;
            if(cl.ice_invoke("opException", Ice.OperationMode.Normal, null, out outEncaps))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch(Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch(System.Exception)
                {
                    test(false);
                }
            }
        }

        WriteLine("ok");

        Write("testing asynchronous ice_invoke... ");
        Flush();

        {
            byte[] inEncaps, outEncaps;
            Ice.AsyncResult result = oneway.begin_ice_invoke("opOneway", Ice.OperationMode.Normal, null);
            if(!oneway.end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }

            Ice.OutputStream outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            inEncaps = outS.finished();

            // begin_ice_invoke with no callback
            result = cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps);
            if(cl.end_ice_invoke(out outEncaps, result))
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, cb.opString, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, cb.opString, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps).whenCompleted(cb.opStringNC, null);
            cb.check();
        }

        {
            // begin_ice_invoke with no callback
            Ice.AsyncResult result = cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null);
            byte[] outEncaps;
            if(cl.end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch(Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch(System.Exception)
                {
                    test(false);
                }
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null).whenCompleted(cb.opExceptionNC, null);
            cb.check();
        }

        WriteLine("ok");

#if SILVERLIGHT
        cl.shutdown();
#else
        return cl;
#endif
    }
Ejemplo n.º 37
0
 public override void read(Ice.InputStream inS)
 {
     obj = new MyClass();
     obj.read__(inS);
     called = true;
 }
Ejemplo n.º 38
0
    public static int run(Ice.Communicator communicator)
    {
        MyClassFactoryWrapper factoryWrapper = new MyClassFactoryWrapper();

        communicator.getValueFactoryManager().add(factoryWrapper.create, Test.MyClass.ice_staticId());
        communicator.getValueFactoryManager().add(MyInterfaceFactory, Test.MyInterfaceDisp_.ice_staticId());

        Ice.InputStream @in;
        Ice.OutputStream @out;

        Write("testing primitive types... ");
        Flush();

        {
            byte[] data = new byte[0];
            @in = new Ice.InputStream(communicator, data);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.startEncapsulation();
            @out.writeBool(true);
            @out.endEncapsulation();
            byte[] data = @out.finished();

            @in = new Ice.InputStream(communicator, data);
            @in.startEncapsulation();
            test(@in.readBool());
            @in.endEncapsulation();

            @in = new Ice.InputStream(communicator, data);
            @in.startEncapsulation();
            test(@in.readBool());
            @in.endEncapsulation();
        }

        {
            byte[] data = new byte[0];
            @in = new Ice.InputStream(communicator, data);
            try
            {
                @in.readBool();
                test(false);
            }
            catch (Ice.UnmarshalOutOfBoundsException)
            {
            }
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeBool(true);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readBool());
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeByte((byte)1);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readByte() == (byte)1);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeShort((short)2);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readShort() == (short)2);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeInt(3);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readInt() == 3);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeLong(4);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readLong() == 4);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeFloat((float)5.0);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readFloat() == (float)5.0);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeDouble(6.0);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readDouble() == 6.0);
        }

        {
            @out = new Ice.OutputStream(communicator);
            @out.writeString("hello world");
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            test(@in.readString().Equals("hello world"));
        }

        WriteLine("ok");

        Write("testing constructed types... ");
        Flush();

        {
            @out = new Ice.OutputStream(communicator);
            Test.MyEnumHelper.write(@out, Test.MyEnum.enum3);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyEnum e = Test.MyEnumHelper.read(@in);
            test(e == Test.MyEnum.enum3);
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.SmallStruct s = new Test.SmallStruct();
            s.bo = true;
            s.by = (byte)1;
            s.sh = (short)2;
            s.i = 3;
            s.l = 4;
            s.f = (float)5.0;
            s.d = 6.0;
            s.str = "7";
            s.e = Test.MyEnum.enum2;
            s.p = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
            s.write__(@out);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.SmallStruct s2 = new Test.SmallStruct();
            s2.read__(@in);
            test(s2.Equals(s));
        }

        {
            @out = new Ice.OutputStream(communicator);
            OptionalClass o = new OptionalClass();
            o.bo = true;
            o.by = (byte)5;
            o.sh = 4;
            o.i = 3;
            @out.writeValue(o);
            @out.writePendingValues();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            TestReadValueCallback cb = new TestReadValueCallback();
            @in.readValue(cb.invoke);
            @in.readPendingValues();
            OptionalClass o2 = (OptionalClass)cb.obj;
            test(o2.bo == o.bo);
            test(o2.by == o.by);
            if(communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0"))
            {
                test(!o2.sh.HasValue);
                test(!o2.i.HasValue);
            }
            else
            {
                test(o2.sh.Value == o.sh.Value);
                test(o2.i.Value == o.i.Value);
            }
        }

        {
            @out = new Ice.OutputStream(communicator, Ice.Util.Encoding_1_0);
            OptionalClass o = new OptionalClass();
            o.bo = true;
            o.by = 5;
            o.sh = 4;
            o.i = 3;
            @out.writeValue(o);
            @out.writePendingValues();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, Ice.Util.Encoding_1_0, data);
            TestReadValueCallback cb = new TestReadValueCallback();
            @in.readValue(cb.invoke);
            @in.readPendingValues();
            OptionalClass o2 = (OptionalClass)cb.obj;
            test(o2.bo == o.bo);
            test(o2.by == o.by);
            test(!o2.sh.HasValue);
            test(!o2.i.HasValue);
        }

        {
            bool[] arr =
            {
                true,
                false,
                true,
                false
            };
            @out = new Ice.OutputStream(communicator);
            Ice.BoolSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            bool[] arr2 = Ice.BoolSeqHelper.read(@in);
            test(Compare(arr2, arr));

            bool[][] arrS =
            {
                arr,
                new bool[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.BoolSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            bool[][] arr2S = Test.BoolSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            byte[] arr =
            {
                (byte)0x01,
                (byte)0x11,
                (byte)0x12,
                (byte)0x22
            };
            @out = new Ice.OutputStream(communicator);
            Ice.ByteSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            byte[] arr2 = Ice.ByteSeqHelper.read(@in);
            test(Compare(arr2, arr));

            byte[][] arrS =
            {
                arr,
                new byte[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.ByteSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            byte[][] arr2S = Test.ByteSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            Serialize.Small small = new Serialize.Small();
            small.i = 99;
            @out = new Ice.OutputStream(communicator);
            @out.writeSerializable(small);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Serialize.Small small2 = (Serialize.Small)@in.readSerializable();
            test(small2.i == 99);
        }

        {
            short[] arr =
            {
                (short)0x01,
                (short)0x11,
                (short)0x12,
                (short)0x22
            };
            @out = new Ice.OutputStream(communicator);
            Ice.ShortSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            short[] arr2 = Ice.ShortSeqHelper.read(@in);
            test(Compare(arr2, arr));

            short[][] arrS =
            {
                arr,
                new short[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.ShortSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            short[][] arr2S = Test.ShortSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            int[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            Ice.IntSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            int[] arr2 = Ice.IntSeqHelper.read(@in);
            test(Compare(arr2, arr));

            int[][] arrS =
            {
                arr,
                new int[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.IntSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            int[][] arr2S = Test.IntSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            long[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            Ice.LongSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            long[] arr2 = Ice.LongSeqHelper.read(@in);
            test(Compare(arr2, arr));

            long[][] arrS =
            {
                arr,
                new long[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.LongSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            long[][] arr2S = Test.LongSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            float[] arr =
            {
                (float)1,
                (float)2,
                (float)3,
                (float)4
            };
            @out = new Ice.OutputStream(communicator);
            Ice.FloatSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            float[] arr2 = Ice.FloatSeqHelper.read(@in);
            test(Compare(arr2, arr));

            float[][] arrS =
            {
                arr,
                new float[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.FloatSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            float[][] arr2S = Test.FloatSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            double[] arr =
            {
                (double)1,
                (double)2,
                (double)3,
                (double)4
            };
            @out = new Ice.OutputStream(communicator);
            Ice.DoubleSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            double[] arr2 = Ice.DoubleSeqHelper.read(@in);
            test(Compare(arr2, arr));

            double[][] arrS =
            {
                arr,
                new double[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.DoubleSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            double[][] arr2S = Test.DoubleSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            @out = new Ice.OutputStream(communicator);
            Ice.StringSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            string[] arr2 = Ice.StringSeqHelper.read(@in);
            test(Compare(arr2, arr));

            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.StringSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            string[][] arr2S = Test.StringSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = new Ice.OutputStream(communicator);
            Test.MyEnumSHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyEnum[] arr2 = Test.MyEnumSHelper.read(@in);
            test(Compare(arr2, arr));

            Test.MyEnum[][] arrS =
            {
                arr,
                new Test.MyEnum[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Test.MyEnumSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyEnum[][] arr2S = Test.MyEnumSSHelper.read(@in);
            test(Compare(arr2S, arrS));
        }

        Test.SmallStruct[] smallStructArray = new Test.SmallStruct[3];
        for (int i = 0; i < smallStructArray.Length; ++i)
        {
            smallStructArray[i] = new Test.SmallStruct();
            smallStructArray[i].bo = true;
            smallStructArray[i].by = (byte)1;
            smallStructArray[i].sh = (short)2;
            smallStructArray[i].i = 3;
            smallStructArray[i].l = 4;
            smallStructArray[i].f = (float)5.0;
            smallStructArray[i].d = 6.0;
            smallStructArray[i].str = "7";
            smallStructArray[i].e = Test.MyEnum.enum2;
            smallStructArray[i].p = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
        }

        Test.MyClass[] myClassArray = new Test.MyClass[4];
        for (int i = 0; i < myClassArray.Length; ++i)
        {
            myClassArray[i] = new Test.MyClass();
            myClassArray[i].c = myClassArray[i];
            myClassArray[i].o = myClassArray[i];
            myClassArray[i].s = new Test.SmallStruct();
            myClassArray[i].s.e = Test.MyEnum.enum2;
            myClassArray[i].seq1 = new bool[] { true, false, true, false };
            myClassArray[i].seq2 = new byte[] { (byte)1, (byte)2, (byte)3, (byte)4 };
            myClassArray[i].seq3 = new short[] { (short)1, (short)2, (short)3, (short)4 };
            myClassArray[i].seq4 = new int[] { 1, 2, 3, 4 };
            myClassArray[i].seq5 = new long[] { 1, 2, 3, 4 };
            myClassArray[i].seq6 = new float[] { (float)1, (float)2, (float)3, (float)4 };
            myClassArray[i].seq7 = new double[] { (double)1, (double)2, (double)3, (double)4 };
            myClassArray[i].seq8 = new string[] { "string1", "string2", "string3", "string4" };
            myClassArray[i].seq9 = new Test.MyEnum[] { Test.MyEnum.enum3, Test.MyEnum.enum2, Test.MyEnum.enum1 };
            myClassArray[i].seq10 = new Test.MyClass[4]; // null elements.
            myClassArray[i].d = new System.Collections.Generic.Dictionary<string, Test.MyClass>();
            myClassArray[i].d["hi"] = myClassArray[i];
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.MyClassSHelper.write(@out, myClassArray);
            @out.writePendingValues();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyClass[] arr2 = Test.MyClassSHelper.read(@in);
            @in.readPendingValues();
            test(arr2.Length == myClassArray.Length);
            for (int i = 0; i < arr2.Length; ++i)
            {
                test(arr2[i] != null);
                test(arr2[i].c == arr2[i]);
                test(arr2[i].o == arr2[i]);
                test(arr2[i].s.e == Test.MyEnum.enum2);
                test(Compare(arr2[i].seq1, myClassArray[i].seq1));
                test(Compare(arr2[i].seq2, myClassArray[i].seq2));
                test(Compare(arr2[i].seq3, myClassArray[i].seq3));
                test(Compare(arr2[i].seq4, myClassArray[i].seq4));
                test(Compare(arr2[i].seq5, myClassArray[i].seq5));
                test(Compare(arr2[i].seq6, myClassArray[i].seq6));
                test(Compare(arr2[i].seq7, myClassArray[i].seq7));
                test(Compare(arr2[i].seq8, myClassArray[i].seq8));
                test(Compare(arr2[i].seq9, myClassArray[i].seq9));
                test(arr2[i].d["hi"].Equals(arr2[i]));
            }

            Test.MyClass[][] arrS =
            {
                myClassArray,
                new Test.MyClass[0],
                myClassArray
            };
            @out = new Ice.OutputStream(communicator);
            Test.MyClassSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Test.MyClass[][] arr2S = Test.MyClassSSHelper.read(@in);
            test(arr2S.Length == arrS.Length);
            test(arr2S[0].Length == arrS[0].Length);
            test(arr2S[1].Length == arrS[1].Length);
            test(arr2S[2].Length == arrS[2].Length);
        }

        {
            Test.MyInterface i = new MyInterfaceI();
            @out = new Ice.OutputStream(communicator);
            @out.writeValue(i);
            @out.writePendingValues();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            TestReadValueCallback cb = new TestReadValueCallback();
            @in.readValue(cb.invoke);
            @in.readPendingValues();
            test(cb.obj != null);
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.MyClass obj = new Test.MyClass();
            obj.s = new Test.SmallStruct();
            obj.s.e = Test.MyEnum.enum2;
            TestValueWriter writer = new TestValueWriter(obj);
            @out.writeValue(writer);
            @out.writePendingValues();
            byte[] data = @out.finished();
            test(writer.called);
            factoryWrapper.setFactory(TestObjectFactory);
            @in = new Ice.InputStream(communicator, data);
            TestReadValueCallback cb = new TestReadValueCallback();
            @in.readValue(cb.invoke);
            @in.readPendingValues();
            test(cb.obj != null);
            test(cb.obj is TestValueReader);
            TestValueReader reader = (TestValueReader)cb.obj;
            test(reader.called);
            test(reader.obj != null);
            test(reader.obj.s.e == Test.MyEnum.enum2);
            factoryWrapper.setFactory(null);
        }

        {
            @out = new Ice.OutputStream(communicator);
            Test.MyException ex = new Test.MyException();

            Test.MyClass c = new Test.MyClass();
            c.c = c;
            c.o = c;
            c.s = new Test.SmallStruct();
            c.s.e = Test.MyEnum.enum2;
            c.seq1 = new bool[] { true, false, true, false };
            c.seq2 = new byte[] { (byte)1, (byte)2, (byte)3, (byte)4 };
            c.seq3 = new short[] { (short)1, (short)2, (short)3, (short)4 };
            c.seq4 = new int[] { 1, 2, 3, 4 };
            c.seq5 = new long[] { 1, 2, 3, 4 };
            c.seq6 = new float[] { (float)1, (float)2, (float)3, (float)4 };
            c.seq7 = new double[] { (double)1, (double)2, (double)3, (double)4 };
            c.seq8 = new string[] { "string1", "string2", "string3", "string4" };
            c.seq9 = new Test.MyEnum[] { Test.MyEnum.enum3, Test.MyEnum.enum2, Test.MyEnum.enum1 };
            c.seq10 = new Test.MyClass[4]; // null elements.
            c.d = new Dictionary<string, Test.MyClass>();
            c.d.Add("hi", c);

            ex.c = c;

            @out.writeException(ex);
            byte[] data = @out.finished();

            @in = new Ice.InputStream(communicator, data);
            try
            {
                @in.throwException();
                test(false);
            }
            catch (Test.MyException ex1)
            {
                test(ex1.c.s.e == c.s.e);
                test(Compare(ex1.c.seq1, c.seq1));
                test(Compare(ex1.c.seq2, c.seq2));
                test(Compare(ex1.c.seq3, c.seq3));
                test(Compare(ex1.c.seq4, c.seq4));
                test(Compare(ex1.c.seq5, c.seq5));
                test(Compare(ex1.c.seq6, c.seq6));
                test(Compare(ex1.c.seq7, c.seq7));
                test(Compare(ex1.c.seq8, c.seq8));
                test(Compare(ex1.c.seq9, c.seq9));
            }
            catch (Ice.UserException)
            {
                test(false);
            }
        }

        {
            Dictionary<byte, bool> dict = new Dictionary<byte, bool>();
            dict.Add((byte)4, true);
            dict.Add((byte)1, false);
            @out = new Ice.OutputStream(communicator);
            Test.ByteBoolDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary<byte, bool> dict2 = Test.ByteBoolDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary<short, int> dict = new Dictionary<short, int>();
            dict.Add((short)1, 9);
            dict.Add((short)4, 8);
            @out = new Ice.OutputStream(communicator);
            Test.ShortIntDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary<short, int> dict2 = Test.ShortIntDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary<long, float> dict = new Dictionary<long, float>();
            dict.Add((long)123809828, (float)0.51f);
            dict.Add((long)123809829, (float)0.56f);
            @out = new Ice.OutputStream(communicator);
            Test.LongFloatDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary<long, float> dict2 = Test.LongFloatDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary<string, string> dict = new Dictionary<string, string>();
            dict.Add("key1", "value1");
            dict.Add("key2", "value2");
            @out = new Ice.OutputStream(communicator);
            Test.StringStringDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary<string, string> dict2 = Test.StringStringDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary<string, Test.MyClass> dict = new Dictionary<string, Test.MyClass>();
            Test.MyClass c;
            c = new Test.MyClass();
            c.s = new Test.SmallStruct();
            c.s.e = Test.MyEnum.enum2;
            dict.Add("key1", c);
            c = new Test.MyClass();
            c.s = new Test.SmallStruct();
            c.s.e = Test.MyEnum.enum3;
            dict.Add("key2", c);
            @out = new Ice.OutputStream(communicator);
            Test.StringMyClassDHelper.write(@out, dict);
            @out.writePendingValues();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Dictionary<string, Test.MyClass> dict2 = Test.StringMyClassDHelper.read(@in);
            @in.readPendingValues();
            test(dict2.Count == dict.Count);
            test(dict2["key1"].s.e == Test.MyEnum.enum2);
            test(dict2["key2"].s.e == Test.MyEnum.enum3);
        }

        {
            bool[] arr =
            {
                true,
                false,
                true,
                false
            };
            @out = new Ice.OutputStream(communicator);
            List<bool> l = new List<bool>(arr);
            Test.BoolListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List<bool> l2 = Test.BoolListHelper.read(@in);
            test(Compare(l, l2));
        }

        {
            byte[] arr =
            {
                (byte)0x01,
                (byte)0x11,
                (byte)0x12,
                (byte)0x22
            };
            @out = new Ice.OutputStream(communicator);
            List<byte> l = new List<byte>(arr);
            Test.ByteListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List<byte> l2 = Test.ByteListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = new Ice.OutputStream(communicator);
            List<Test.MyEnum> l = new List<Test.MyEnum>(arr);
            Test.MyEnumListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List<Test.MyEnum> l2 = Test.MyEnumListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            List<Test.SmallStruct> l = new List<Test.SmallStruct>(smallStructArray);
            Test.SmallStructListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List<Test.SmallStruct> l2 = Test.SmallStructListHelper.read(@in);
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i].Equals(smallStructArray[i]));
            }
        }

        {
            @out = new Ice.OutputStream(communicator);
            List<Test.MyClass> l = new List<Test.MyClass>(myClassArray);
            Test.MyClassListHelper.write(@out, l);
            @out.writePendingValues();
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List<Test.MyClass> l2 = Test.MyClassListHelper.read(@in);
            @in.readPendingValues();
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i] != null);
                test(l2[i].c == l2[i]);
                test(l2[i].o == l2[i]);
                test(l2[i].s.e == Test.MyEnum.enum2);
                test(Compare(l2[i].seq1, l[i].seq1));
                test(Compare(l2[i].seq2, l[i].seq2));
                test(Compare(l2[i].seq3, l[i].seq3));
                test(Compare(l2[i].seq4, l[i].seq4));
                test(Compare(l2[i].seq5, l[i].seq5));
                test(Compare(l2[i].seq6, l[i].seq6));
                test(Compare(l2[i].seq7, l[i].seq7));
                test(Compare(l2[i].seq8, l[i].seq8));
                test(Compare(l2[i].seq9, l[i].seq9));
                test(l2[i].d["hi"].Equals(l2[i]));
            }
        }

        {
            Test.MyClassPrx[] arr = new Test.MyClassPrx[2];
            arr[0] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("zero"));
            arr[1] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("one"));
            @out = new Ice.OutputStream(communicator);
            List<Test.MyClassPrx> l = new List<Test.MyClassPrx>(arr);
            Test.MyClassProxyListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List<Test.MyClassPrx> l2 = Test.MyClassProxyListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            short[] arr =
            {
                (short)0x01,
                (short)0x11,
                (short)0x12,
                (short)0x22
            };
            @out = new Ice.OutputStream(communicator);
            LinkedList<short> l = new LinkedList<short>(arr);
            Test.ShortLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            LinkedList<short> l2 = Test.ShortLinkedListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            int[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            LinkedList<int> l = new LinkedList<int>(arr);
            Test.IntLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            LinkedList<int> l2 = Test.IntLinkedListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = new Ice.OutputStream(communicator);
            LinkedList<Test.MyEnum> l = new LinkedList<Test.MyEnum>(arr);
            Test.MyEnumLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            LinkedList<Test.MyEnum> l2 = Test.MyEnumLinkedListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            LinkedList<Test.SmallStruct> l = new LinkedList<Test.SmallStruct>(smallStructArray);
            Test.SmallStructLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            LinkedList<Test.SmallStruct> l2 = Test.SmallStructLinkedListHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator<Test.SmallStruct> e = l.GetEnumerator();
            IEnumerator<Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            long[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = new Ice.OutputStream(communicator);
            Stack<long> l = new Stack<long>(arr);
            Test.LongStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack<long> l2 = Test.LongStackHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            float[] arr =
            {
                (float)1,
                (float)2,
                (float)3,
                (float)4
            };
            @out = new Ice.OutputStream(communicator);
            Stack<float> l = new Stack<float>(arr);
            Test.FloatStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack<float> l2 = Test.FloatStackHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            Stack<Test.SmallStruct> l = new Stack<Test.SmallStruct>(smallStructArray);
            Test.SmallStructStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack<Test.SmallStruct> l2 = Test.SmallStructStackHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator<Test.SmallStruct> e = l.GetEnumerator();
            IEnumerator<Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            Test.MyClassPrx[] arr = new Test.MyClassPrx[2];
            arr[0] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("zero"));
            arr[1] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("one"));
            @out = new Ice.OutputStream(communicator);
            Stack<Test.MyClassPrx> l = new Stack<Test.MyClassPrx>(arr);
            Test.MyClassProxyStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack<Test.MyClassPrx> l2 = Test.MyClassProxyStackHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            double[] arr =
            {
                (double)1,
                (double)2,
                (double)3,
                (double)4
            };
            @out = new Ice.OutputStream(communicator);
            Queue<double> l = new Queue<double>(arr);
            Test.DoubleQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Queue<double> l2 = Test.DoubleQueueHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            @out = new Ice.OutputStream(communicator);
            Queue<string> l = new Queue<string>(arr);
            Test.StringQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Queue<string> l2 = Test.StringQueueHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            @out = new Ice.OutputStream(communicator);
            Queue<Test.SmallStruct> l = new Queue<Test.SmallStruct>(smallStructArray);
            Test.SmallStructQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Queue<Test.SmallStruct> l2 = Test.SmallStructQueueHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator<Test.SmallStruct> e = l.GetEnumerator();
            IEnumerator<Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            List<string[]> l = new List<string[]>(arrS);
            Test.StringSListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            List<string[]> l2 = Test.StringSListHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = new Ice.OutputStream(communicator);
            Stack<string[]> l = new Stack<string[]>(arrS);
            Test.StringSStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            Stack<string[]> l2 = Test.StringSStackHelper.read(@in);
            test(Compare(l2, l));
        }

        {
            SortedDictionary<string, string> dict = new SortedDictionary<string, string>();
            dict.Add("key1", "value1");
            dict.Add("key2", "value2");
            @out = new Ice.OutputStream(communicator);
            Test.SortedStringStringDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = new Ice.InputStream(communicator, data);
            IDictionary<string, string> dict2 = Test.SortedStringStringDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        WriteLine("ok");
        return 0;
    }
Ejemplo n.º 39
0
 public override void read(Ice.InputStream @in)
 {
     obj = new Test.MyClass();
     obj.read__(@in);
     called = true;
 }
Ejemplo n.º 40
0
 public virtual void read__(InputStream is__)
 {
      is__.startObject();
      readImpl__(is__);
      is__.endObject(false);
 }
Ejemplo n.º 41
0
        public override int run(string[] args)
        {
            if (args.Length > 0)
            {
                Console.Error.WriteLine(appName() + ": too many arguments");
                return(1);
            }

            Ice.ObjectPrx obj = communicator().propertyToProxy("Printer.Proxy");

            menu();

            string line = null;

            do
            {
                try
                {
                    Console.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    byte[] outParams;

                    if (line.Equals("1"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = Ice.Util.createOutputStream(communicator());
                        outStream.startEncapsulation();
                        outStream.writeString("The streaming API works!");
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printString", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }

                        outStream.destroy();
                    }
                    else if (line.Equals("2"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = Ice.Util.createOutputStream(communicator());
                        outStream.startEncapsulation();
                        string[] arr = { "The", "streaming", "API", "works!" };
                        Demo.StringSeqHelper.write(outStream, arr);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printStringSequence", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }

                        outStream.destroy();
                    }
                    else if (line.Equals("3"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = Ice.Util.createOutputStream(communicator());
                        outStream.startEncapsulation();
                        Dictionary <string, string> dict = new Dictionary <string, string>();
                        dict["The"] = "streaming";
                        dict["API"] = "works!";
                        Demo.StringDictHelper.write(outStream, dict);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printDictionary", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }

                        outStream.destroy();
                    }
                    else if (line.Equals("4"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = Ice.Util.createOutputStream(communicator());
                        outStream.startEncapsulation();
                        Demo.ColorHelper.write(outStream, Demo.Color.green);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printEnum", Ice.OperationMode.Normal, outStream.finished(), out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }

                        outStream.destroy();
                    }
                    else if (line.Equals("5"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = Ice.Util.createOutputStream(communicator());
                        outStream.startEncapsulation();
                        Demo.Structure s = new Demo.Structure();
                        s.name  = "red";
                        s.value = Demo.Color.red;
                        s.ice_write(outStream);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printStruct", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }

                        outStream.destroy();
                    }
                    else if (line.Equals("6"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = Ice.Util.createOutputStream(communicator());
                        outStream.startEncapsulation();
                        Demo.Structure[] arr = new Demo.Structure[3];
                        arr[0]       = new Demo.Structure();
                        arr[0].name  = "red";
                        arr[0].value = Demo.Color.red;
                        arr[1]       = new Demo.Structure();
                        arr[1].name  = "green";
                        arr[1].value = Demo.Color.green;
                        arr[2]       = new Demo.Structure();
                        arr[2].name  = "blue";
                        arr[2].value = Demo.Color.blue;
                        Demo.StructureSeqHelper.write(outStream, arr);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printStructSequence", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }

                        outStream.destroy();
                    }
                    else if (line.Equals("7"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = Ice.Util.createOutputStream(communicator());
                        outStream.startEncapsulation();
                        Demo.C c = new Demo.C();
                        c.s       = new Demo.Structure();
                        c.s.name  = "blue";
                        c.s.value = Demo.Color.blue;
                        Demo.CHelper.write(outStream, c);
                        outStream.writePendingObjects();
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printClass", Ice.OperationMode.Normal, outStream.finished(), out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }

                        outStream.destroy();
                    }
                    else if (line.Equals("8"))
                    {
                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("getValues", Ice.OperationMode.Normal, null, out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                            continue;
                        }

                        //
                        // Unmarshal the results.
                        //
                        Ice.InputStream inStream = Ice.Util.createInputStream(communicator(), outParams);
                        inStream.startEncapsulation();
                        Demo.CHelper ch = new Demo.CHelper(inStream);
                        ch.read();
                        String str = inStream.readString();
                        inStream.readPendingObjects();
                        inStream.destroy();
                        Demo.C c = ch.value;
                        Console.Error.WriteLine("Got string `" + str + "' and class: s.name=" + c.s.name +
                                                ", s.value=" + c.s.value);
                    }
                    else if (line.Equals("9"))
                    {
                        //
                        // Invoke operation.
                        //
                        if (obj.ice_invoke("throwPrintFailure", Ice.OperationMode.Normal, null, out outParams))
                        {
                            Console.Error.WriteLine("Expected exception");
                            continue;
                        }

                        Ice.InputStream inStream = Ice.Util.createInputStream(communicator(), outParams);
                        inStream.startEncapsulation();
                        try
                        {
                            inStream.throwException();
                        }
                        catch (Demo.PrintFailure)
                        {
                            // Expected.
                        }
                        catch (Ice.UserException)
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                        inStream.endEncapsulation();
                        inStream.destroy();
                    }
                    else if (line.Equals("s"))
                    {
                        obj.ice_invoke("shutdown", Ice.OperationMode.Normal, null, out outParams);
                    }
                    else if (line.Equals("x"))
                    {
                        // Nothing to do.
                    }
                    else if (line.Equals("?"))
                    {
                        menu();
                    }
                    else
                    {
                        Console.Error.WriteLine("unknown command `" + line + "'");
                        menu();
                    }
                }
                catch (Ice.LocalException ex)
                {
                    Console.Error.WriteLine(ex);
                }
            }while(!line.Equals("x"));

            return(0);
        }
Ejemplo n.º 42
0
 /// <summary>
 /// @param in The input stream to read from.
 /// @param rid If <code>true</code>, extraction begins by reading a Slice type ID
 /// first. If <code>false</code>, the leading type ID is not read. This is used
 /// by the unmarshaling code in case the type ID has already been read as part
 /// of other unmarshaling activities.
 /// </summary>
 public abstract void read(InputStream inStream, bool rid);
Ejemplo n.º 43
0
 ice_invoke(byte[] inParams, out byte[] outParams, Ice.Current current)
 {
     Ice.Communicator communicator = current.adapter.getCommunicator();
     Ice.InputStream  inS          = new Ice.InputStream(communicator, inParams);
     inS.startEncapsulation();
     Ice.OutputStream outS = new Ice.OutputStream(communicator);
     outS.startEncapsulation();
     if (current.operation.Equals("opOneway"))
     {
         outParams = new byte[0];
         return(true);
     }
     else if (current.operation.Equals("opString"))
     {
         string s = inS.readString();
         outS.writeString(s);
         outS.writeString(s);
         outS.endEncapsulation();
         outParams = outS.finished();
         return(true);
     }
     else if (current.operation.Equals("opException"))
     {
         if (current.ctx.ContainsKey("raise"))
         {
             throw new Test.MyException();
         }
         Test.MyException ex = new Test.MyException();
         outS.writeException(ex);
         outS.endEncapsulation();
         outParams = outS.finished();
         return(false);
     }
     else if (current.operation.Equals("shutdown"))
     {
         communicator.shutdown();
         outParams = null;
         return(true);
     }
     else if (current.operation.Equals("ice_isA"))
     {
         string s = inS.readString();
         if (s.Equals("::Test::MyClass"))
         {
             outS.writeBool(true);
         }
         else
         {
             outS.writeBool(false);
         }
         outS.endEncapsulation();
         outParams = outS.finished();
         return(true);
     }
     else
     {
         Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
         ex.id        = current.id;
         ex.facet     = current.facet;
         ex.operation = current.operation;
         throw ex;
     }
 }
Ejemplo n.º 44
0
    public static Test.MyClassPrx allTests(Ice.Communicator communicator)
    {
        Ice.ObjectPrx baseProxy = communicator.stringToProxy("test:default -p 12010");
        Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy);
        Test.MyClassPrx oneway = Test.MyClassPrxHelper.uncheckedCast(cl.ice_oneway());
        Test.MyClassPrx batchOneway = Test.MyClassPrxHelper.uncheckedCast(cl.ice_batchOneway());

        Write("testing ice_invoke... ");
        Flush();

        {
            byte[] inEncaps, outEncaps;
            if(!oneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps))
            {
                test(false);
            }

            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            batchOneway.ice_flushBatchRequests();

            Ice.OutputStream outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            inEncaps = outS.finished();

            if(cl.ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, out outEncaps))
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }
        }

        for(int i = 0; i < 2; ++i)
        {
            byte[] outEncaps;
            Dictionary<string, string> ctx = null;
            if(i == 1)
            {
                ctx = new Dictionary<string, string>();
                ctx["raise"] = "";
            }

            if(cl.ice_invoke("opException", Ice.OperationMode.Normal, null, out outEncaps, ctx))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch(Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch(Exception)
                {
                    test(false);
                }
            }
        }

        WriteLine("ok");

        Write("testing asynchronous ice_invoke with Async Task API... ");
        Flush();

        {
            try
            {
                oneway.ice_invokeAsync("opOneway", Ice.OperationMode.Normal, null).Wait();
            }
            catch(Exception)
            {
                test(false);
            }

            Ice.OutputStream outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            byte[] inEncaps = outS.finished();

            // begin_ice_invoke with no callback
            var result = cl.ice_invokeAsync("opString", Ice.OperationMode.Normal, inEncaps).Result;
            if(result.returnValue)
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, result.outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }
        }

        {
            var result = cl.ice_invokeAsync("opException", Ice.OperationMode.Normal, null).Result;
            if(result.returnValue)
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, result.outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch(Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch(Exception)
                {
                    test(false);
                }
            }
        }

        WriteLine("ok");

        Write("testing asynchronous ice_invoke with AsyncResult API... ");
        Flush();

        {
            byte[] inEncaps, outEncaps;
            Ice.AsyncResult result = oneway.begin_ice_invoke("opOneway", Ice.OperationMode.Normal, null);
            if(!oneway.end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }

            Ice.OutputStream outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            inEncaps = outS.finished();

            // begin_ice_invoke with no callback
            result = cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps);
            if(cl.end_ice_invoke(out outEncaps, result))
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, cb.opString, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, cb.opString, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps).whenCompleted(cb.opStringNC, null);
            cb.check();
        }

        {
            // begin_ice_invoke with no callback
            Ice.AsyncResult result = cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null);
            byte[] outEncaps;
            if(cl.end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch(Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch(Exception)
                {
                    test(false);
                }
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null).whenCompleted(cb.opExceptionNC, null);
            cb.check();
        }

        WriteLine("ok");
        return cl;
    }
Ejemplo n.º 45
0
 protected abstract void readImpl__(InputStream is__);
Ejemplo n.º 46
0
        public override int run(string[] args)
        {
            if (args.Length > 0)
            {
                Console.Error.WriteLine(appName() + ": too many arguments");
                return(1);
            }

            var obj = communicator().propertyToProxy("Printer.Proxy");

            menu();

            string line = null;

            do
            {
                try
                {
                    Console.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if (line == null)
                    {
                        break;
                    }

                    byte[] outParams;

                    if (line.Equals("1"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        outStream.writeString("The streaming API works!");
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printString", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if (line.Equals("2"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        string[] arr = { "The", "streaming", "API", "works!" };
                        StringSeqHelper.write(outStream, arr);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printStringSequence", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if (line.Equals("3"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        var dict = new Dictionary <string, string>()
                        {
                            { "The", "streaming" },
                            { "API", "works!" }
                        };
                        StringDictHelper.write(outStream, dict);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printDictionary", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if (line.Equals("4"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        ColorHelper.write(outStream, Color.green);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printEnum", Ice.OperationMode.Normal, outStream.finished(), out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if (line.Equals("5"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        var s = new Structure("read", Color.red);
                        Structure.write(outStream, s);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printStruct", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if (line.Equals("6"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        var outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        Structure[] arr =
                        {
                            new Structure("red",   Color.red),
                            new Structure("green", Color.green),
                            new Structure("blue",  Color.blue)
                        };
                        StructureSeqHelper.write(outStream, arr);
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printStructSequence", Ice.OperationMode.Normal, outStream.finished(),
                                            out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if (line.Equals("7"))
                    {
                        //
                        // Marshal the in parameter.
                        //
                        Ice.OutputStream outStream = new Ice.OutputStream(communicator());
                        outStream.startEncapsulation();
                        var c = new C(new Structure("blue", Color.blue));
                        outStream.writeValue(c);
                        outStream.writePendingValues();
                        outStream.endEncapsulation();

                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("printClass", Ice.OperationMode.Normal, outStream.finished(), out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                    }
                    else if (line.Equals("8"))
                    {
                        //
                        // Invoke operation.
                        //
                        if (!obj.ice_invoke("getValues", Ice.OperationMode.Normal, null, out outParams))
                        {
                            Console.Error.WriteLine("Unknown user exception");
                            continue;
                        }

                        //
                        // Unmarshal the results.
                        //
                        var inStream = new Ice.InputStream(communicator(), outParams);
                        inStream.startEncapsulation();
                        var cb = new ReadValueCallback();
                        inStream.readValue(cb.invoke);
                        var str = inStream.readString();
                        inStream.readPendingValues();
                        var c = cb.obj as C;
                        Console.Error.WriteLine("Got string `" + str + "' and class: s.name=" + c.s.name +
                                                ", s.value=" + c.s.value);
                    }
                    else if (line.Equals("9"))
                    {
                        //
                        // Invoke operation.
                        //
                        if (obj.ice_invoke("throwPrintFailure", Ice.OperationMode.Normal, null, out outParams))
                        {
                            Console.Error.WriteLine("Expected exception");
                            continue;
                        }

                        var inStream = new Ice.InputStream(communicator(), outParams);
                        inStream.startEncapsulation();
                        try
                        {
                            inStream.throwException();
                        }
                        catch (PrintFailure)
                        {
                            // Expected.
                        }
                        catch (Ice.UserException)
                        {
                            Console.Error.WriteLine("Unknown user exception");
                        }
                        inStream.endEncapsulation();
                    }
                    else if (line.Equals("s"))
                    {
                        obj.ice_invoke("shutdown", Ice.OperationMode.Normal, null, out outParams);
                    }
                    else if (line.Equals("x"))
                    {
                        // Nothing to do.
                    }
                    else if (line.Equals("?"))
                    {
                        menu();
                    }
                    else
                    {
                        Console.Error.WriteLine("unknown command `" + line + "'");
                        menu();
                    }
                }
                catch (Ice.LocalException ex)
                {
                    Console.Error.WriteLine(ex);
                }
            }while(!line.Equals("x"));

            return(0);
        }
Ejemplo n.º 47
0
 public override bool ice_invoke(byte[] inParams, out byte[] outParams, Ice.Current current)
 {
     Ice.Communicator communicator = current.adapter.getCommunicator();
     Ice.InputStream inS = new Ice.InputStream(communicator, inParams);
     inS.startEncapsulation();
     Ice.OutputStream outS = new Ice.OutputStream(communicator);
     outS.startEncapsulation();
     if(current.operation.Equals("opOneway"))
     {
         outParams = new byte[0];
         return true;
     }
     else if(current.operation.Equals("opString"))
     {
         string s = inS.readString();
         outS.writeString(s);
         outS.writeString(s);
         outS.endEncapsulation();
         outParams = outS.finished();
         return true;
     }
     else if(current.operation.Equals("opException"))
     {
         if(current.ctx.ContainsKey("raise"))
         {
             throw new Test.MyException();
         }
         Test.MyException ex = new Test.MyException();
         outS.writeException(ex);
         outS.endEncapsulation();
         outParams = outS.finished();
         return false;
     }
     else if(current.operation.Equals("shutdown"))
     {
         communicator.shutdown();
         outParams = null;
         return true;
     }
     else if(current.operation.Equals("ice_isA"))
     {
         string s = inS.readString();
         if(s.Equals("::Test::MyClass"))
         {
             outS.writeBool(true);
         }
         else
         {
             outS.writeBool(false);
         }
         outS.endEncapsulation();
         outParams = outS.finished();
         return true;
     }
     else
     {
         Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
         ex.id = current.id;
         ex.facet = current.facet;
         ex.operation = current.operation;
         throw ex;
     }
 }
Ejemplo n.º 48
0
        internal ConnectionI(Communicator communicator, IceInternal.Instance instance,
                             IceInternal.ACMMonitor monitor, IceInternal.Transceiver transceiver,
                             IceInternal.Connector connector, IceInternal.EndpointI endpoint, ObjectAdapterI adapter)
        {
            _communicator = communicator;
            _instance = instance;
            _monitor = monitor;
            _transceiver = transceiver;
            _desc = transceiver.ToString();
            _type = transceiver.protocol();
            _connector = connector;
            _endpoint = endpoint;
            _adapter = adapter;
            InitializationData initData = instance.initializationData();
            _logger = initData.logger; // Cached for better performance.
            _traceLevels = instance.traceLevels(); // Cached for better performance.
            _timer = instance.timer();
            _writeTimeout = new TimeoutCallback(this);
            _writeTimeoutScheduled = false;
            _readTimeout = new TimeoutCallback(this);
            _readTimeoutScheduled = false;
            _warn = initData.properties.getPropertyAsInt("Ice.Warn.Connections") > 0;
            _warnUdp = initData.properties.getPropertyAsInt("Ice.Warn.Datagrams") > 0;
            _cacheBuffers = instance.cacheMessageBuffers() > 0;
            if(_monitor != null && _monitor.getACM().timeout > 0)
            {
                _acmLastActivity = IceInternal.Time.currentMonotonicTimeMillis();
            }
            else
            {
                _acmLastActivity = -1;
            }
            _nextRequestId = 1;
            _messageSizeMax = adapter != null ? adapter.messageSizeMax() : instance.messageSizeMax();
            _batchRequestQueue = new IceInternal.BatchRequestQueue(instance, _endpoint.datagram());
            _readStream = new InputStream(instance, Util.currentProtocolEncoding);
            _readHeader = false;
            _readStreamPos = -1;
            _writeStream = new OutputStream(instance, Util.currentProtocolEncoding);
            _writeStreamPos = -1;
            _dispatchCount = 0;
            _state = StateNotInitialized;

            _compressionLevel = initData.properties.getPropertyAsIntWithDefault("Ice.Compression.Level", 1);
            if(_compressionLevel < 1)
            {
                _compressionLevel = 1;
            }
            else if(_compressionLevel > 9)
            {
                _compressionLevel = 9;
            }

            if(adapter != null)
            {
                _servantManager = adapter.getServantManager();
            }

            try
            {
                if(adapter != null)
                {
                    _threadPool = adapter.getThreadPool();
                }
                else
                {
                    _threadPool = instance.clientThreadPool();
                }
                _threadPool.initialize(this);
            }
            catch(LocalException)
            {
                throw;
            }
            catch(System.Exception ex)
            {
                throw new SyscallException(ex);
            }
        }
Ejemplo n.º 49
0
        private async ValueTask InvokeAllAsync(Ice.OutputStream os, int requestId)
        {
            // The object adapter DirectCount was incremented by the caller and we are responsible to decrement it
            // upon completion.

            Ice.Instrumentation.IDispatchObserver?dispatchObserver = null;
            try
            {
                if (_traceLevels.Protocol >= 1)
                {
                    FillInValue(os, new Ice.OutputStream.Position(0, 10), os.Size);
                    if (requestId > 0)
                    {
                        FillInValue(os, new Ice.OutputStream.Position(0, Ice1Definitions.HeaderSize), requestId);
                    }
                    TraceUtil.TraceSend(os, _logger, _traceLevels);
                }

                // TODO Avoid copy OutputStream buffer
                var requestFrame = new Ice.InputStream(os.Communicator, os.Encoding, os.ToArray());
                requestFrame.Pos = Ice1Definitions.RequestHeader.Length;

                int start   = requestFrame.Pos;
                var current = new Ice.Current(requestId, requestFrame, _adapter);

                // Then notify and set dispatch observer, if any.
                Ice.Instrumentation.ICommunicatorObserver?communicatorObserver = _adapter.Communicator.Observer;
                if (communicatorObserver != null)
                {
                    int encapsSize = requestFrame.GetEncapsulationSize();

                    dispatchObserver = communicatorObserver.GetDispatchObserver(current,
                                                                                requestFrame.Pos - start + encapsSize);
                    dispatchObserver?.Attach();
                }

                bool amd = true;
                try
                {
                    Ice.IObject?servant = current.Adapter.Find(current.Id, current.Facet);

                    if (servant == null)
                    {
                        amd = false;
                        throw new Ice.ObjectNotExistException(current.Id, current.Facet, current.Operation);
                    }

                    ValueTask <Ice.OutputStream> vt = servant.DispatchAsync(requestFrame, current);
                    amd = !vt.IsCompleted;
                    if (requestId != 0)
                    {
                        Ice.OutputStream responseFrame = await vt.ConfigureAwait(false);

                        dispatchObserver?.Reply(responseFrame.Size - Ice1Definitions.HeaderSize - 4);
                        SendResponse(requestId, responseFrame, amd);
                    }
                }
                catch (System.Exception ex)
                {
                    if (requestId != 0)
                    {
                        Ice.RemoteException actualEx;
                        if (ex is Ice.RemoteException remoteEx && !remoteEx.ConvertToUnhandled)
                        {
                            actualEx = remoteEx;
                        }
                        else
                        {
                            actualEx = new UnhandledException(current.Id, current.Facet, current.Operation, ex);
                        }

                        Incoming.ReportException(actualEx, dispatchObserver, current);
                        var responseFrame = new Ice.OutgoingResponseFrame(current, actualEx);
                        dispatchObserver?.Reply(responseFrame.Size - Ice1Definitions.HeaderSize - 4);
                        SendResponse(requestId, responseFrame, amd);
                    }
                }
            }
Ejemplo n.º 50
0
        private void invokeAll(InputStream stream, int invokeNum, int requestId, byte compress,
                               IceInternal.ServantManager servantManager, ObjectAdapter adapter)
        {
            //
            // Note: In contrast to other private or protected methods, this
            // operation must be called *without* the mutex locked.
            //

            IceInternal.Incoming inc = null;
            try
            {
                while(invokeNum > 0)
                {
                    //
                    // Prepare the invocation.
                    //
                    bool response = !_endpoint.datagram() && requestId != 0;
                    Debug.Assert(!response || invokeNum == 1);

                    inc = getIncoming(adapter, response, compress, requestId);

                    //
                    // Dispatch the invocation.
                    //
                    inc.invoke(servantManager, stream);

                    --invokeNum;

                    reclaimIncoming(inc);
                    inc = null;
                }

                stream.clear();
            }
            catch(LocalException ex)
            {
                invokeException(requestId, ex, invokeNum, false);
            }
            finally
            {
                if(inc != null)
                {
                    reclaimIncoming(inc);
                }
            }
        }
Ejemplo n.º 51
0
 protected virtual void readImpl__(InputStream is__)
 {
 }
Ejemplo n.º 52
0
    public override bool ice_invoke(byte[] inParams, out byte[] outParams, Ice.Current current)
    {
        outParams = null;

        Ice.Communicator communicator = current.adapter.getCommunicator();

        Ice.InputStream inStream = null;
        if (inParams.Length > 0)
        {
            inStream = new Ice.InputStream(communicator, inParams);
            inStream.startEncapsulation();
        }

        if (current.operation.Equals("printString"))
        {
            string message = inStream.readString();
            inStream.endEncapsulation();
            Console.WriteLine("Printing string `" + message + "'");
            return(true);
        }
        else if (current.operation.Equals("printStringSequence"))
        {
            String[] seq = Demo.StringSeqHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing string sequence {");
            for (int i = 0; i < seq.Length; ++i)
            {
                if (i > 0)
                {
                    Console.Write(", ");
                }
                Console.Write("'" + seq[i] + "'");
            }
            Console.WriteLine("}");
            return(true);
        }
        else if (current.operation.Equals("printDictionary"))
        {
            Dictionary <string, string> dict = Demo.StringDictHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing dictionary {");
            bool first = true;
            foreach (KeyValuePair <string, string> e in dict)
            {
                if (!first)
                {
                    Console.Write(", ");
                }
                first = false;
                Console.Write(e.Key + "=" + e.Value);
            }
            Console.WriteLine("}");
            return(true);
        }
        else if (current.operation.Equals("printEnum"))
        {
            Demo.Color c = (Demo.Color)inStream.readEnum((int)Demo.Color.blue);
            inStream.endEncapsulation();
            Console.WriteLine("Printing enum " + c);
            return(true);
        }
        else if (current.operation.Equals("printStruct"))
        {
            Demo.Structure s = new Demo.Structure();
            s.read__(inStream);
            inStream.endEncapsulation();
            Console.WriteLine("Printing struct: name=" + s.name + ", value=" + s.value);
            return(true);
        }
        else if (current.operation.Equals("printStructSequence"))
        {
            Demo.Structure[] seq = Demo.StructureSeqHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing struct sequence: {");
            for (int i = 0; i < seq.Length; ++i)
            {
                if (i > 0)
                {
                    Console.Write(", ");
                }
                Console.Write(seq[i].name + "=" + seq[i].value);
            }
            Console.WriteLine("}");
            return(true);
        }
        else if (current.operation.Equals("printClass"))
        {
            ReadObjectCallback cb = new ReadObjectCallback();
            inStream.readObject(cb.invoke);
            inStream.readPendingObjects();
            inStream.endEncapsulation();
            Demo.C c = cb.obj as Demo.C;
            Console.WriteLine("Printing class: s.name=" + c.s.name + ", s.value=" + c.s.value);
            return(true);
        }
        else if (current.operation.Equals("getValues"))
        {
            Demo.C c = new Demo.C();
            c.s       = new Demo.Structure();
            c.s.name  = "green";
            c.s.value = Demo.Color.green;
            Ice.OutputStream outStream = new Ice.OutputStream(communicator);
            outStream.startEncapsulation();
            outStream.writeObject(c);
            outStream.writeString("hello");
            outStream.writePendingObjects();
            outStream.endEncapsulation();
            outParams = outStream.finished();
            return(true);
        }
        else if (current.operation.Equals("throwPrintFailure"))
        {
            Console.WriteLine("Throwing PrintFailure");
            Demo.PrintFailure ex = new Demo.PrintFailure();
            ex.reason = "paper tray empty";
            Ice.OutputStream outStream = new Ice.OutputStream(communicator);
            outStream.startEncapsulation();
            outStream.writeException(ex);
            outStream.endEncapsulation();
            outParams = outStream.finished();
            return(false);
        }
        else if (current.operation.Equals("shutdown"))
        {
            current.adapter.getCommunicator().shutdown();
            return(true);
        }
        else
        {
            Ice.OperationNotExistException ex = new Ice.OperationNotExistException();
            ex.id        = current.id;
            ex.facet     = current.facet;
            ex.operation = current.operation;
            throw ex;
        }
    }
Ejemplo n.º 53
0
    public static Test.MyClassPrx allTests(TestCommon.Application app)
    {
        Ice.Communicator communicator = app.communicator();
        Ice.ObjectPrx    baseProxy    = communicator.stringToProxy("test:" + app.getTestEndpoint(0));
        Test.MyClassPrx  cl           = Test.MyClassPrxHelper.checkedCast(baseProxy);
        Test.MyClassPrx  oneway       = Test.MyClassPrxHelper.uncheckedCast(cl.ice_oneway());
        Test.MyClassPrx  batchOneway  = Test.MyClassPrxHelper.uncheckedCast(cl.ice_batchOneway());

        Write("testing ice_invoke... ");
        Flush();

        {
            byte[] inEncaps, outEncaps;
            if (!oneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps))
            {
                test(false);
            }

            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            test(batchOneway.ice_invoke("opOneway", Ice.OperationMode.Normal, null, out outEncaps));
            batchOneway.ice_flushBatchRequests();

            Ice.OutputStream outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            inEncaps = outS.finished();

            if (cl.ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, out outEncaps))
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }
        }

        for (int i = 0; i < 2; ++i)
        {
            byte[] outEncaps;
            Dictionary <string, string> ctx = null;
            if (i == 1)
            {
                ctx          = new Dictionary <string, string>();
                ctx["raise"] = "";
            }

            if (cl.ice_invoke("opException", Ice.OperationMode.Normal, null, out outEncaps, ctx))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch (Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch (Exception)
                {
                    test(false);
                }
            }
        }

        WriteLine("ok");

        Write("testing asynchronous ice_invoke with Async Task API... ");
        Flush();

        {
            try
            {
                oneway.ice_invokeAsync("opOneway", Ice.OperationMode.Normal, null).Wait();
            }
            catch (Exception)
            {
                test(false);
            }

            Ice.OutputStream outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            byte[] inEncaps = outS.finished();

            // begin_ice_invoke with no callback
            var result = cl.ice_invokeAsync("opString", Ice.OperationMode.Normal, inEncaps).Result;
            if (result.returnValue)
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, result.outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }
        }

        {
            var result = cl.ice_invokeAsync("opException", Ice.OperationMode.Normal, null).Result;
            if (result.returnValue)
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, result.outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch (Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch (Exception)
                {
                    test(false);
                }
            }
        }

        WriteLine("ok");

        Write("testing asynchronous ice_invoke with AsyncResult API... ");
        Flush();

        {
            byte[]          inEncaps, outEncaps;
            Ice.AsyncResult result = oneway.begin_ice_invoke("opOneway", Ice.OperationMode.Normal, null);
            if (!oneway.end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }

            Ice.OutputStream outS = new Ice.OutputStream(communicator);
            outS.startEncapsulation();
            outS.writeString(testString);
            outS.endEncapsulation();
            inEncaps = outS.finished();

            // begin_ice_invoke with no callback
            result = cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps);
            if (cl.end_ice_invoke(out outEncaps, result))
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                string s = inS.readString();
                test(s.Equals(testString));
                s = inS.readString();
                inS.endEncapsulation();
                test(s.Equals(testString));
            }
            else
            {
                test(false);
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, cb.opString, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps, cb.opString, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opString", Ice.OperationMode.Normal, inEncaps).whenCompleted(cb.opStringNC, null);
            cb.check();
        }

        {
            // begin_ice_invoke with no callback
            Ice.AsyncResult result = cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null);
            byte[]          outEncaps;
            if (cl.end_ice_invoke(out outEncaps, result))
            {
                test(false);
            }
            else
            {
                Ice.InputStream inS = new Ice.InputStream(communicator, outEncaps);
                inS.startEncapsulation();
                try
                {
                    inS.throwException();
                }
                catch (Test.MyException)
                {
                    inS.endEncapsulation();
                }
                catch (Exception)
                {
                    test(false);
                }
            }

            // begin_ice_invoke with Callback
            Callback cb = new Callback(communicator, false);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, null);
            cb.check();

            // begin_ice_invoke with Callback with cookie
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null, cb.opException, new Cookie());
            cb.check();

            // begin_ice_invoke with Callback_Object_ice_invoke
            cb = new Callback(communicator, true);
            cl.begin_ice_invoke("opException", Ice.OperationMode.Normal, null).whenCompleted(cb.opExceptionNC, null);
            cb.check();
        }

        WriteLine("ok");
        return(cl);
    }
Ejemplo n.º 54
0
    public override bool ice_invoke(byte[] inParams, out byte[] outParams, Ice.Current current)
    {
        outParams = null;

        var communicator = current.adapter.getCommunicator();

        Ice.InputStream inStream = null;
        if(inParams.Length > 0)
        {
            inStream = new Ice.InputStream(communicator, inParams);
            inStream.startEncapsulation();
        }

        if(current.operation.Equals("printString"))
        {
            var message = inStream.readString();
            inStream.endEncapsulation();
            Console.WriteLine("Printing string `" + message + "'");
            return true;
        }
        else if(current.operation.Equals("printStringSequence"))
        {
            var seq = StringSeqHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing string sequence {");
            for(int i = 0; i < seq.Length; ++i)
            {
                if(i > 0)
                {
                    Console.Write(", ");
                }
                Console.Write("'" + seq[i] + "'");
            }
            Console.WriteLine("}");
            return true;
        }
        else if(current.operation.Equals("printDictionary"))
        {
            var dict = StringDictHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing dictionary {");
            bool first = true;
            foreach(var e in dict)
            {
                if(!first)
                {
                    Console.Write(", ");
                }
                first = false;
                Console.Write(e.Key + "=" + e.Value);
            }
            Console.WriteLine("}");
            return true;
        }
        else if(current.operation.Equals("printEnum"))
        {
            var c = ColorHelper.read(inStream);
            inStream.endEncapsulation();
            Console.WriteLine("Printing enum " + c);
            return true;
        }
        else if(current.operation.Equals("printStruct"))
        {
            var s = Structure.read(inStream);
            inStream.endEncapsulation();
            Console.WriteLine("Printing struct: name=" + s.name + ", value=" + s.value);
            return true;
        }
        else if(current.operation.Equals("printStructSequence"))
        {
            var seq = StructureSeqHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing struct sequence: {");
            for(int i = 0; i < seq.Length; ++i)
            {
                if(i > 0)
                {
                    Console.Write(", ");
                }
                Console.Write(seq[i].name + "=" + seq[i].value);
            }
            Console.WriteLine("}");
            return true;
        }
        else if(current.operation.Equals("printClass"))
        {
            var cb = new ReadValueCallback();
            inStream.readValue(cb.invoke);
            inStream.readPendingValues();
            inStream.endEncapsulation();
            var c = cb.obj as C;
            Console.WriteLine("Printing class: s.name=" + c.s.name + ", s.value=" + c.s.value);
            return true;
        }
        else if(current.operation.Equals("getValues"))
        {
            var c = new C(new Structure("green", Color.green));
            var outStream = new Ice.OutputStream(communicator);
            outStream.startEncapsulation();
            outStream.writeValue(c);
            outStream.writeString("hello");
            outStream.writePendingValues();
            outStream.endEncapsulation();
            outParams = outStream.finished();
            return true;
        }
        else if(current.operation.Equals("throwPrintFailure"))
        {
            Console.WriteLine("Throwing PrintFailure");
            var ex = new PrintFailure("paper tray empty");
            var outStream = new Ice.OutputStream(communicator);
            outStream.startEncapsulation();
            outStream.writeException(ex);
            outStream.endEncapsulation();
            outParams = outStream.finished();
            return false;
        }
        else if(current.operation.Equals("shutdown"))
        {
            current.adapter.getCommunicator().shutdown();
            return true;
        }
        else
        {
            throw new Ice.OperationNotExistException(current.id, current.facet, current.operation);
        }
    }
Ejemplo n.º 55
0
 public void opStringNC(bool ok, byte[] outEncaps)
 {
     if(ok)
     {
         Ice.InputStream inS = new Ice.InputStream(_communicator, outEncaps);
         inS.startEncapsulation();
         string s = inS.readString();
         test(s.Equals(testString));
         s = inS.readString();
         test(s.Equals(testString));
         inS.endEncapsulation();
         callback.called();
     }
     else
     {
         test(false);
     }
 }
Ejemplo n.º 56
0
    public override bool ice_invoke(byte[] inParams, out byte[] outParams, Ice.Current current)
    {
        outParams = null;

        var communicator = current.adapter.getCommunicator();

        Ice.InputStream inStream = null;
        if (inParams.Length > 0)
        {
            inStream = new Ice.InputStream(communicator, inParams);
            inStream.startEncapsulation();
        }

        if (current.operation.Equals("printString"))
        {
            var message = inStream.readString();
            inStream.endEncapsulation();
            Console.WriteLine("Printing string `" + message + "'");
            return(true);
        }
        else if (current.operation.Equals("printStringSequence"))
        {
            var seq = StringSeqHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing string sequence {");
            for (int i = 0; i < seq.Length; ++i)
            {
                if (i > 0)
                {
                    Console.Write(", ");
                }
                Console.Write("'" + seq[i] + "'");
            }
            Console.WriteLine("}");
            return(true);
        }
        else if (current.operation.Equals("printDictionary"))
        {
            var dict = StringDictHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing dictionary {");
            bool first = true;
            foreach (var e in dict)
            {
                if (!first)
                {
                    Console.Write(", ");
                }
                first = false;
                Console.Write(e.Key + "=" + e.Value);
            }
            Console.WriteLine("}");
            return(true);
        }
        else if (current.operation.Equals("printEnum"))
        {
            var c = ColorHelper.read(inStream);
            inStream.endEncapsulation();
            Console.WriteLine("Printing enum " + c);
            return(true);
        }
        else if (current.operation.Equals("printStruct"))
        {
            var s = Structure.read(inStream);
            inStream.endEncapsulation();
            Console.WriteLine("Printing struct: name=" + s.name + ", value=" + s.value);
            return(true);
        }
        else if (current.operation.Equals("printStructSequence"))
        {
            var seq = StructureSeqHelper.read(inStream);
            inStream.endEncapsulation();
            Console.Write("Printing struct sequence: {");
            for (int i = 0; i < seq.Length; ++i)
            {
                if (i > 0)
                {
                    Console.Write(", ");
                }
                Console.Write(seq[i].name + "=" + seq[i].value);
            }
            Console.WriteLine("}");
            return(true);
        }
        else if (current.operation.Equals("printClass"))
        {
            var cb = new ReadValueCallback();
            inStream.readValue(cb.invoke);
            inStream.readPendingValues();
            inStream.endEncapsulation();
            var c = cb.obj as C;
            Console.WriteLine("Printing class: s.name=" + c.s.name + ", s.value=" + c.s.value);
            return(true);
        }
        else if (current.operation.Equals("getValues"))
        {
            var c         = new C(new Structure("green", Color.green));
            var outStream = new Ice.OutputStream(communicator);
            outStream.startEncapsulation();
            outStream.writeValue(c);
            outStream.writeString("hello");
            outStream.writePendingValues();
            outStream.endEncapsulation();
            outParams = outStream.finished();
            return(true);
        }
        else if (current.operation.Equals("throwPrintFailure"))
        {
            Console.WriteLine("Throwing PrintFailure");
            var ex        = new PrintFailure("paper tray empty");
            var outStream = new Ice.OutputStream(communicator);
            outStream.startEncapsulation();
            outStream.writeException(ex);
            outStream.endEncapsulation();
            outParams = outStream.finished();
            return(false);
        }
        else if (current.operation.Equals("shutdown"))
        {
            current.adapter.getCommunicator().shutdown();
            return(true);
        }
        else
        {
            throw new Ice.OperationNotExistException(current.id, current.facet, current.operation);
        }
    }
Ejemplo n.º 57
0
 protected virtual void readImpl__(InputStream is__)
 {
     throw new MarshalException("class was not generated with stream support");
 }
Ejemplo n.º 58
0
 public virtual void read__(InputStream is__)
 {
     is__.startObject();
     readImpl__(is__);
     is__.endObject(false);
 }