ReadBoolean() public method

public ReadBoolean ( ) : bool
return bool
 public virtual void TightMarshalLong2(
     OpenWireFormat wireFormat,
     long o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         if (bs.ReadBoolean())
         {
             dataOut.Write(o);
         }
         else
         {
             dataOut.Write((int)o);
         }
     }
     else
     {
         if (bs.ReadBoolean())
         {
             dataOut.Write((short)o);
         }
     }
 }
Esempio n. 2
0
        public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
        {
            if (bs.ReadBoolean())
            {
                byte dataType = dis.ReadByte();

                BaseDataStreamMarshaller dsm  = GetDataStreamMarshallerForType(dataType);
                DataStructure            data = dsm.CreateObject();

                if (data.IsMarshallAware() && bs.ReadBoolean())
                {
                    dis.ReadInt32();
                    dis.ReadByte();

                    BooleanStream bs2 = new BooleanStream();
                    bs2.Unmarshal(dis);
                    dsm.TightUnmarshal(this, data, dis, bs2);
                }
                else
                {
                    dsm.TightUnmarshal(this, data, dis, bs);
                }

                return(data);
            }

            return(null);
        }
Esempio n. 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;

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

                dsm.TightMarshal2(this, o, ds, bs);
            }
        }
 public virtual long TightUnmarshalLong(OpenWireFormat wireFormat, BinaryReader dataIn, BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         if (bs.ReadBoolean())
         {
             return(dataIn.ReadInt64()); // dataIn.ReadInt64();
         }
         else
         {
             return(dataIn.ReadInt32());
         }
     }
     else
     {
         if (bs.ReadBoolean())
         {
             return(dataIn.ReadInt16());
         }
         else
         {
             return(0);
         }
     }
 }
Esempio n. 5
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);
            }
        }
        protected virtual BrokerError TightUnmarshalBrokerError(
            OpenWireFormat wireFormat,
            BinaryReader dataIn,
            BooleanStream bs)
        {
            if (bs.ReadBoolean())
            {
                BrokerError answer = new BrokerError();

                answer.ExceptionClass = TightUnmarshalString(dataIn, bs);
                answer.Message        = TightUnmarshalString(dataIn, bs);
                if (wireFormat.StackTraceEnabled)
                {
                    short length = dataIn.ReadInt16();
                    StackTraceElement[] stackTrace = new StackTraceElement[length];
                    for (int i = 0; i < stackTrace.Length; i++)
                    {
                        StackTraceElement element = new StackTraceElement();
                        element.ClassName  = TightUnmarshalString(dataIn, bs);
                        element.MethodName = TightUnmarshalString(dataIn, bs);
                        element.FileName   = TightUnmarshalString(dataIn, bs);
                        element.LineNumber = dataIn.ReadInt32();
                        stackTrace[i]      = element;
                    }
                    answer.StackTraceElements = stackTrace;
                    answer.Cause = TightUnmarshalBrokerError(wireFormat, dataIn, bs);
                }
                return(answer);
            }
            else
            {
                return(null);
            }
        }
        protected void TightMarshalBrokerError2(
            OpenWireFormat wireFormat,
            BrokerError o,
            BinaryWriter dataOut,
            BooleanStream bs)
        {
            if (bs.ReadBoolean())
            {
                TightMarshalString2(o.ExceptionClass, dataOut, bs);
                TightMarshalString2(o.Message, dataOut, bs);
                if (wireFormat.StackTraceEnabled)
                {
                    StackTraceElement[] stackTrace = o.StackTraceElements;
                    dataOut.Write((short)stackTrace.Length);

                    for (int i = 0; i < stackTrace.Length; i++)
                    {
                        StackTraceElement element = stackTrace[i];
                        TightMarshalString2(element.ClassName, dataOut, bs);
                        TightMarshalString2(element.MethodName, dataOut, bs);
                        TightMarshalString2(element.FileName, dataOut, bs);
                        dataOut.Write(element.LineNumber);
                    }
                    TightMarshalBrokerError2(wireFormat, o.Cause, dataOut, bs);
                }
            }
        }
 protected virtual String TightUnmarshalString(BinaryReader dataIn, BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         if (bs.ReadBoolean())
         {
             return(ReadAsciiString(dataIn));
         }
         else
         {
             return(dataIn.ReadString());
         }
     }
     else
     {
         return(null);
     }
 }
 public static void TightMarshalString2(String value, BinaryWriter dataOut, BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         // If we verified it only holds ascii values
         if (bs.ReadBoolean())
         {
             dataOut.Write((short) value.Length);
             // now lets write the bytes
             char[] chars = value.ToCharArray();
             for (int i = 0; i < chars.Length; i++)
             {
                 dataOut.Write((byte)(chars[i]&0xFF00>>8));
             }
         }
         else
         {
             dataOut.Write(value);
         }
     }
 }
