Esempio n. 1
0
 override protected EndpointI readWithUnderlying(EndpointI underlying, Ice.InputStream s)
 {
     return(new WSEndpoint(instance_, underlying, s));
 }
Esempio n. 2
0
        private static void printReply(System.IO.StringWriter s, Ice.InputStream str)
        {
            int requestId = str.readInt();

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

            byte replyStatus = str.readByte();

            s.Write("\nreply status = " + (int)replyStatus + ' ');

            switch (replyStatus)
            {
            case ReplyStatus.replyOK:
            {
                s.Write("(ok)");
                break;
            }

            case ReplyStatus.replyUserException:
            {
                s.Write("(user exception)");
                break;
            }

            case ReplyStatus.replyObjectNotExist:
            case ReplyStatus.replyFacetNotExist:
            case ReplyStatus.replyOperationNotExist:
            {
                switch (replyStatus)
                {
                case ReplyStatus.replyObjectNotExist:
                {
                    s.Write("(object not exist)");
                    break;
                }

                case ReplyStatus.replyFacetNotExist:
                {
                    s.Write("(facet not exist)");
                    break;
                }

                case ReplyStatus.replyOperationNotExist:
                {
                    s.Write("(operation not exist)");
                    break;
                }

                default:
                {
                    Debug.Assert(false);
                    break;
                }
                }

                printIdentityFacetOperation(s, str);
                break;
            }

            case ReplyStatus.replyUnknownException:
            case ReplyStatus.replyUnknownLocalException:
            case ReplyStatus.replyUnknownUserException:
            {
                switch (replyStatus)
                {
                case ReplyStatus.replyUnknownException:
                {
                    s.Write("(unknown exception)");
                    break;
                }

                case ReplyStatus.replyUnknownLocalException:
                {
                    s.Write("(unknown local exception)");
                    break;
                }

                case ReplyStatus.replyUnknownUserException:
                {
                    s.Write("(unknown user exception)");
                    break;
                }

                default:
                {
                    Debug.Assert(false);
                    break;
                }
                }

                string unknown = str.readString();
                s.Write("\nunknown = " + unknown);
                break;
            }

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

            if (replyStatus == ReplyStatus.replyOK || replyStatus == ReplyStatus.replyUserException)
            {
                Ice.EncodingVersion v = str.skipEncapsulation();
                if (!v.Equals(Ice.Util.Encoding_1_0))
                {
                    s.Write("\nencoding = ");
                    s.Write(Ice.Util.encodingVersionToString(v));
                }
            }
        }
Esempio n. 3
0
 public TcpEndpointI(ProtocolInstance instance, Ice.InputStream s) :
     base(instance, s)
 {
     _timeout  = s.readInt();
     _compress = s.readBool();
 }
Esempio n. 4
0
        public EndpointI create(string str, bool oaEndpoint)
        {
            string[] arr = IceUtilInternal.StringUtil.splitString(str, " \t\r\n");
            if (arr == null)
            {
                Ice.EndpointParseException e = new Ice.EndpointParseException();
                e.str = "mismatched quote";
                throw e;
            }

            if (arr.Length == 0)
            {
                Ice.EndpointParseException e = new Ice.EndpointParseException();
                e.str = "value has no non-whitespace characters";
                throw e;
            }

            List <string> v        = new List <string>(arr);
            string        protocol = v[0];

            v.RemoveAt(0);

            if (protocol.Equals("default"))
            {
                protocol = instance_.defaultsAndOverrides().defaultProtocol;
            }

            EndpointFactory factory = null;

            lock (this)
            {
                for (int i = 0; i < _factories.Count; i++)
                {
                    EndpointFactory f = _factories[i];
                    if (f.protocol().Equals(protocol))
                    {
                        factory = f;
                    }
                }
            }

            if (factory != null)
            {
                EndpointI e = factory.create(v, oaEndpoint);
                if (v.Count > 0)
                {
                    Ice.EndpointParseException ex = new Ice.EndpointParseException();
                    ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'";
                    throw ex;
                }
                return(e);

                // Code below left in place for debugging.

                /*
                 * EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint);
                 * BasicStream bs = new BasicStream(instance_, true);
                 * e.streamWrite(bs);
                 * Buffer buf = bs.getBuffer();
                 * buf.b.position(0);
                 * short type = bs.readShort();
                 * EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs);
                 * System.Console.Error.WriteLine("Normal: " + e);
                 * System.Console.Error.WriteLine("Opaque: " + ue);
                 * return e;
                 */
            }

            //
            // If the stringified endpoint is opaque, create an unknown endpoint,
            // then see whether the type matches one of the known endpoints.
            //
            if (protocol.Equals("opaque"))
            {
                EndpointI ue = new OpaqueEndpointI(v);
                if (v.Count > 0)
                {
                    Ice.EndpointParseException ex = new Ice.EndpointParseException();
                    ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'";
                    throw ex;
                }
                factory = get(ue.type());
                if (factory != null)
                {
                    //
                    // Make a temporary stream, write the opaque endpoint data into the stream,
                    // and ask the factory to read the endpoint data from that stream to create
                    // the actual endpoint.
                    //
                    Ice.OutputStream os = new Ice.OutputStream(instance_, Ice.Util.currentProtocolEncoding);
                    os.writeShort(ue.type());
                    ue.streamWrite(os);
                    Ice.InputStream iss =
                        new Ice.InputStream(instance_, Ice.Util.currentProtocolEncoding, os.getBuffer(), true);
                    iss.pos(0);
                    iss.readShort(); // type
                    iss.startEncapsulation();
                    EndpointI e = factory.read(iss);
                    iss.endEncapsulation();
                    return(e);
                }
                return(ue); // Endpoint is opaque, but we don't have a factory for its type.
            }

            return(null);
        }
Esempio n. 5
0
 public virtual void read__(Ice.InputStream inS__)
 {
     inS__.startObject();
     readImpl__(inS__);
     inS__.endObject(false);
 }
Esempio n. 6
0
        public Reference create(Ice.Identity ident, Ice.InputStream s)
        {
            //
            // Don't read the identity here. Operations calling this
            // constructor read the identity, and pass it as a parameter.
            //

            if (ident.name.Length == 0 && ident.category.Length == 0)
            {
                return(null);
            }

            //
            // For compatibility with the old FacetPath.
            //
            string[] facetPath = s.readStringSeq();
            string   facet;

            if (facetPath.Length > 0)
            {
                if (facetPath.Length > 1)
                {
                    throw new Ice.ProxyUnmarshalException();
                }
                facet = facetPath[0];
            }
            else
            {
                facet = "";
            }

            int mode = s.readByte();

            if (mode < 0 || mode > (int)Reference.Mode.ModeLast)
            {
                throw new Ice.ProxyUnmarshalException();
            }

            bool secure = s.readBool();

            Ice.ProtocolVersion protocol;
            Ice.EncodingVersion encoding;
            if (!s.getEncoding().Equals(Ice.Util.Encoding_1_0))
            {
                protocol = new Ice.ProtocolVersion();
                protocol.ice_readMembers(s);
                encoding = new Ice.EncodingVersion();
                encoding.ice_readMembers(s);
            }
            else
            {
                protocol = Ice.Util.Protocol_1_0;
                encoding = Ice.Util.Encoding_1_0;
            }

            EndpointI[] endpoints = null;
            string      adapterId = "";

            int sz = s.readSize();

            if (sz > 0)
            {
                endpoints = new EndpointI[sz];
                for (int i = 0; i < sz; i++)
                {
                    endpoints[i] = _instance.endpointFactoryManager().read(s);
                }
            }
            else
            {
                adapterId = s.readString();
            }

            return(create(ident, facet, (Reference.Mode)mode, secure, protocol, encoding, endpoints, adapterId, null));
        }
Esempio n. 7
0
 readWithUnderlying(IceInternal.EndpointI underlying, Ice.InputStream s)
 {
     return(new EndpointI(_instance, underlying));
 }
Esempio n. 8
0
        internal static void traceSend(Ice.OutputStream str, Ice.Logger logger, TraceLevels tl)
        {
            if(tl.protocol >= 1)
            {
                int p = str.pos();
                Ice.InputStream iss = new Ice.InputStream(str.instance(), str.getEncoding(), str.getBuffer(), false);
                iss.pos(0);

                using(System.IO.StringWriter s = new System.IO.StringWriter(CultureInfo.CurrentCulture))
                {
                    byte type = printMessage(s, iss);

                    logger.trace(tl.protocolCat, "sending " + getMessageTypeAsString(type) + " " + s.ToString());
                }
                str.pos(p);
            }
        }
Esempio n. 9
0
            static public int allTests(global::Test.TestHelper helper)
            {
                var communicator = helper.communicator();
                MyClassFactoryWrapper factoryWrapper = new MyClassFactoryWrapper();

                communicator.getValueFactoryManager().add(factoryWrapper.create, Test.MyClass.ice_staticId());
                communicator.getValueFactoryManager().add((id) =>
                {
                    return(new Ice.InterfaceByValue("::Test::MyInterface"));
                },
                                                          "::Test::MyInterface");

                Ice.InputStream  inS;
                Ice.OutputStream outS;

                var output = helper.getWriter();

                output.Write("testing primitive types... ");
                output.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"));
                }

                output.WriteLine("ok");

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

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

                {
                    outS = new Ice.OutputStream(communicator);
                    var s = new Test.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   = Test.MyEnum.enum2;
                    s.p   = Test.MyInterfacePrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
                    Test.SmallStruct.ice_write(outS, s);
                    var data = outS.finished();
                    var s2   = Test.SmallStruct.ice_read(new Ice.InputStream(communicator, data));
                    test(s2.Equals(s));
                }

                {
                    outS = new Ice.OutputStream(communicator);
                    var o = new Test.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 = (Test.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 Test.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 = (Test.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);
                    Test.BoolSSHelper.write(outS, arrS);
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.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);
                    Test.ByteSSHelper.write(outS, arrS);
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.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);
                    Test.ShortSSHelper.write(outS, arrS);
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.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);
                    Test.IntSSHelper.write(outS, arrS);
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.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);
                    Test.LongSSHelper.write(outS, arrS);
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.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);
                    Test.FloatSSHelper.write(outS, arrS);
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.FloatSSHelper.read(inS);
                    test(Compare(arr2S, arrS));
                }

                {
                    double[] arr =
                    {
                        1,
                        2,
                        3,
                        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);
                    Test.DoubleSSHelper.write(outS, arrS);
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.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);
                    Test.StringSSHelper.write(outS, arrS);
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.StringSSHelper.read(inS);
                    test(Compare(arr2S, arrS));
                }

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

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

                var 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  = 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   = Test.MyEnum.enum2;
                    smallStructArray[i].p   = Test.MyInterfacePrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
                }

                var 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[] { 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 Test.MyEnum[] { Test.MyEnum.enum3, Test.MyEnum.enum2, Test.MyEnum.enum1 };
                    myClassArray[i].seq10   = new Test.MyClass[4]; // null elements.
                    myClassArray[i].d       = new Dictionary <string, Test.MyClass>();
                    myClassArray[i].d["hi"] = myClassArray[i];
                }

                var myInterfaceArray = new Ice.Value[4];

                for (int i = 0; i < myInterfaceArray.Length; ++i)
                {
                    myInterfaceArray[i] = new Ice.InterfaceByValue("::Test::MyInterface");
                }

                {
                    outS = new Ice.OutputStream(communicator);
                    Test.MyClassSHelper.write(outS, myClassArray);
                    outS.writePendingValues();
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var arr2 = Test.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 == 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 };
                    outS = new Ice.OutputStream(communicator);
                    Test.MyClassSSHelper.write(outS, arrS);
                    outS.writePendingValues();
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.MyClassSSHelper.read(inS);
                    inS.readPendingValues();
                    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);

                    for (int j = 0; j < arr2S.Length; ++j)
                    {
                        for (int k = 0; k < arr2S[j].Length; ++k)
                        {
                            test(arr2S[j][k].c == arr2S[j][k]);
                            test(arr2S[j][k].o == arr2S[j][k]);
                            test(arr2S[j][k].s.e == Test.MyEnum.enum2);
                            test(Compare(arr2S[j][k].seq1, myClassArray[k].seq1));
                            test(Compare(arr2S[j][k].seq2, myClassArray[k].seq2));
                            test(Compare(arr2S[j][k].seq3, myClassArray[k].seq3));
                            test(Compare(arr2S[j][k].seq4, myClassArray[k].seq4));
                            test(Compare(arr2S[j][k].seq5, myClassArray[k].seq5));
                            test(Compare(arr2S[j][k].seq6, myClassArray[k].seq6));
                            test(Compare(arr2S[j][k].seq7, myClassArray[k].seq7));
                            test(Compare(arr2S[j][k].seq8, myClassArray[k].seq8));
                            test(Compare(arr2S[j][k].seq9, myClassArray[k].seq9));
                            test(arr2S[j][k].d["hi"].Equals(arr2S[j][k]));
                        }
                    }
                }

                {
                    outS = new Ice.OutputStream(communicator);
                    Test.MyInterfaceSHelper.write(outS, myInterfaceArray);
                    outS.writePendingValues();
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var arr2 = Test.MyInterfaceSHelper.read(inS);
                    inS.readPendingValues();
                    test(arr2.Length == myInterfaceArray.Length);
                    Ice.Value[][] arrS = { myInterfaceArray, new Ice.Value[0], myInterfaceArray };
                    outS = new Ice.OutputStream(communicator);
                    Test.MyInterfaceSSHelper.write(outS, arrS);
                    outS.writePendingValues();
                    data = outS.finished();
                    inS  = new Ice.InputStream(communicator, data);
                    var arr2S = Test.MyInterfaceSSHelper.read(inS);
                    inS.readPendingValues();
                    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 Test.MyClass();
                    obj.s   = new Test.SmallStruct();
                    obj.s.e = Test.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 == Test.MyEnum.enum2);
                    factoryWrapper.setFactory(null);
                }

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

                    var 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[] { 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 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;

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

                    inS = new Ice.InputStream(communicator, data);
                    try
                    {
                        inS.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);
                    }
                }

                {
                    var dict = new Dictionary <byte, bool>();
                    dict.Add(4, true);
                    dict.Add(1, false);
                    outS = new Ice.OutputStream(communicator);
                    Test.ByteBoolDHelper.write(outS, dict);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var dict2 = Test.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);
                    Test.ShortIntDHelper.write(outS, dict);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var dict2 = Test.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);
                    Test.LongFloatDHelper.write(outS, dict);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var dict2 = Test.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);
                    Test.StringStringDHelper.write(outS, dict);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var dict2 = Test.StringStringDHelper.read(inS);
                    test(Ice.CollectionComparer.Equals(dict2, dict));
                }

                {
                    var dict = new Dictionary <string, Test.MyClass>();
                    var 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);
                    outS = new Ice.OutputStream(communicator);
                    Test.StringMyClassDHelper.write(outS, dict);
                    outS.writePendingValues();
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var dict2 = Test.StringMyClassDHelper.read(inS);
                    inS.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 };
                    outS = new Ice.OutputStream(communicator);
                    var l = new List <bool>(arr);
                    Test.BoolListHelper.write(outS, l);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.BoolListHelper.read(inS);
                    test(Compare(l, l2));
                }

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

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

                {
                    outS = new Ice.OutputStream(communicator);
                    var l = new List <Test.SmallStruct>(smallStructArray);
                    Test.SmallStructListHelper.write(outS, l);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.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 <Test.MyClass>(myClassArray);
                    Test.MyClassListHelper.write(outS, l);
                    outS.writePendingValues();
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.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 == 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]));
                    }
                }

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

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

                {
                    short[] arr = { 0x01, 0x11, 0x12, 0x22 };
                    outS = new Ice.OutputStream(communicator);
                    var l = new LinkedList <short>(arr);
                    Test.ShortLinkedListHelper.write(outS, l);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.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));
                }

                {
                    Test.MyEnum[] arr = { Test.MyEnum.enum3, Test.MyEnum.enum2, Test.MyEnum.enum1, Test.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);
                    Test.SmallStructLinkedListHelper.write(outS, l);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.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);
                    Test.LongStackHelper.write(outS, l);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.LongStackHelper.read(inS);
                    test(Compare(l2, l));
                }

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

                {
                    outS = new Ice.OutputStream(communicator);
                    var l = new Stack <Test.SmallStruct>(smallStructArray);
                    Test.SmallStructStackHelper.write(outS, l);
                    byte[] data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.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 Ice.ObjectPrx[2];
                    arr[0] = communicator.stringToProxy("zero");
                    arr[1] = communicator.stringToProxy("one");
                    outS   = new Ice.OutputStream(communicator);
                    var l = new Stack <Ice.ObjectPrx>(arr);
                    Test.MyClassProxyStackHelper.write(outS, l);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.MyClassProxyStackHelper.read(inS);
                    test(Compare(l2, l));
                }

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

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

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

                {
                    outS = new Ice.OutputStream(communicator);
                    var l = new Queue <Test.SmallStruct>(smallStructArray);
                    Test.SmallStructQueueHelper.write(outS, l);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.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);
                    Test.StringSListHelper.write(outS, l);
                    byte[] data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.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);
                    Test.StringSStackHelper.write(outS, l);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var l2 = Test.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);
                    Test.SortedStringStringDHelper.write(outS, dict);
                    var data = outS.finished();
                    inS = new Ice.InputStream(communicator, data);
                    var dict2 = Test.SortedStringStringDHelper.read(inS);
                    test(Ice.CollectionComparer.Equals(dict2, dict));
                }

                output.WriteLine("ok");
                return(0);
            }
