public int PacketBytesToClass( byte[] data, int index) { Type infotype = this.GetType(); // bRead byte[] tempRead = new byte[ sizeof( bool)]; Buffer.BlockCopy( data, index, tempRead, 0, sizeof( bool)); FieldInfo headerinfo = infotype.GetField( "bRead", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToBoolean( tempRead, 0)); index += sizeof( bool); // nPostSerial byte[] tempPostSerial = new byte[ sizeof( UInt64)]; Buffer.BlockCopy( data, index, tempPostSerial, 0, sizeof( UInt64)); headerinfo = infotype.GetField( "nPostSerial", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToUInt64( tempPostSerial, 0)); index += sizeof( UInt64); // bAccount byte[] tempAccount = new byte[ sizeof( bool)]; Buffer.BlockCopy( data, index, tempAccount, 0, sizeof( bool)); headerinfo = infotype.GetField( "bAccount", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToBoolean( tempAccount, 0)); index += sizeof( bool); // nPostType byte[] tempPostType = new byte[ sizeof( Int32)]; Buffer.BlockCopy( data, index, tempPostType, 0, sizeof( Int32)); headerinfo = infotype.GetField( "nPostType", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToInt32( tempPostType, 0)); index += sizeof( Int32); // nPostSubValue1 byte[] tempPostSubValue1 = new byte[ sizeof( Int64)]; Buffer.BlockCopy( data, index, tempPostSubValue1, 0, sizeof( Int64)); headerinfo = infotype.GetField( "nPostSubValue1", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToInt64( tempPostSubValue1, 0)); index += sizeof( Int64); // nPostSubValue2 byte[] tempPostSubValue2 = new byte[ sizeof( Int64)]; Buffer.BlockCopy( data, index, tempPostSubValue2, 0, sizeof( Int64)); headerinfo = infotype.GetField( "nPostSubValue2", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToInt64( tempPostSubValue2, 0)); index += sizeof( Int64); // nPostSubValue3 byte[] tempPostSubValue3 = new byte[ sizeof( Int64)]; Buffer.BlockCopy( data, index, tempPostSubValue3, 0, sizeof( Int64)); headerinfo = infotype.GetField( "nPostSubValue3", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToInt64( tempPostSubValue3, 0)); index += sizeof( Int64); // nGold byte[] tempGold = new byte[ sizeof( UInt64)]; Buffer.BlockCopy( data, index, tempGold, 0, sizeof( UInt64)); headerinfo = infotype.GetField( "nGold", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToUInt64( tempGold, 0)); index += sizeof( UInt64); sRecievItem1 = new sITEM(); byte[] tempRecievItem1 = new byte[ sITEM.size]; Buffer.BlockCopy( data, index, tempRecievItem1, 0, sITEM.size); sRecievItem1.ByteArrayToClass( tempRecievItem1); index += sITEM.size; sRecievItem2 = new sITEM(); byte[] tempRecievItem2 = new byte[ sITEM.size]; Buffer.BlockCopy( data, index, tempRecievItem2, 0, sITEM.size); sRecievItem2.ByteArrayToClass( tempRecievItem2); index += sITEM.size; sRecievItem3 = new sITEM(); byte[] tempRecievItem3 = new byte[ sITEM.size]; Buffer.BlockCopy( data, index, tempRecievItem3, 0, sITEM.size); sRecievItem3.ByteArrayToClass( tempRecievItem3); index += sITEM.size; sRecievItem4 = new sITEM(); byte[] tempRecievItem4 = new byte[ sITEM.size]; Buffer.BlockCopy( data, index, tempRecievItem4, 0, sITEM.size); sRecievItem4.ByteArrayToClass( tempRecievItem4); index += sITEM.size; // nDeleteTime byte[] tempDeleteTime = new byte[ sizeof( UInt32)]; Buffer.BlockCopy( data, index, tempDeleteTime, 0, sizeof( UInt32)); headerinfo = infotype.GetField( "nDeleteTime", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToUInt32( tempDeleteTime, 0)); index += sizeof( UInt32); // nSendNameLength byte[] tempSendNameLength = new byte[ sizeof(Int16)]; Buffer.BlockCopy( data, index, tempSendNameLength, 0, sizeof(Int16)); headerinfo = infotype.GetField( "nSendNameLength", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToInt16( tempSendNameLength, 0)); index += sizeof(Int16); // nTitleLength byte[] tempTitleLength = new byte[ sizeof(Int16)]; Buffer.BlockCopy( data, index, tempTitleLength, 0, sizeof(Int16)); headerinfo = infotype.GetField( "nTitleLength", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToInt16( tempTitleLength, 0)); index += sizeof(Int16); // nContentLength byte[] tempContentLength = new byte[ sizeof(Int16)]; Buffer.BlockCopy( data, index, tempContentLength, 0, sizeof(Int16)); headerinfo = infotype.GetField( "nContentLength", BINDING_FLAGS_PIG); headerinfo.SetValue( this, BitConverter.ToInt16( tempContentLength, 0)); index += sizeof(Int16); byte[] tempSenderName = new byte[ nSendNameLength]; Buffer.BlockCopy( data, index, tempSenderName, 0, nSendNameLength); senderName = System.Text.UTF8Encoding.UTF8.GetString( tempSenderName); index += nSendNameLength; byte[] tempTitle = new byte[ nTitleLength]; Buffer.BlockCopy( data, index, tempTitle, 0, nTitleLength); title = System.Text.UTF8Encoding.UTF8.GetString( tempTitle); index += nTitleLength; byte[] tempContent = new byte[ nContentLength]; Buffer.BlockCopy( data, index, tempContent, 0, nContentLength); content = System.Text.UTF8Encoding.UTF8.GetString( tempContent); index += nContentLength; return index; }