TOC PREV NEXT INDEX


ENUMERATED



The ASN.1 ENUMERATED type is converted into a C# class that inherits the Asn1Enumerated run-time class. This base class encapsulates the following public member variable:

    public int mValue;
 

This value is populated with one of the enumerated constant values that are generated by the compiler and added to the C# source file.

The following shows the basic mapping from ASN.1 type to C# class definition:

ASN.1 Production:
<name> ::= ENUMERATED { <e1>, <e2>, ..., <en> }


 
Generated C# class:

public class <name> : Asn1Enumerated {
 
   public const int  <e1> = <v1>;
 
   public const int  <e2> = <v2>;
 
   ...
 
   public const int  <en> = <vn>;
 

 
   public <name> () :
 
      base() {
 
   }
 
   public <name> (int value_) {
 
      base (value_) {
 
   }
 
   public override void Decode () { <code> }
 
   public override int  Encode () { <code> }
 
   public override void Print () { <code> }
 
}


 



Notes:


In the case of the enumerated type, encode/decode methods are always generated. These verify that the given value is within the defined set. An Asn1InvalidEnumException is thrown if the value is not in the defined set.

If an extensibility marker (...) is present in the ASN.1 definition, it will not affect the generated constants. A constant will be generated for all options - both root and extended. If the definition ends in a ... (what we call an `open extension'), then the generated decode function will be modified to not throw an Asn1InvalidEnumException. Instead, if the value is not in the defined set, it will set the value to the built-in base class constant Asn1Enumerated.UNDEFINED.

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