Exemplo n.º 1
0
        private void ReadDefinition(ref ISOMessageFieldsPackager msgFieldPackager, XmlReader reader)
        {
            ISOMessageTypesPackager isoMessageTypesPackager = null;
            string headerPackager = null;

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

                    case "messages":
                        isoMessageTypesPackager = LoadMessageTypes(reader);
                        break;

                    case "isofields":
                        msgFieldPackager = LoadISOMessageFieldsPackager(reader, 0);
                        msgFieldPackager.HeaderPackager = headerPackager;
                        msgFieldPackager.SetMessageTypesPackager(isoMessageTypesPackager);
                        msgFieldPackager.SetStorageClass(Type.GetType("ISO8583Net.Field.ISOMessageFields"));
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="fileName"></param>
        /// <param name="msgFieldPackager"></param>
        public ISOPackagerLoader(ILogger logger, string fileName, ref ISOMessageFieldsPackager msgFieldPackager)
        {
            _logger = logger;

            XmlReader reader = null;

            ISOMessageTypesPackager isoMessageTypesPackager = null;

            if (File.Exists(fileName))
            {
                if (Logger.IsEnabled(LogLevel.Trace))
                {
                    Logger.LogTrace("Loading packager definition from [" + fileName + "]");
                }

                reader = XmlReader.Create(fileName);
            }
            else
            {
                Logger.LogError(string.Format("Filename [{0}] does not exist", fileName));

                throw new Exception(string.Format("Filename[{0}] does not exist", fileName));
            }

            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.ISOMessageFields"));
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
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;
                    }
                }
            }
        }