Ejemplo n.º 1
0
        internal static SmlMessageBody Create(SmlMessageType a_type, SmlBase a_baseNode)
        {
            switch (a_type)
            {
            case SmlMessageType.OpenResponse:
                return(SmlOpenResponse.Create(a_baseNode));

            case SmlMessageType.CloseResponse:
                return(SmlCloseResponse.Create(a_baseNode));

            case SmlMessageType.GetListResponse:
                return(SmlGetListResponse.Create(a_baseNode));
            }

            return(new SmlMessageBody(a_baseNode));
        }
Ejemplo n.º 2
0
        public override ParseResult ContinuePopulate(byte a_byte)
        {
            var ret = m_tl.ContinuePopulate(a_byte);

            if (ret == ParseResult.MoreBytesNeeded)
            {
                return(ParseResult.MoreBytesNeeded);
            }

            if (ret == ParseResult.Failed)
            {
                return(EndWithFailed());
            }

            SmlList list = m_tl.EndPopulate() as SmlList;

            if (list == null || list.Length != 6)
            {
                return(EndWithFailed());
            }

            m_transactionId = list.GetElement(0) as SmlString;
            if (m_transactionId == null)
            {
                return(EndWithFailed());
            }

            m_groupNo = list.GetElement(1) as SmlUnsigned8;
            if (m_groupNo == null)
            {
                return(EndWithFailed());
            }

            m_abortOnError = list.GetElement(2) as SmlUnsigned8;
            if (m_abortOnError == null)
            {
                return(EndWithFailed());
            }

            var body = list.GetElement(3) as SmlList;

            if (body == null || body.Length != 2)
            {
                return(EndWithFailed());
            }
            var type = body.GetElement(0) as SmlUnsigned32;

            if (type == null || !Enum.IsDefined(typeof(SmlMessageType), type.Value))
            {
                return(EndWithFailed());
            }
            m_messageType = (SmlMessageType)type.Value;
            m_body        = SmlMessageBody.Create(m_messageType, body.GetElement(1));
            if (m_body == null)
            {
                return(EndWithFailed());
            }

            m_crc = list.GetElement(4) as SmlUnsigned16;
            if (m_crc == null)
            {
                return(EndWithFailed());
            }

            var eom = list.GetElement(5) as SmlTypeLengthField;

            if (eom == null || eom.SmlFieldType != SmlFieldType.EndOfMessage)
            {
                return(EndWithFailed());
            }

            m_state = State.Done;
            return(ParseResult.Done);
        }