Exemplo n.º 1
0
	public new void PacketBytesToClass( byte[] data)
	{
		Type infotype = this.GetType();
		FieldInfo headerinfo = null;

		int index = ParsePacketHeader( data);

		// eResult
		byte[] result = new byte[ sizeof( Int32)];
		headerinfo = infotype.GetField( "eResult", BINDING_FLAGS_PIG);
		Buffer.BlockCopy( data, index, result, 0, sizeof( Int32));
		headerinfo.SetValue( this, BitConverter.ToInt32( result, 0));
		index += sizeof( Int32);

		// nPartyIdx
		byte[] partyIdx = new byte[ sizeof( Int32)];
		headerinfo = infotype.GetField( "nPartyIdx", BINDING_FLAGS_PIG);
		Buffer.BlockCopy( data, index, partyIdx, 0, sizeof( Int32));
		headerinfo.SetValue( this, BitConverter.ToInt32( partyIdx, 0));
		index += sizeof( Int32);

		// nMapIdx
		byte[] mapIdx = new byte[ sizeof( Int32)];
		headerinfo = infotype.GetField( "nMapIdx", BINDING_FLAGS_PIG);
		Buffer.BlockCopy( data, index, mapIdx, 0, sizeof( Int32));
		headerinfo.SetValue( this, BitConverter.ToInt32( mapIdx, 0));
		index += sizeof( Int32);

		sOption = new sPARTYOPTION();
		byte[] tmpData = new byte[sPARTYOPTION.size];
		Buffer.BlockCopy( data, index, tmpData, 0, tmpData.Length);
		sOption.ByteArrayToClass( tmpData);
		index += sPARTYOPTION.size;

		// nUserCnt
		byte[] userCnt = new byte[ sizeof( Int32)];
		headerinfo = infotype.GetField( "nUserCnt", BINDING_FLAGS_PIG);
		Buffer.BlockCopy( data, index, userCnt, 0, sizeof( Int32));
		headerinfo.SetValue( this, BitConverter.ToInt32( userCnt, 0));
		index += sizeof( Int32);

		if( 0 < nUserCnt)
		{
			body = new sPARTYDETAILINFO[nUserCnt];
			for( int i = 0; i < nUserCnt; i++)
			{
				body[i] = new sPARTYDETAILINFO();
	
				tmpData = new byte[sPARTYDETAILINFO.size];
				Buffer.BlockCopy( data, index, tmpData, 0, tmpData.Length);
				body[i].ByteArrayToClass( tmpData);
				index += sPARTYDETAILINFO.size;
			}
		}
	}