Esempio n. 10
0
 public static void TightMarshalString2(String value, BinaryWriter dataOut, BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         // If we verified it only holds ascii values
         if (bs.ReadBoolean())
         {
             dataOut.Write((short)value.Length);
             // now lets write the bytes
             char[] chars = value.ToCharArray();
             for (int i = 0; i < chars.Length; i++)
             {
                 dataOut.Write((byte)(chars[i] & 0xFF00 >> 8));
             }
         }
         else
         {
             dataOut.Write(value);
         }
     }
 }
Esempio n. 11
0
        public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
        {
            if (bs.ReadBoolean())
            {
                DataStructure            data;
                BaseDataStreamMarshaller dsm;
                byte dataType = dis.ReadByte();

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

                data = dsm.CreateObject();
                if (data.IsMarshallAware() && bs.ReadBoolean())
                {
                    dis.ReadInt32();
                    dis.ReadByte();

                    BooleanStream bs2 = new BooleanStream();
                    bs2.Unmarshal(dis);
                    dsm.TightUnmarshal(this, data, dis, bs2);

                    // TODO: extract the sequence from the dis and associate it.
                    //                MarshallAware ma = (MarshallAware)data
                    //                ma.setCachedMarshalledForm(this, sequence);
                }
                else
                {
                    dsm.TightUnmarshal(this, data, dis, bs);
                }

                return(data);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 12
0
        public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
        {
            if (bs.ReadBoolean())
            {
                byte dataType = dis.ReadByte();
                BaseDataStreamMarshaller dsm = (BaseDataStreamMarshaller)dataMarshallers[dataType & 0xFF];
                if (dsm == null)
                {
                    throw new IOException("Unknown data type: " + dataType);
                }
                DataStructure data = dsm.CreateObject();

                if (data.IsMarshallAware() && bs.ReadBoolean())
                {
                    dis.ReadInt32();
                    dis.ReadByte();

                    BooleanStream bs2 = new BooleanStream();
                    bs2.Unmarshal(dis);
                    dsm.TightUnmarshal(this, data, dis, bs2);

                    // TODO: extract the sequence from the dis and associate it.
                    //                MarshallAware ma = (MarshallAware)data
                    //                ma.setCachedMarshalledForm(this, sequence);
                }
                else
                {
                    dsm.TightUnmarshal(this, data, dis, bs);
                }

                return(data);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 13
0
 protected virtual void TightMarshalObjectArray2(
     OpenWireFormat wireFormat,
     DataStructure[] objects,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         dataOut.Write((short)objects.Length);
         for (int i = 0; i < objects.Length; i++)
         {
             TightMarshalNestedObject2(wireFormat, objects[i], dataOut, bs);
         }
     }
 }
Esempio n. 14
0
 protected virtual BrokerError TightUnmarshalBrokerError(
     OpenWireFormat wireFormat,
     BinaryReader dataIn,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         BrokerError answer = new BrokerError();
         
         answer.ExceptionClass = TightUnmarshalString(dataIn, bs);
         answer.Message = TightUnmarshalString(dataIn, bs);
         if (wireFormat.StackTraceEnabled)
         {
             short length = dataIn.ReadInt16();
             StackTraceElement[] stackTrace = new StackTraceElement[length];
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = new StackTraceElement();
                 element.ClassName = TightUnmarshalString(dataIn, bs);
                 element.MethodName = TightUnmarshalString(dataIn, bs);
                 element.FileName = TightUnmarshalString(dataIn, bs);
                 element.LineNumber = dataIn.ReadInt32();
                 stackTrace[i] = element;
             }
             answer.StackTraceElements = stackTrace;
             answer.Cause = TightUnmarshalBrokerError(wireFormat, dataIn, bs);
         }
         return answer;
     }
     else
     {
         return null;
     }
 }
Esempio n. 15
0
        protected void AssertMarshalBooleans(int count, GetBooleanValueDelegate valueDelegate)
        {
            BooleanStream bs = new BooleanStream();
            for(int i = 0; i < count; i++)
            {
                bs.WriteBoolean(valueDelegate(i, count));
            }
            MemoryStream buffer = new MemoryStream();
            BinaryWriter ds = new EndianBinaryWriter(buffer);
            bs.Marshal(ds);
            ds.Write(endOfStreamMarker);

            // now lets read from the stream

            MemoryStream ins = new MemoryStream(buffer.ToArray());
            BinaryReader dis = new EndianBinaryReader(ins);
            bs = new BooleanStream();
            bs.Unmarshal(dis);

            for(int i = 0; i < count; i++)
            {
                bool expected = valueDelegate(i, count);

                try
                {
                    bool actual = bs.ReadBoolean();
                    Assert.AreEqual(expected, actual);
                }
                catch(Exception e)
                {
                    Assert.Fail("Failed to parse bool: " + i + " out of: " + count + " due to: " + e);
                }
            }
            int marker = dis.ReadInt32();
            Assert.AreEqual(endOfStreamMarker, marker, "did not match: " + endOfStreamMarker + " and " + marker);

            // lets try read and we should get an exception
            try
            {
                dis.ReadByte();
                Assert.Fail("Should have reached the end of the stream");
            }
            catch(EndOfStreamException)
            {
            }
        }
Esempio n. 16
0
        public DataStructure TightUnmarshalNestedObject(BinaryReader dis, BooleanStream bs)
        {
            if(bs.ReadBoolean())
            {
                byte dataType = dis.ReadByte();

                BaseDataStreamMarshaller dsm = GetDataStreamMarshallerForType(dataType);
                DataStructure data = dsm.CreateObject();

                if(data.IsMarshallAware() && bs.ReadBoolean())
                {
                    dis.ReadInt32();
                    dis.ReadByte();

                    BooleanStream bs2 = new BooleanStream();
                    bs2.Unmarshal(dis);
                    dsm.TightUnmarshal(this, data, dis, bs2);
                }
                else
                {
                    dsm.TightUnmarshal(this, data, dis, bs);
                }

                return data;
            }

            return null;
        }
Esempio n. 17
0
 protected virtual String TightUnmarshalString(BinaryReader dataIn, BooleanStream bs)
 {
     if(bs.ReadBoolean())
     {
         if(bs.ReadBoolean())
         {
             return ReadAsciiString(dataIn);
         }
         else
         {
             return dataIn.ReadString();
         }
     }
     else
     {
         return null;
     }
 }
Esempio n. 18
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);
            }
        }