Esempio n. 10
0
 public override void read(Ice.InputStream inS)
 {
     obj = new Test.MyClass();
     obj.iceRead(inS);
     called = true;
 }
Esempio n. 11
0
 public InputStreamWrapper(int size, Ice.InputStream s)
 {
     s_      = s;
     pos_    = 0;
     length_ = size;
 }
Esempio n. 12
0
        private static byte 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);

                byte type = 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);
            }
        }
Esempio n. 13
0
 public static string[] read(Ice.InputStream istr)
 {
     string[] v;
     v = istr.readStringSeq();
     return(v);
 }
Esempio n. 14
0
 public override void read__(Ice.InputStream istr)
 {
     read(istr);
 }
Esempio n. 15
0
 internal UdpEndpoint(TransportInstance instance, Ice.InputStream s)
     : base(instance, s)
 {
     _connect           = false;
     HasCompressionFlag = s.ReadBool();
 }
Esempio n. 16
0
        private void invokeAll(Ice.OutputStream os, int requestId, int batchRequestNum)
        {
            if(_traceLevels.protocol >= 1)
            {
                fillInValue(os, 10, os.size());
                if(requestId > 0)
                {
                    fillInValue(os, Protocol.headerSize, requestId);
                }
                else if(batchRequestNum > 0)
                {
                    fillInValue(os, Protocol.headerSize, batchRequestNum);
                }
                TraceUtil.traceSend(os, _logger, _traceLevels);
            }

            Ice.InputStream iss = new Ice.InputStream(os.instance(), os.getEncoding(), os.getBuffer(), false);

            if(batchRequestNum > 0)
            {
                iss.pos(Protocol.requestBatchHdr.Length);
            }
            else
            {
                iss.pos(Protocol.requestHdr.Length);
            }

            int invokeNum = batchRequestNum > 0 ? batchRequestNum : 1;
            ServantManager servantManager = _adapter.getServantManager();
            try
            {
                while(invokeNum > 0)
                {
                    //
                    // Increase the direct count for the dispatch. We increase it again here for
                    // each dispatch. It's important for the direct count to be > 0 until the last
                    // collocated request response is sent to make sure the thread pool isn't
                    // destroyed before.
                    //
                    try
                    {
                        _adapter.incDirectCount();
                    }
                    catch(Ice.ObjectAdapterDeactivatedException ex)
                    {
                        handleException(requestId, ex, false);
                        break;
                    }

                    Incoming @in = new Incoming(_reference.getInstance(), this, null, _adapter, _response, (byte)0,
                                               requestId);
                    @in.invoke(servantManager, iss);
                    --invokeNum;
                }
            }
            catch(Ice.LocalException ex)
            {
                invokeException(requestId, ex, invokeNum, false); // Fatal invocation exception
            }

            _adapter.decDirectCount();
        }
