Beispiel #1
0
        public void TightMarshalNestedObject2(DataStructure o, BinaryWriter ds, BooleanStream bs)
        {
            if (!bs.ReadBoolean())
            {
                return;
            }

            byte type = o.GetDataStructureType();

            ds.Write(type);

            if (o.IsMarshallAware() && bs.ReadBoolean())
            {
                MarshallAware ma       = (MarshallAware)o;
                byte[]        sequence = ma.GetMarshalledForm(this);
                ds.Write(sequence, 0, sequence.Length);
            }
            else
            {
                BaseDataStreamMarshaller dsm;

                lock (this.marshalLock)
                {
                    dsm = GetDataStreamMarshallerForType(type);
                }

                dsm.TightMarshal2(this, o, ds, bs);
            }
        }
Beispiel #2
0
        public int TightMarshalNestedObject1(DataStructure o, BooleanStream bs)
        {
            bs.WriteBoolean(o != null);
            if (null == o)
            {
                return(0);
            }

            if (o.IsMarshallAware())
            {
                MarshallAware ma       = (MarshallAware)o;
                byte[]        sequence = ma.GetMarshalledForm(this);
                bs.WriteBoolean(sequence != null);
                if (sequence != null)
                {
                    return(1 + sequence.Length);
                }
            }

            byte type = o.GetDataStructureType();

            if (type == 0)
            {
                throw new IOException("No valid data structure type for: " + o + " of type: " + o.GetType());
            }

            BaseDataStreamMarshaller dsm = GetDataStreamMarshallerForType(type);

            Tracer.Debug("Marshalling type: " + type + " with structure: " + o);
            return(1 + dsm.TightMarshal1(this, o, bs));
        }
Beispiel #3
0
        public void TightMarshalNestedObject2(DataStructure o, BinaryWriter ds, BooleanStream bs)
        {
            if (!bs.ReadBoolean())
            {
                return;
            }

            byte type = o.GetDataStructureType();

            ds.Write(type);

            if (o.IsMarshallAware() && bs.ReadBoolean())
            {
                MarshallAware ma       = (MarshallAware)o;
                byte[]        sequence = ma.GetMarshalledForm(this);
                ds.Write(sequence, 0, sequence.Length);
            }
            else
            {
                BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller)dataMarshallers[type & 0xFF];
                if (dsm == null)
                {
                    throw new IOException("Unknown data type: " + type);
                }
                dsm.TightMarshal2(this, o, ds, bs);
            }
        }
        public int TightMarshalNestedObject1(DataStructure o, BooleanStream bs)
        {
            bs.WriteBoolean(o != null);
            if (o == null)
            {
                return(0);
            }

            if (o.IsMarshallAware())
            {
                MarshallAware ma       = (MarshallAware)o;
                byte[]        sequence = ma.GetMarshalledForm(this);
                bs.WriteBoolean(sequence != null);
                if (sequence != null)
                {
                    return(1 + sequence.Length);
                }
            }

            byte type = o.GetDataStructureType();

            if (type == 0)
            {
                throw new IOException("No valid data structure type for: " + o + " of type: " + o.GetType());
            }
            BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller)dataMarshallers[type & 0xFF];

            if (dsm == null)
            {
                throw new IOException("Unknown data type: " + type);
            }
            //Console.WriteLine("Marshalling type: " + type + " with structure: " + o);
            return(1 + dsm.TightMarshal1(this, o, bs));
        }
