Ejemplo n.º 1
0
        public byte[] ServeImage(byte[] Request, int IOffset, int ICount, out int OOffset, out int OCount)
        {
            Ceras.CerasSerializer cser;

            lock (Serializers)
                if (Serializers.Count == 0)
                {
                    Ceras.SerializerConfig Config = new Ceras.SerializerConfig();
                    Config.VersionTolerance.Mode = Ceras.VersionToleranceMode.Standard;
                    Ceras.CerasSerializer Ser = new Ceras.CerasSerializer(Config);
                    cser = Ser;
                }
                else
                {
                    cser = Serializers.Pop();
                }

            byte[] CerasBuffer = null;

            RemoteData RD  = null;
            int        Off = IOffset;

            cser.Deserialize(ref RD, Request, ref Off);
            if (Math.Abs(Off - IOffset - ICount) > 1)
            {
                throw new System.Runtime.Serialization.SerializationException("Data size mismatch");
            }
            LocWrap.Swap(RD);

            int NL = cser.Serialize(RD, ref CerasBuffer);

            OOffset = 0; OCount = NL;
            return(CerasBuffer);
        }
Ejemplo n.º 2
0
        public void Swap(RemoteData RD)
        {
            Ceras.CerasSerializer cser;

            lock (Serializers)
                if (Serializers.Count == 0)
                {
                    Ceras.SerializerConfig Config = new Ceras.SerializerConfig();
                    Config.VersionTolerance.Mode = Ceras.VersionToleranceMode.Standard;
                    Ceras.CerasSerializer Ser = new Ceras.CerasSerializer(Config);
                    cser = Ser;
                }
                else
                {
                    cser = Serializers.Pop();
                }

            byte[] CerasBuffer;
            lock (CerasBuffers)
                if (CerasBuffers.Count == 0)
                {
                    CerasBuffer = null;
                }
                else
                {
                    CerasBuffer = CerasBuffers.Pop();
                }

            int Len = cser.Serialize(RD, ref CerasBuffer);

            int Ref = RD.Reference;

            byte[] Reply = Network.SendReceive(Ref, CerasBuffer, Len);

            cser.Deserialize(ref RD, Reply);

            lock (Serializers)
                Serializers.Push(cser);
            lock (CerasBuffers)
                CerasBuffers.Push(CerasBuffer);
        }