Example #1
0
        // Skips fields until finds MsgType. Throws if MsgType can't be found.
        static MsgType FindMsgType(IEnumerator <Field> fields)
        {
            MsgType msgType = new MsgType();

            while (fields.MoveNext())
            {
                int tag = Deserialization.ParseInt(fields.Current.Tag);
                if (msgType.AcceptField(tag, fields.Current.Value) == FieldAcceptance.Accepted)
                {
                    return(msgType);
                }
            }
            throw new MsgTypeNotFoundException();
        }
Example #2
0
        // Throws if the message is malformed.
        // Returns null if message type isn't recognized.
        // If the result is not null, it's guaranteed to inherit from Fix44.Message
        // and implement IClientMessage, IServerMessage, or both.
        public Mantle.IMessage CreateMessage(IEnumerator <Field> fields)
        {
            MsgType  msgType = FindMsgType(fields);
            IMessage msg     = NewMessage(msgType);

            if (msg != null)
            {
                while (fields.MoveNext())
                {
                    int tag = Deserialization.ParseInt(fields.Current.Tag);
                    msg.AcceptField(tag, fields.Current.Value);
                }
            }
            return(msg);
        }
Example #3
0
        // Throws if the protocol can't be recognized.
        IMessageFactory GetFactory(IEnumerator <Field> fields)
        {
            if (!fields.MoveNext())
            {
                throw new MissingBeginStringException();
            }
            int         tag     = Deserialization.ParseInt(fields.Current.Tag);
            BeginString version = new BeginString();

            if (version.AcceptField(tag, fields.Current.Value) != FieldAcceptance.Accepted)
            {
                throw new MissingBeginStringException();
            }
            if (!_protocols.ContainsKey(version.Value))
            {
                throw new UnsupportedProtocolException(String.Format("Unrecognized protocol: {0}", version.Value));
            }
            return(_protocols[version.Value]);
        }
Example #4
0
 protected override int Deserialize(ArraySegment <byte> bytes)
 {
     return(Deserialization.ParseInt(bytes));
 }