Esempio n. 17
0
 public Endpoint Read(Ice.InputStream s) => new UdpEndpoint(_instance, s);
Esempio n. 18
0
 public InputStreamWrapper(int size, Ice.InputStream s)
 {
     s_ = s;
     pos_ = 0;
     length_ = size;
 }
Esempio n. 19
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();
         }
         var 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;
     }
 }
Esempio n. 20
0
 public BaseServiceHelper(Ice.InputStream inS__)
 {
     _in = inS__;
     _pp = new IceInternal.ParamPatcher <minie.irpc.BaseService>("::minie::irpc::BaseService");
 }
Esempio n. 21
0
        public void invoke(ServantManager servantManager, Ice.InputStream stream)
        {
            _is = stream;

            int start = _is.pos();

            //
            // Read the current.
            //
            current_.id.read__(_is);

            //
            // For compatibility with the old FacetPath.
            //
            string[] facetPath = _is.readStringSeq();
            if (facetPath.Length > 0)
            {
                if (facetPath.Length > 1)
                {
                    throw new Ice.MarshalException();
                }
                current_.facet = facetPath[0];
            }
            else
            {
                current_.facet = "";
            }

            current_.operation = _is.readString();
            current_.mode      = (Ice.OperationMode)(int) _is.readByte();
            current_.ctx       = new Dictionary <string, string>();
            int sz = _is.readSize();

            while (sz-- > 0)
            {
                string first  = _is.readString();
                string second = _is.readString();
                current_.ctx[first] = second;
            }

            Ice.Instrumentation.CommunicatorObserver obsv = instance_.initializationData().observer;
            if (obsv != null)
            {
                // Read the encapsulation size.
                int size = _is.readInt();
                _is.pos(_is.pos() - 4);

                observer_ = obsv.getDispatchObserver(current_, _is.pos() - start + size);
                if (observer_ != null)
                {
                    observer_.attach();
                }
            }

            //
            // Don't put the code above into the try block below. Exceptions
            // in the code above are considered fatal, and must propagate to
            // the caller of this operation.
            //

            if (servantManager != null)
            {
                servant_ = servantManager.findServant(current_.id, current_.facet);
                if (servant_ == null)
                {
                    locator_ = servantManager.findServantLocator(current_.id.category);
                    if (locator_ == null && current_.id.category.Length > 0)
                    {
                        locator_ = servantManager.findServantLocator("");
                    }

                    if (locator_ != null)
                    {
                        try
                        {
                            servant_ = locator_.locate(current_, out cookie_);
                        }
                        catch (Ice.UserException ex)
                        {
                            Ice.EncodingVersion encoding = _is.skipEncapsulation(); // Required for batch requests.

                            if (observer_ != null)
                            {
                                observer_.userException();
                            }

                            if (response_)
                            {
                                os_.writeByte(ReplyStatus.replyUserException);
                                os_.startEncapsulation(encoding, Ice.FormatType.DefaultFormat);
                                os_.writeException(ex);
                                os_.endEncapsulation();
                                if (observer_ != null)
                                {
                                    observer_.reply(os_.size() - Protocol.headerSize - 4);
                                }
                                responseHandler_.sendResponse(current_.requestId, os_, compress_, false);
                            }
                            else
                            {
                                responseHandler_.sendNoResponse();
                            }

                            if (observer_ != null)
                            {
                                observer_.detach();
                                observer_ = null;
                            }
                            responseHandler_ = null;
                            return;
                        }
                        catch (System.Exception ex)
                        {
                            _is.skipEncapsulation(); // Required for batch requests.
                            handleException__(ex, false);
                            return;
                        }
                    }
                }
            }

            try
            {
                if (servant_ != null)
                {
                    //
                    // DispatchAsync is a "pseudo dispatch status", used internally only
                    // to indicate async dispatch.
                    //
                    if (servant_.dispatch__(this, current_) == Ice.DispatchStatus.DispatchAsync)
                    {
                        //
                        // If this was an asynchronous dispatch, we're done here.
                        //
                        return;
                    }

                    if (locator_ != null && !servantLocatorFinished__(false))
                    {
                        return;
                    }
                }
                else
                {
                    //
                    // Skip the input parameters, this is required for reading
                    // the next batch request if dispatching batch requests.
                    //
                    _is.skipEncapsulation();

                    if (servantManager != null && servantManager.hasServant(current_.id))
                    {
                        throw new Ice.FacetNotExistException(current_.id, current_.facet, current_.operation);
                    }
                    else
                    {
                        throw new Ice.ObjectNotExistException(current_.id, current_.facet, current_.operation);
                    }
                }
            }
            catch (System.Exception ex)
            {
                if (servant_ != null && locator_ != null && !servantLocatorFinished__(false))
                {
                    return;
                }
                handleException__(ex, false);
                return;
            }

            //
            // Don't put the code below into the try block above. Exceptions
            // in the code below are considered fatal, and must propagate to
            // the caller of this operation.
            //

            Debug.Assert(responseHandler_ != null);

            if (response_)
            {
                if (observer_ != null)
                {
                    observer_.reply(os_.size() - Protocol.headerSize - 4);
                }
                responseHandler_.sendResponse(current_.requestId, os_, compress_, false);
            }
            else
            {
                responseHandler_.sendNoResponse();
            }

            if (observer_ != null)
            {
                observer_.detach();
                observer_ = null;
            }
            responseHandler_ = null;
        }