Esempio n. 19
0
 protected void TightMarshalBrokerError2(
     OpenWireFormat wireFormat,
     BrokerError o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         TightMarshalString2(o.ExceptionClass, dataOut, bs);
         TightMarshalString2(o.Message, dataOut, bs);
         if (wireFormat.StackTraceEnabled)
         {
             StackTraceElement[] stackTrace = o.StackTraceElements;
             dataOut.Write((short) stackTrace.Length);
             
             for (int i = 0; i < stackTrace.Length; i++)
             {
                 StackTraceElement element = stackTrace[i];
                 TightMarshalString2(element.ClassName, dataOut, bs);
                 TightMarshalString2(element.MethodName, dataOut, bs);
                 TightMarshalString2(element.FileName, dataOut, bs);
                 dataOut.Write(element.LineNumber);
             }
             TightMarshalBrokerError2(wireFormat, o.Cause, dataOut, bs);
         }
     }
 }
Esempio n. 20
0
 public virtual void TightMarshalLong2(
     OpenWireFormat wireFormat,
     long o,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         if (bs.ReadBoolean())
         {
             dataOut.Write(o);
         }
         else
         {
             dataOut.Write((int)o);
         }
     }
     else
     {
         if (bs.ReadBoolean())
         {
             dataOut.Write((short)o);
         }
     }
 }
Esempio n. 21
0
 protected virtual void TightMarshalObjectArray2(
     OpenWireFormat wireFormat,
     DataStructure[] objects,
     BinaryWriter dataOut,
     BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         dataOut.Write((short) objects.Length);
         for (int i = 0; i < objects.Length; i++)
         {
             TightMarshalNestedObject2(wireFormat, objects[i], dataOut, bs);
         }
     }
 }
Esempio n. 22
0
 public virtual long TightUnmarshalLong(OpenWireFormat wireFormat, BinaryReader dataIn, BooleanStream bs)
 {
     if (bs.ReadBoolean())
     {
         if (bs.ReadBoolean())
         {
             return dataIn.ReadInt64(); // dataIn.ReadInt64();
         }
         else
         {
             return dataIn.ReadInt32();
         }
     }
     else
     {
         if (bs.ReadBoolean())
         {
             return dataIn.ReadInt16();
         }
         else
         {
             return 0;
         }
     }
 }