/// <summary> /// /// </summary> /// <param name="isoHeader"></param> /// <param name="packedBytes"></param> /// <param name="index"></param> public override void Pack(ISOHeader isoHeader, byte[] packedBytes, ref int index) { ISOHeaderTITP terminalHeader = (ISOHeaderTITP)isoHeader; terminalHeader.Payload.CopyTo(packedBytes, index); index += terminalHeader.Payload.Length; }
/// <summary> /// /// </summary> /// <param name="isoHeader"></param> /// <param name="packedBytes"></param> /// <param name="index"></param> public override void UnPack(ISOHeader isoHeader, ReadOnlySpan <byte> packedBytes, ref int index) { if (Logger.IsEnabled(LogLevel.Information)) { Logger.LogInformation("Unpacking TITP Header"); } ISOHeaderTITP terminalHeader = (ISOHeaderTITP)isoHeader; int length = terminalHeader.Payload.Length; packedBytes.Slice(index, length).CopyTo(terminalHeader.Payload); index += length; }
/// <summary> /// /// </summary> /// <param name="headerPackagerName"></param> /// <param name="logger"></param> /// <returns></returns> public static (ISOHeader Header, ISOHeaderPackager Packager) GetMessageHeaderAndPackager(string headerPackagerName, ILogger logger) { ISOHeader header; ISOHeaderPackager packager; switch (headerPackagerName) { case "ISOHeaderTITPPackager": packager = new ISOHeaderTITPPackager(logger); header = new ISOHeaderTITP(logger); break; case "ISOHeaderVisaPackager": packager = new ISOHeaderVisaPackager(logger); header = new ISOHeaderVisa(logger); break; default: throw new ArgumentException($"Invalid header packager name: {headerPackagerName}"); } return(header, packager); }