Esempio n. 22
0
 public override void read__(Ice.InputStream istr)
 {
     Debug.Assert(false);
 }
Esempio n. 23
0
 protected override Endpoint ReadWithUnderlying(Endpoint underlying, Ice.InputStream s) =>
 new WSEndpoint(Instance, underlying, s);
Esempio n. 24
0
 public EndpointI read(Ice.InputStream s)
 {
     return(new TcpEndpointI(_instance, s));
 }
Esempio n. 25
0
 protected abstract EndpointI readWithUnderlying(EndpointI underlying, Ice.InputStream s);
Esempio n. 26
0
        public void invoke(ServantManager servantManager, Ice.InputStream stream)
        {
            _is = stream;

            int start = _is.pos();

            //
            // Read the current.
            //
            _current.id.ice_readMembers(_is);

            //
            // For compatibility with the old FacetPath.
            //
            string[] facetPath = _is.readStringSeq();
            if (facetPath.Length > 0)
            {
                if (facetPath.Length > 1)
                {
                    throw new Ice.MarshalException();
                }
                _current.facet = facetPath[0];
            }
            else
            {
                _current.facet = "";
            }

            _current.operation = _is.readString();
            _current.mode      = (Ice.OperationMode)_is.readByte();
            _current.ctx       = new Dictionary <string, string>();
            int sz = _is.readSize();

            while (sz-- > 0)
            {
                string first  = _is.readString();
                string second = _is.readString();
                _current.ctx[first] = second;
            }

            Ice.Instrumentation.CommunicatorObserver obsv = _instance.initializationData().observer;
            if (obsv != null)
            {
                // Read the encapsulation size.
                int size = _is.readInt();
                _is.pos(_is.pos() - 4);

                _observer = obsv.getDispatchObserver(_current, _is.pos() - start + size);
                if (_observer != null)
                {
                    _observer.attach();
                }
            }

            //
            // Don't put the code above into the try block below. Exceptions
            // in the code above are considered fatal, and must propagate to
            // the caller of this operation.
            //

            if (servantManager != null)
            {
                _servant = servantManager.findServant(_current.id, _current.facet);
                if (_servant == null)
                {
                    _locator = servantManager.findServantLocator(_current.id.category);
                    if (_locator == null && _current.id.category.Length > 0)
                    {
                        _locator = servantManager.findServantLocator("");
                    }

                    if (_locator != null)
                    {
                        Debug.Assert(_locator != null);
                        try
                        {
                            _servant = _locator.locate(_current, out _cookie);
                        }
                        catch (Exception ex)
                        {
                            skipReadParams(); // Required for batch requests.
                            handleException(ex, false);
                            return;
                        }
                    }
                }
            }

            if (_servant == null)
            {
                try
                {
                    if (servantManager != null && servantManager.hasServant(_current.id))
                    {
                        throw new Ice.FacetNotExistException(_current.id, _current.facet, _current.operation);
                    }
                    else
                    {
                        throw new Ice.ObjectNotExistException(_current.id, _current.facet, _current.operation);
                    }
                }
                catch (Exception ex)
                {
                    skipReadParams(); // Required for batch requests
                    handleException(ex, false);
                    return;
                }
            }

            try
            {
                Task <Ice.OutputStream> task = _servant.iceDispatch(this, _current);
                if (task == null)
                {
                    completed(null, false);
                }
                else
                {
                    if (task.IsCompleted)
                    {
                        _os = task.GetAwaiter().GetResult(); // Get the response
                        completed(null, false);
                    }
                    else
                    {
                        task.ContinueWith((Task <Ice.OutputStream> t) =>
                        {
                            try
                            {
                                _os = t.GetAwaiter().GetResult();
                                completed(null, true); // true = asynchronous
                            }
                            catch (Exception ex)
                            {
                                completed(ex, true); // true = asynchronous
                            }
                        }, TaskContinuationOptions.ExecuteSynchronously);
                    }
                }
            }
            catch (Exception ex)
            {
                completed(ex, false);
            }
        }
