Exemple #1
0
        /// <summary>
        /// Parse BitMap of Message to be Parsed
        /// </summary>
        /// <typeparam name="TMessage">TMessage class, a derived class of BaseMessage class</typeparam>
        /// <param name="message">message instance</param>
        /// <param name="isoMessageBytes">messageBytes</param>
        /// <param name="currentPos">position to Read</param>
        /// <returns>BitMap Value</returns>
        private string ParseBitMap <TMessage>(TMessage message, byte[] isoMessageBytes, ref int currentPos) where TMessage : BaseMessage, new()
        {
            IsoFieldAttribute bitMapIsoField = message.GetIsoFieldByPropName(nameof(BaseMessage.BitMap));
            var bitMap = bitMapIsoField.GetFieldValue(isoMessageBytes, ref currentPos);

            //Second BitMap Exists Read More Data
            if (bitMap.ToBinaryStringFromHex().First() == '1')
            {
                return(bitMap + bitMapIsoField.GetFieldValue(isoMessageBytes, ref currentPos));
            }

            return(bitMap);
        }
Exemple #2
0
        /// <summary>
        /// Parse a byte[] iso Message to an Instance of TMessage
        /// </summary>
        /// <typeparam name="TMessage">TMessage class, a derived class of BaseMessage class</typeparam>
        /// <param name="isoMessageBytes">bytes of received Message</param>
        /// <returns>an Instance of TMessage</returns>
        public TMessage Parse <TMessage>(byte[] isoMessageBytes) where TMessage : BaseMessage, new()
        {
            var currentPosition = 0;
            var messageIntance  = new TMessage();

            IsoFieldAttribute mtiIsoField = messageIntance.GetIsoFieldByPropName(nameof(messageIntance.MTI));

            messageIntance.MTI = mtiIsoField.GetFieldValue(isoMessageBytes, ref currentPosition);

            messageIntance.BitMap = ParseBitMap(messageIntance, isoMessageBytes, ref currentPosition);
            ParseFields(ref messageIntance, isoMessageBytes, currentPosition);
            return(messageIntance);
        }