【问题标题】:OpenIso8583.Net Adding a bit to the templateOpenIso8583.Net 在模板中添加一点
【发布时间】:2020-03-23 20:13:00
【问题描述】:

该库几年前被移动,我找到的 wiki 链接已过时。

我想将第 127 位添加到 Iso8583 类。我正在使用下面的代码,但程序在从 ToMsg() 调用的 Pack() 方法中死掉了。我不知道在长度字段中输入什么值。该字段是最大长度为 5 的 LLLVAR,那么长度是 5、8 还是 999?所有三个值都会在 Pack() 中引发异常。

我需要添加什么才能让第 127 位工作?

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OpenIso8583Net;
using OpenIso8583Net.FieldValidator;
using OpenIso8583Net.Formatter;
using OpenIso8583Net.LengthFormatters;

namespace MyLink
{

    public class MyIso8583 : Iso8583
    {
        public new class Bit : Iso8583.Bit
        {    
            public const int _127_DISCOVER_VERSION = 127;
        }

        // First you need to customise the template
        // The message 
        private static readonly Template template;


        static MyIso8583()
        {

            // Get the default template for the Iso8583 class
            template = GetDefaultIso8583Template();

            // change template to add bit 127 LLLVAR(5)

            template.Add(Bit._127_DISCOVER_VERSION, FieldDescriptor.AsciiVar(3, 5, FieldValidators.AlphaNumericSpecial));

        }

        // override the base class using the template 
        public MyIso8583() : base(template)
        {

        }

        protected override IField CreateField(int field)
        {

            return base.CreateField(field);
        }

    }
}

编辑 3/24/20:我添加了对 Bit 和 CreateField 的覆盖。我希望新位 127 的行为类似于长度为 5 的默认 LLLVAR。

【问题讨论】:

    标签: iso8583 openiso8583.net


    【解决方案1】:

    此代码有效。实际上可能不需要添加 CreateField 覆盖。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-17
      • 2014-11-14
      • 1970-01-01
      • 2017-10-20
      • 1970-01-01
      相关资源
      最近更新 更多