コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="msgFieldPackager"></param>
        public ISOPackagerLoader(ILogger logger, ref ISOMessageFieldsPackager msgFieldPackager)
        {
            _logger = logger;

            XmlReader reader = null;

            ISOMessageTypesPackager isoMessageTypesPackager = null;

            if (Logger.IsEnabled(LogLevel.Trace))
            {
                Logger.LogTrace("Loading packager definition from build-in resource");
            }

            // load from embeded resource visa.xml

            Stream stream = typeof(ISOPackagerLoader).GetTypeInfo().Assembly.GetManifestResourceStream("ISO8583Net.ISODialects.visa.xml");

            reader = XmlReader.Create(stream);

            while (reader.Read())
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                    case "isopackager":
                        string attribute = reader["totalfields"];
                        m_totalFields  = Int32.Parse(attribute);
                        m_totalFields += 1;
                        break;

                    case "messages":
                        isoMessageTypesPackager = new ISOMessageTypesPackager(Logger, m_totalFields);
                        isoMessageTypesPackager = LoadMessageTypes(reader);
                        break;

                    case "isofields":
                        msgFieldPackager = LoadISOMessageFieldsPackager(reader, 0);
                        msgFieldPackager.SetMessageTypesPackager(isoMessageTypesPackager);
                        msgFieldPackager.SetStorageClass(Type.GetType("ISO8583Net.Field.ISOMessageFields"));
                        break;
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private ISOMessageTypesPackager LoadMessageTypes(XmlReader reader)
        {
            ISOMessageTypesPackager msgTypesPackager = new ISOMessageTypesPackager(_logger, m_totalFields);

            if (reader.ReadToDescendant("message"))
            {
                do
                {
                    ISOMsgTypePackager msgTypeDefinition = new ISOMsgTypePackager(_logger, m_totalFields);

                    // Search for the attribute name on this current node.

                    string attribute = reader["type"];

                    if (attribute != null)
                    {
                        msgTypeDefinition.messageTypeIdentifier = attribute;
                    }

                    attribute = reader["name"];

                    if (attribute != null)
                    {
                        msgTypeDefinition.messageTypeName = attribute;
                    }

                    attribute = reader["desc"];

                    if (attribute != null)
                    {
                        msgTypeDefinition.messageTypeDescription = attribute;
                    }

                    // read the rest of attributes from 0 to total_dialect fields

                    for (int field = 0; field <= m_totalFields; ++field)
                    {
                        string attributeName = "f" + field.ToString("D3");

                        attribute = reader[attributeName];

                        switch (attribute)
                        {
                        case "C":
                            msgTypeDefinition.m_conBitmap.SetBit(field);
                            break;

                        case "M":
                            msgTypeDefinition.m_manBitmap.SetBit(field);
                            break;

                        case "O":
                            msgTypeDefinition.m_optBitmap.SetBit(field);
                            break;

                        default:
                            msgTypeDefinition.m_manBitmap.SetBit(field);

                            msgTypeDefinition.m_optBitmap.SetBit(field);
                            break;
                        }
                    }

                    msgTypesPackager.Add(msgTypeDefinition.messageTypeIdentifier, msgTypeDefinition);
                } while (reader.ReadToNextSibling("message"));
            }

            return(msgTypesPackager);
        }
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="isoMessageTypesPackager"></param>
 public void SetMessageTypesPackager(ISOMessageTypesPackager isoMessageTypesPackager)
 {
     m_isoMsgTypePackager = isoMessageTypesPackager;
 }