Download Procedure for Calling C# PER Encode Methods

Transcript
Chapter 3. Generated C# Source Code
Overview
A separate C# source file with extension ‘.cs’ is generated for each production encountered within an ASN.1 source
file. Every ASN.1 type is mapped to a C# class. This is true even at the lowest levels – types such as BOOLEAN,
INTEGER, and NULL all have wrapper classes.
The following items may be present in a generated C# file:
• Using statements
• Namespace specification
• Class declaration
• A tag constant object declaration
• Public member variables
• Constructors
• Public Decode() method
• Public Encode() method
• Other methods
• Inner SAX Handler class (XER only)
Additional specialized items may be present as well depending on the base type of the target production. These
specialized items are discussed in the sections on ASN.1 to C# mappings for the various ASN.1 types.
A complete generated C# source file for the ‘EmployeeNumber’ production within the production within the ASN.1
sample file ‘employee.asn’ can be found on the following page. The ASN.1 production from which this file was
generated is as follows:
EmployeeNumber ::= [APPLICATION 2] IMPLICIT INTEGER
The generated code is as follows:
using System;
using Com.Objsys.Asn1.Runtime;
namespace Test {
public class EmployeeNumber : Asn1Integer {
public new readonly static Asn1Tag _TAG =
new Asn1Tag (Asn1Tag.APPL, Asn1Tag.PRIM, 2);
public EmployeeNumber () : base()
{
}
public EmployeeNumber (long value_) : base(value_)
31