首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenIso8583.Net在模板中添加了一点

OpenIso8583.Net在模板中添加了一点
EN

Stack Overflow用户
提问于 2020-03-24 04:13:00
回答 1查看 73关注 0票数 0

这个库几年前就被移走了,我找到的维基链接已经过时了。

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

我需要添加什么才能使127位正常工作?

代码语言:javascript
复制
 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。

EN

回答 1

Stack Overflow用户

发布于 2020-03-24 23:13:25

这段代码可以工作。实际上可能没有必要添加CreateField覆盖。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60820917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档