AddCode

Namespace: Digi21.DigiNG.DigiTab
Assembly: Digi21.DigiNG

Adds a code to the code table.

public void AddCode(NodeDigiTab code)

Parameters

Parameter Description
code NodeDigiTab created using its constructor.

Notes

AddCode assigns the code the code table's first style and its import and export format translation parameters, appends the code and reorders the table.

After the call, code is read-only: assigning one of its properties throws InvalidOperationException. To modify the added code, retrieve it again using the this[string] indexer or Codes.

AddCode does not check whether the table already has a code with that name. To avoid duplicating the code, check whether the name exists using HasCode before adding it.

The code is added to the table in memory. To save the table, call Write.

Exceptions

Exception When
InvalidOperationException The code table is not modifiable, for example the one returned by DigiNG.DigiTab.
ArgumentException code has already been added to a code table using AddCode.
NullReferenceException code is null.

AddCode does not throw ArgumentException for a NodeDigiTab obtained from Codes or the indexer of another modifiable table: that code becomes part of both tables at once. To copy a code from one table to another, create a new NodeDigiTab and copy its properties.

Example

The complete example is in NodeDigiTab.