Esempio n. 27
0
 public IceInternal.EndpointI read(Ice.InputStream s)
 {
     return(new EndpointI(_instance, s));
 }
Esempio n. 28
0
 public EndpointI read(Ice.InputStream s)
 {
     return(new WSEndpoint(_instance, _delegate.read(s), s));
 }
Esempio n. 29
0
 public InputStreamWrapper(int size, Ice.InputStream s)
 {
     _s      = s;
     _pos    = 0;
     _length = size;
 }
Esempio n. 30
0
 public abstract void read(Ice.InputStream istr);
Esempio n. 31
0
        private void invokeAll(Ice.OutputStream os, int requestId, int batchRequestNum)
        {
            if (_traceLevels.protocol >= 1)
            {
                fillInValue(os, 10, os.size());
                if (requestId > 0)
                {
                    fillInValue(os, Protocol.headerSize, requestId);
                }
                else if (batchRequestNum > 0)
                {
                    fillInValue(os, Protocol.headerSize, batchRequestNum);
                }
                TraceUtil.traceSend(os, _logger, _traceLevels);
            }

            Ice.InputStream iss = new Ice.InputStream(os.instance(), os.getEncoding(), os.getBuffer(), false);

            if (batchRequestNum > 0)
            {
                iss.pos(Protocol.requestBatchHdr.Length);
            }
            else
            {
                iss.pos(Protocol.requestHdr.Length);
            }

            int            invokeNum      = batchRequestNum > 0 ? batchRequestNum : 1;
            ServantManager servantManager = _adapter.getServantManager();

            try
            {
                while (invokeNum > 0)
                {
                    //
                    // Increase the direct count for the dispatch. We increase it again here for
                    // each dispatch. It's important for the direct count to be > 0 until the last
                    // collocated request response is sent to make sure the thread pool isn't
                    // destroyed before.
                    //
                    try
                    {
                        _adapter.incDirectCount();
                    }
                    catch (Ice.ObjectAdapterDeactivatedException ex)
                    {
                        handleException(requestId, ex, false);
                        break;
                    }

                    Incoming inS = new Incoming(_reference.getInstance(), this, null, _adapter, _response, (byte)0,
                                                requestId);
                    inS.invoke(servantManager, iss);
                    --invokeNum;
                }
            }
            catch (Ice.LocalException ex)
            {
                invokeException(requestId, ex, invokeNum, false); // Fatal invocation exception
            }

            _adapter.decDirectCount();
        }
