Ejemplo n.º 1
0
        /// <summary>
        /// This function deserialize from a byte array and return a new class filled
        /// with the data
        /// </summary>
        /// <param name="data">serialized data that contains the information</param>
        /// <returns>a new class filled with the deserialized data</returns>
        public new static DataErrorCommand DeSerialize(byte[] data)
        {
            var com = new DataErrorCommand();

            using (var m = new MemoryStream(data))
            {
                using (var reader = new BinaryReader(m))
                {
                    com.CommandSize   = reader.ReadUInt16();
                    com.CommandCode   = reader.ReadUInt16();
                    com.GroupId       = reader.ReadUInt16();
                    com.DataErrorCode = reader.ReadUInt16();
                }
            }
            return(com);
        }
 // Data handler for data errors, prints out the groupId and error code
 public virtual void OnDataError(DataErrorCommand error)
 {
     Console.Out.WriteLine("Data Error: GroupId: {0}, Errorcode: {1}", error.GroupId, error.DataErrorCode);
 }