Esempio n. 1
0
        public FABMessage Serialize(IntPtr value)
        {
            var message = new FABMessage();

            ((FABMessageWatcher)message).Write((void *)value, Marshal.SizeOf(value));
            return(message);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 public T Deserialize(FABMessage data, IntPtr value)
 {
     ((FABMessageWatcher)data).Read(Marshal.SizeOf(value), (void *)value);
     return(Marshal.PtrToStructure <T>(value));
 }
Esempio n. 5
0
 public FABMessageEventArgs(FABMessage message)
 {
     this.message = message;
 }