Esempio n. 32
0
        public void sendResponse(int requestId, Ice.OutputStream os, byte status, bool amd)
        {
            Ice.AsyncCallback cb = null;
            OutgoingAsyncBase outAsync;
            lock(this)
            {
                Debug.Assert(_response);

                if(_traceLevels.protocol >= 1)
                {
                    fillInValue(os, 10, os.size());
                }

                // Adopt the OutputStream's buffer.
                Ice.InputStream iss = new Ice.InputStream(os.instance(), os.getEncoding(), os.getBuffer(), true);

                iss.pos(Protocol.replyHdr.Length + 4);

                if(_traceLevels.protocol >= 1)
                {
                    TraceUtil.traceRecv(iss, _logger, _traceLevels);
                }

                if(_asyncRequests.TryGetValue(requestId, out outAsync))
                {
                    _asyncRequests.Remove(requestId);
                    outAsync.getIs().swap(iss);
                    cb = outAsync.completed();
                }
            }

            if(cb != null)
            {
                if(amd)
                {
                    outAsync.invokeCompletedAsync(cb);
                }
                else
                {
                    outAsync.invokeCompleted(cb);
                }
            }
            _adapter.decDirectCount();
        }
Esempio n. 33
0
 protected override void readImpl__(Ice.InputStream inS__)
 {
     inS__.startSlice();
     inS__.endSlice();
     base.readImpl__(inS__);
 }