Beispiel #5
0
        public void Marshal(Object o, BinaryWriter ds)
        {
            int size = 1;

            if (o != null)
            {
                DataStructure            c    = (DataStructure)o;
                byte                     type = c.GetDataStructureType();
                BaseDataStreamMarshaller dsm  = dataMarshallers[type & 0xFF];
                if (dsm == null)
                {
                    throw new IOException("Unknown data type: " + type);
                }

                if (tightEncodingEnabled)
                {
                    BooleanStream bs = new BooleanStream();
                    size += dsm.TightMarshal1(this, c, bs);
                    size += bs.MarshalledSize();

                    if (!sizePrefixDisabled)
                    {
                        ds.Write(size);
                    }

                    ds.Write(type);
                    bs.Marshal(ds);
                    dsm.TightMarshal2(this, c, ds, bs);
                }
                else
                {
                    BinaryWriter looseOut = ds;
                    MemoryStream ms       = null;
                    // If we are prefixing then we need to first write it to memory,
                    // otherwise we can write direct to the stream.
                    if (!sizePrefixDisabled)
                    {
                        ms       = new MemoryStream();
                        looseOut = new OpenWireBinaryWriter(ms);
                        looseOut.Write(size);
                    }

                    looseOut.Write(type);
                    dsm.LooseMarshal(this, c, looseOut);

                    if (!sizePrefixDisabled)
                    {
                        ms.Position = 0;
                        looseOut.Write((int)ms.Length - 4);
                        ds.Write(ms.GetBuffer(), 0, (int)ms.Length);
                    }
                }
            }
            else
            {
                ds.Write(size);
                ds.Write(NULL_TYPE);
            }
        }
        public override Response visit(ICommandVisitor visitor)
        {
            switch (objectId.GetDataStructureType())
            {
            case ConnectionId.ID_ConnectionId:
                return(visitor.processRemoveConnection((ConnectionId)objectId));

            case SessionId.ID_SessionId:
                return(visitor.processRemoveSession((SessionId)objectId));

            case ConsumerId.ID_ConsumerId:
                return(visitor.processRemoveConsumer((ConsumerId)objectId));

            case ProducerId.ID_ProducerId:
                return(visitor.processRemoveProducer((ProducerId)objectId));

            default:
                throw new IOException("Unknown remove command type: " + objectId.GetDataStructureType());
            }
        }
Beispiel #7
0
        public void LooseMarshalNestedObject(DataStructure o, BinaryWriter dataOut)
        {
            dataOut.Write(o != null);
            if (o != null)
            {
                byte type = o.GetDataStructureType();
                dataOut.Write(type);

                BaseDataStreamMarshaller dsm = GetDataStreamMarshallerForType(type);
                dsm.LooseMarshal(this, o, dataOut);
            }
        }
Beispiel #8
0
 public void LooseMarshalNestedObject(DataStructure o, BinaryWriter dataOut)
 {
     dataOut.Write(o != null);
     if (o != null)
     {
         byte type = o.GetDataStructureType();
         dataOut.Write(type);
         BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller)dataMarshallers[type & 0xFF];
         if (dsm == null)
         {
             throw new IOException("Unknown data type: " + type);
         }
         dsm.LooseMarshal(this, o, dataOut);
     }
 }
Beispiel #9
0
        public void TightMarshalNestedObject2(DataStructure o, BinaryWriter ds, BooleanStream bs)
        {
            if(!bs.ReadBoolean())
            {
                return;
            }

            byte type = o.GetDataStructureType();
            ds.Write(type);

            if(o.IsMarshallAware() && bs.ReadBoolean())
            {
                MarshallAware ma = (MarshallAware) o;
                byte[] sequence = ma.GetMarshalledForm(this);
                ds.Write(sequence, 0, sequence.Length);
            }
            else
            {
                BaseDataStreamMarshaller dsm = GetDataStreamMarshallerForType(type);
                dsm.TightMarshal2(this, o, ds, bs);
            }
        }
Beispiel #10
0
        public int TightMarshalNestedObject1(DataStructure o, BooleanStream bs)
        {
            bs.WriteBoolean(o != null);
            if(null == o)
            {
                return 0;
            }

            if(o.IsMarshallAware())
            {
                MarshallAware ma = (MarshallAware) o;
                byte[] sequence = ma.GetMarshalledForm(this);
                bs.WriteBoolean(sequence != null);
                if(sequence != null)
                {
                    return 1 + sequence.Length;
                }
            }

            byte type = o.GetDataStructureType();
            if(type == 0)
            {
                throw new IOException("No valid data structure type for: " + o + " of type: " + o.GetType());
            }

            BaseDataStreamMarshaller dsm = GetDataStreamMarshallerForType(type);

            Tracer.Debug("Marshalling type: " + type + " with structure: " + o);
            return 1 + dsm.TightMarshal1(this, o, bs);
        }
