TOC PREV NEXT INDEX


SEQUENCE OF



The ASN.1 SEQUENCE OF type is converted to a C# class that inherits the Asn1Type run-time base class. An array public member variable named elements is generated to hold the elements of the defined type.

The following shows the basic mapping from ASN.1 type to C# class definition:
ASN.1 Production:
<name> ::= SEQUENCE OF <type>
 
Generated C# class:

public class <name> : Asn1Type {
 
   public <type>[] elements
 

 
   public <type> () {
 
      elements = null;
 
   }
 
   public <type> (int numRecords) {
 
      elements = new <type> [numRecords];
 
   }
 
   public override void Decode () { ... }
 
   public override int  Encode () { ... }
 
   public override void Print () { ... }
 
}
 



The compiler first generates a public member variable to hold the SEQUENCE OF elements. The decision was made to make the variable public to make it easier to populate for encoding. The alternative was to use protected or private variables with get/set methods for setting or examining the values. It was felt that this approach would be too cumbersome for setting values in deeply nested constructed types.

Two constructors are generated: a default constructor and a constructor that takes a number of elements argument. The default constructor will set the elements variable to null. The second constructor will allocate space for the given number of elements. The recommended way to populate a variable of this type for encoding is to use the second form of the constructor to allocate the required number of elements and then directly set the element object values. For example, to populate the following construct:

	IntSeq ::= SEQUENCE OF INTEGER 
 

with 3 integers, the following code could be used:

	IntSeq intSeq = new IntSeq (3);
 
	intSeq.elements[0] = new Asn1Integer (1);
 
	intSeq.elements[1] = new Asn1Integer (2);
 
	intSeq.elements[2] = new Asn1Integer (3);
 

Note that each of the integer element values is wrapped in an Asn1Integer wrapper class.


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

Copyright © 1997-2005 Objective Systems,Inc.
All Rights Reserved.


This document may be distributed in any form, electronic
or otherwise, provided that it is distributed in its entirety
and that the copyright and this notice are included.