Esempio n. 34
0
        public void invoke(ServantManager servantManager, Ice.InputStream stream)
        {
            _is = stream;

            int start = _is.pos();

            //
            // Read the current.
            //
            current_.id.read__(_is);

            //
            // For compatibility with the old FacetPath.
            //
            string[] facetPath = _is.readStringSeq();
            if(facetPath.Length > 0)
            {
                if(facetPath.Length > 1)
                {
                    throw new Ice.MarshalException();
                }
                current_.facet = facetPath[0];
            }
            else
            {
                current_.facet = "";
            }

            current_.operation = _is.readString();
            current_.mode = (Ice.OperationMode)(int)_is.readByte();
            current_.ctx = new Dictionary<string, string>();
            int sz = _is.readSize();
            while(sz-- > 0)
            {
                string first = _is.readString();
                string second = _is.readString();
                current_.ctx[first] = second;
            }

            Ice.Instrumentation.CommunicatorObserver obsv = instance_.initializationData().observer;
            if(obsv != null)
            {
                // Read the encapsulation size.
                int size = _is.readInt();
                _is.pos(_is.pos() - 4);

                observer_ = obsv.getDispatchObserver(current_, _is.pos() - start + size);
                if(observer_ != null)
                {
                    observer_.attach();
                }
            }

            //
            // Don't put the code above into the try block below. Exceptions
            // in the code above are considered fatal, and must propagate to
            // the caller of this operation.
            //

            if(servantManager != null)
            {
                servant_ = servantManager.findServant(current_.id, current_.facet);
                if(servant_ == null)
                {
                    locator_ = servantManager.findServantLocator(current_.id.category);
                    if(locator_ == null && current_.id.category.Length > 0)
                    {
                        locator_ = servantManager.findServantLocator("");
                    }

                    if(locator_ != null)
                    {
                        try
                        {
                            servant_ = locator_.locate(current_, out cookie_);
                        }
                        catch(Ice.UserException ex)
                        {
                            Ice.EncodingVersion encoding = _is.skipEncapsulation(); // Required for batch requests.

                            if(observer_ != null)
                            {
                                observer_.userException();
                            }

                            if(response_)
                            {
                                os_.writeByte(ReplyStatus.replyUserException);
                                os_.startEncapsulation(encoding, Ice.FormatType.DefaultFormat);
                                os_.writeException(ex);
                                os_.endEncapsulation();
                                if(observer_ != null)
                                {
                                    observer_.reply(os_.size() - Protocol.headerSize - 4);
                                }
                                responseHandler_.sendResponse(current_.requestId, os_, compress_, false);
                            }
                            else
                            {
                                responseHandler_.sendNoResponse();
                            }

                            if(observer_ != null)
                            {
                                observer_.detach();
                                observer_ = null;
                            }
                            responseHandler_ = null;
                            return;
                        }
                        catch(System.Exception ex)
                        {
                            _is.skipEncapsulation(); // Required for batch requests.
                            handleException__(ex, false);
                            return;
                        }
                    }
                }
            }

            try
            {
                if(servant_ != null)
                {
                    //
                    // DispatchAsync is a "pseudo dispatch status", used internally only
                    // to indicate async dispatch.
                    //
                    if(servant_.dispatch__(this, current_) == Ice.DispatchStatus.DispatchAsync)
                    {
                        //
                        // If this was an asynchronous dispatch, we're done here.
                        //
                        return;
                    }

                    if(locator_ != null && !servantLocatorFinished__(false))
                    {
                        return;
                    }
                }
                else
                {
                    //
                    // Skip the input parameters, this is required for reading
                    // the next batch request if dispatching batch requests.
                    //
                    _is.skipEncapsulation();

                    if(servantManager != null && servantManager.hasServant(current_.id))
                    {
                        throw new Ice.FacetNotExistException(current_.id, current_.facet, current_.operation);
                    }
                    else
                    {
                        throw new Ice.ObjectNotExistException(current_.id, current_.facet, current_.operation);
                    }
                }
            }
            catch(System.Exception ex)
            {
                if(servant_ != null && locator_ != null && !servantLocatorFinished__(false))
                {
                    return;
                }
                handleException__(ex, false);
                return;
            }

            //
            // Don't put the code below into the try block above. Exceptions
            // in the code below are considered fatal, and must propagate to
            // the caller of this operation.
            //

            Debug.Assert(responseHandler_ != null);

            if(response_)
            {
                if(observer_ != null)
                {
                    observer_.reply(os_.size() - Protocol.headerSize - 4);
                }
                responseHandler_.sendResponse(current_.requestId, os_, compress_, false);
            }
            else
            {
                responseHandler_.sendNoResponse();
            }

            if(observer_ != null)
            {
                observer_.detach();
                observer_ = null;
            }
            responseHandler_ = null;
        }