Beispiel #11
0
        public void LooseMarshalNestedObject(DataStructure o, BinaryWriter dataOut)
        {
            dataOut.Write(o != null);
            if(o != null)
            {
                byte type = o.GetDataStructureType();
                dataOut.Write(type);

                BaseDataStreamMarshaller dsm = GetDataStreamMarshallerForType(type);
                dsm.LooseMarshal(this, o, dataOut);
            }
        }
        public void LooseMarshalNestedObject(DataStructure o, BinaryWriter dataOut)
        {
			dataOut.Write(o!=null);
			if( o!=null ) {
				byte type = o.GetDataStructureType();
				dataOut.Write(type);
                BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
				if( dsm == null )
					throw new IOException("Unknown data type: "+type);
				dsm.LooseMarshal(this, o, dataOut);
			}
        }
 public void TightMarshalNestedObject2(DataStructure o, BinaryWriter ds, BooleanStream bs)
 {
     if (!bs.ReadBoolean())
         return ;
     
     byte type = o.GetDataStructureType();
     ds.Write(type);
     
     if (o.IsMarshallAware() && bs.ReadBoolean())
     {
         MarshallAware ma = (MarshallAware) o;
         byte[] sequence = ma.GetMarshalledForm(this);
         ds.Write(sequence, 0, sequence.Length);
     }
     else
     {
         
         BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
         if (dsm == null)
             throw new IOException("Unknown data type: " + type);
         dsm.TightMarshal2(this, o, ds, bs);
     }
 }
 public int TightMarshalNestedObject1(DataStructure o, BooleanStream bs)
 {
     bs.WriteBoolean(o != null);
     if (o == null)
         return 0;
     
     if (o.IsMarshallAware())
     {
         MarshallAware ma = (MarshallAware) o;
         byte[] sequence = ma.GetMarshalledForm(this);
         bs.WriteBoolean(sequence != null);
         if (sequence != null)
         {
             return 1 + sequence.Length;
         }
     }
     
     byte type = o.GetDataStructureType();
     if (type == 0) {
         throw new IOException("No valid data structure type for: " + o + " of type: " + o.GetType());
     }
     BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller) dataMarshallers[type & 0xFF];
     if (dsm == null)
         throw new IOException("Unknown data type: " + type);
     //Console.WriteLine("Marshalling type: " + type + " with structure: " + o);
     return 1 + dsm.TightMarshal1(this, o, bs);
 }
Beispiel #15
0
        public void Marshal(Object o, BinaryWriter ds)
        {
            int size = 1;

            if (o != null)
            {
                DataStructure            c    = (DataStructure)o;
                byte                     type = c.GetDataStructureType();
                BaseDataStreamMarshaller dsm;
                bool                     _tightEncodingEnabled;
                bool                     _sizePrefixDisabled;

                lock (this.marshalLock)
                {
                    dsm = GetDataStreamMarshallerForType(type);
                    _tightEncodingEnabled = this.tightEncodingEnabled;
                    _sizePrefixDisabled   = this.sizePrefixDisabled;
                }

                if (_tightEncodingEnabled)
                {
                    BooleanStream bs = new BooleanStream();
                    size += dsm.TightMarshal1(this, c, bs);
                    size += bs.MarshalledSize();

                    if (!_sizePrefixDisabled)
                    {
                        ds.Write(size);
                    }

                    ds.Write(type);
                    bs.Marshal(ds);
                    dsm.TightMarshal2(this, c, ds, bs);
                }
                else
                {
                    BinaryWriter looseOut = ds;
                    MemoryStream ms       = null;

                    // If we are prefixing then we need to first write it to memory,
                    // otherwise we can write direct to the stream.
                    if (!_sizePrefixDisabled)
                    {
                        ms       = new MemoryStream();
                        looseOut = new EndianBinaryWriter(ms);
                        looseOut.Write(size);
                    }

                    looseOut.Write(type);
                    dsm.LooseMarshal(this, c, looseOut);

                    if (!_sizePrefixDisabled)
                    {
                        ms.Position = 0;
                        looseOut.Write((int)ms.Length - 4);
                        ds.Write(ms.GetBuffer(), 0, (int)ms.Length);
                    }
                }
            }
            else
            {
                ds.Write(size);
                ds.Write(NULL_TYPE);
            }
        }