public FABMessage Serialize(IntPtr value) { var message = new FABMessage(); ((FABMessageWatcher)message).Write((void *)value, Marshal.SizeOf(value)); return(message); }
public FABMessage GetMessage(T value) { IntPtr pointer = Marshal.OffsetOf(typeof(T), value.GetType().Name); ushort code; if (!_opCodeLookup.TryGetValue(pointer, out code)) { #if DEBUG throw new FABBadOpCodeException("No opcode found for type {0}", value.GetType().FullName); #else throw new FABBadOpCodeException(opCode); #endif } if (!_typeLookup.ContainsKey(code)) { Register <T>(code); } FABMessage message = serializer.Serialize(pointer); if ((ushort)message.OpCode != code) { #if DEBUG throw new FABBadOpCodeException("No opcode found for type {0}", value.GetType().FullName); #else throw new ProudBadOpCodeException(opCode); #endif } return(message); }
public T GetStructure(FABMessage message) { IntPtr type; if (!_typeLookup.TryGetValue((ushort)message.OpCode, out type)) { throw new FABBadOpCodeException("No type found for opcode {0}", (ushort)message.OpCode); } return(this.serializer.Deserialize(message, type)); }
public T Deserialize(FABMessage data, IntPtr value) { ((FABMessageWatcher)data).Read(Marshal.SizeOf(value), (void *)value); return(Marshal.PtrToStructure <T>(value)); }
public FABMessageEventArgs(FABMessage message) { this.message = message; }