Esempio n. 35
0
 public SessionHelper(Ice.InputStream inS__)
 {
     _in = inS__;
     _pp = new IceInternal.ParamPatcher <minie.irpc.Session>("::minie::irpc::Session");
 }
Esempio n. 36
0
        internal static void trace(string heading, Ice.OutputStream str, Ice.Logger logger, TraceLevels tl)
        {
            if(tl.protocol >= 1)
            {
                int p = str.pos();
                Ice.InputStream iss = new Ice.InputStream(str.instance(), str.getEncoding(), str.getBuffer(), false);
                iss.pos(0);

                using(System.IO.StringWriter s = new System.IO.StringWriter(CultureInfo.CurrentCulture))
                {
                    s.Write(heading);
                    printMessage(s, iss);

                    logger.trace(tl.protocolCat, s.ToString());
                }
                str.pos(p);
            }
        }
Esempio n. 37
0
        public EndpointI create(string str, bool oaEndpoint)
        {
            string[] arr = IceUtilInternal.StringUtil.splitString(str, " \t\r\n");
            if(arr == null)
            {
                Ice.EndpointParseException e = new Ice.EndpointParseException();
                e.str = "mismatched quote";
                throw e;
            }

            if(arr.Length == 0)
            {
                Ice.EndpointParseException e = new Ice.EndpointParseException();
                e.str = "value has no non-whitespace characters";
                throw e;
            }

            List<string> v = new List<string>(arr);
            string protocol = v[0];
            v.RemoveAt(0);

            if(protocol.Equals("default"))
            {
                protocol = instance_.defaultsAndOverrides().defaultProtocol;
            }

            EndpointFactory factory = null;

            lock(this)
            {
                for(int i = 0; i < _factories.Count; i++)
                {
                    EndpointFactory f = _factories[i];
                    if(f.protocol().Equals(protocol))
                    {
                        factory = f;
                    }
                }
            }

            if(factory != null)
            {
                EndpointI e = factory.create(v, oaEndpoint);
                if(v.Count > 0)
                {
                    Ice.EndpointParseException ex = new Ice.EndpointParseException();
                    ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'";
                    throw ex;
                }
                return e;

                // Code below left in place for debugging.

                /*
                EndpointI e = f.create(s.Substring(m.Index + m.Length), oaEndpoint);
                BasicStream bs = new BasicStream(instance_, true);
                e.streamWrite(bs);
                Buffer buf = bs.getBuffer();
                buf.b.position(0);
                short type = bs.readShort();
                EndpointI ue = new IceInternal.OpaqueEndpointI(type, bs);
                System.Console.Error.WriteLine("Normal: " + e);
                System.Console.Error.WriteLine("Opaque: " + ue);
                return e;
                */
            }

            //
            // If the stringified endpoint is opaque, create an unknown endpoint,
            // then see whether the type matches one of the known endpoints.
            //
            if(protocol.Equals("opaque"))
            {
                EndpointI ue = new OpaqueEndpointI(v);
                if(v.Count > 0)
                {
                    Ice.EndpointParseException ex = new Ice.EndpointParseException();
                    ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'";
                    throw ex;
                }
                factory = get(ue.type());
                if(factory != null)
                {
                    //
                    // Make a temporary stream, write the opaque endpoint data into the stream,
                    // and ask the factory to read the endpoint data from that stream to create
                    // the actual endpoint.
                    //
                    Ice.OutputStream os = new Ice.OutputStream(instance_, Ice.Util.currentProtocolEncoding);
                    os.writeShort(ue.type());
                    ue.streamWrite(os);
                    Ice.InputStream iss =
                        new Ice.InputStream(instance_, Ice.Util.currentProtocolEncoding, os.getBuffer(), true);
                    iss.pos(0);
                    iss.readShort(); // type
                    iss.startEncapsulation();
                    EndpointI e = factory.read(iss);
                    iss.endEncapsulation();
                    return e;
                }
                return ue; // Endpoint is opaque, but we don't have a factory for its type.
            }

            return null;
        }