Beispiel #1
0
 public void Encode(ServerMessage value)
 {
     Debug.Assert(ExpectForServerMessage);
     ExpectForServerMessage = false;
     Encode(IntCaster <ServerMessage> .ToInt(value));
     LastServerMessageEncoded = value;
 }
        public T DecodeEnum <T>() where T : struct, IConvertible
        {
            var t        = typeof(T);
            var intValue = _enumDecoders.ContainsKey(t) ?
                           _enumDecoders[t].EnumDeserializares[DecodeString() ?? String.Empty] :
                           DecodeInt();

            // Is this a TWS string based enum?
            return(IntCaster <T> .ToT(intValue));
        }
        public void Encode <T>(T value) where T : struct, IConvertible
        {
            var t = typeof(T);

            if (_enumDecoders.ContainsKey(t))
            {
                Encode(_enumDecoders[t].EnumSerializares[IntCaster <T> .ToInt(value)]);
            }
            else
            {
                Encode(IntCaster <T> .ToInt(value));
            }
        }