TOC PREV NEXT INDEX


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:


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_)
 
      {
 
      }
 

 
      public override void Decode
 
         (Asn1BerDecodeBuffer buffer, bool explicitTagging, int implicitLength)
 
      {
 
         int llen = (explicitTagging) ?
 
            MatchTag (buffer, _TAG) : implicitLength;
 

 
         base.Decode (buffer, false, llen);
 

 
      }
 

 
      public override int Encode 
 
	(Asn1BerEncodeBuffer buffer, bool explicitTagging)
 
      {
 
         int _aal = base.Encode (buffer, false);
 

 
         if (explicitTagging) {
 
            _aal += buffer.EncodeTagAndLength (_TAG, _aal);
 
         }
 

 
         return (_aal);
 
      }
 

 
   }
 
}
 


The following sections discuss the various sections of the generated C# source file.


Objective Systems, Inc.

102 Pickering Way, Suite #506
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX