}        /// <summary>

        /// The try parse event data.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="eventData">The event data.</param>
        /// <returns>true on success.</returns>
        internal bool TryParseEventData(Stream stream, out EventData eventData)
        {
            object obj3;
            BigEndianBinaryReader binaryReader = new BigEndianBinaryReader(stream);
            short capacity = binaryReader.ReadInt16();
            Dictionary <byte, object> dictionary = new Dictionary <byte, object>(capacity);

            for (short i = 0; i < capacity; i = (short)(i + 1))
            {
                object obj2;
                byte   key = binaryReader.ReadByte();
                if (GpBinaryByteReader.Read(binaryReader, out obj2))
                {
                    dictionary.Add(key, obj2);
                }
                else
                {
                    eventData = null;
                    return(false);
                }
            }
            EventData data = new EventData
            {
                Parameters = dictionary
            };

            eventData = data;
            if (dictionary.TryGetValue(0xf4, out obj3) && (obj3 is byte))
            {
                eventData.Code = (byte)obj3;
            }
            return(true);
        }
        /// <summary>
        /// The try parse operation response.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="operationResponse">The operation response.</param>
        /// <returns>true on success.</returns>
        internal bool TryParseOperationResponse(Stream stream, out OperationResponse operationResponse)
        {
            object obj3;
            BigEndianBinaryReader binaryReader = new BigEndianBinaryReader(stream);
            short capacity = binaryReader.ReadInt16();
            Dictionary <byte, object> dictionary = new Dictionary <byte, object>(capacity);

            for (short i = 0; i < capacity; i = (short)(i + 1))
            {
                object obj2;
                byte   key = binaryReader.ReadByte();
                if (GpBinaryByteReader.Read(binaryReader, out obj2))
                {
                    dictionary.Add(key, obj2);
                }
                else
                {
                    operationResponse = null;
                    return(false);
                }
            }
            byte   num4 = 0;
            short  num5 = 0;
            string str  = null;

            if (dictionary.TryGetValue(0xf4, out obj3) && (obj3 is byte))
            {
                num4 = (byte)obj3;
            }
            if (dictionary.TryGetValue(0, out obj3) && (obj3 is int))
            {
                num5 = (short)((int)obj3);
            }
            if (dictionary.TryGetValue(1, out obj3))
            {
                string str2 = obj3 as string;
                if (str2 != null)
                {
                    str = str2;
                }
            }
            OperationResponse response = new OperationResponse
            {
                DebugMessage  = str,
                ReturnCode    = num5,
                OperationCode = num4,
                Parameters    = dictionary
            };

            operationResponse = response;
            return(true);
        }
Esempio n. 3
0
        private static bool TryParseOperationResponse(Stream stream, out OperationResponse operationResponse)
        {
            object obj2;
            BigEndianBinaryReader binaryReader = new BigEndianBinaryReader(stream);

            if (GpBinaryByteReader.ReadOperationResponse(binaryReader, out obj2))
            {
                operationResponse = (OperationResponse)obj2;
                return(true);
            }
            operationResponse = null;
            return(false);
        }
Esempio n. 4
0
        private static bool TryParseOperationRequest(MemoryStream stream, out OperationRequest operationRequest)
        {
            object obj2;
            BigEndianBinaryReader binaryReader = new BigEndianBinaryReader(stream);

            if (GpBinaryByteReader.ReadOperationRequest(binaryReader, out obj2))
            {
                operationRequest = (OperationRequest)obj2;
                return(true);
            }
            operationRequest = null;
            return(false);
        }
Esempio n. 5
0
        private static bool TryParseEventData(Stream stream, out EventData eventData)
        {
            object obj2;
            BigEndianBinaryReader binaryReader = new BigEndianBinaryReader(stream);

            if (GpBinaryByteReader.ReadEventData(binaryReader, out obj2))
            {
                eventData = (EventData)obj2;
                return(true);
            }
            eventData = null;
            return(false);
        }
        /// <summary>
        ///  Tries to parse an operation request.
        /// </summary>
        /// <param name="stream"> The stream.</param>
        /// <param name="operationRequest">The operation request.</param>
        /// <returns>True on success.</returns>
        private static bool TryParseOperationRequest(MemoryStream stream, out OperationRequest operationRequest)
        {
            BigEndianBinaryReader binaryReader = new BigEndianBinaryReader(stream);
            byte num = binaryReader.ReadByte();

            binaryReader.ReadBoolean();
            short capacity = binaryReader.ReadInt16();

            if ((capacity < 0) || (capacity > ((stream.Length - stream.Position) / 2L)))
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Invalid parameter count: count={0}, bytesLeft={1}", new object[] { capacity, stream.Length - stream.Position });
                }
                operationRequest = null;
                return(false);
            }
            OperationRequest request = new OperationRequest
            {
                Parameters    = new Dictionary <byte, object>(capacity),
                OperationCode = num
            };

            operationRequest = request;
            for (short i = 0; i < capacity; i = (short)(i + 1))
            {
                object obj2;
                byte   key = binaryReader.ReadByte();
                if (GpBinaryByteReader.Read(binaryReader, out obj2))
                {
                    operationRequest.Parameters.Add(key, obj2);
                }
                else
                {
                    operationRequest = null;
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 7
0
        public bool TryParse(Stream stream, out object obj)
        {
            BigEndianBinaryReader binaryReader = new BigEndianBinaryReader(stream);

            return(GpBinaryByteReader.Read(binaryReader, out obj));
        }