Table of Contents

Class ValueIndexer

Namespace
EDIParser
Assembly
EDIParser.dll

Provides indexer-based access to values contained within a parser, segment, field, component, or repetition.

public sealed class ValueIndexer
Inheritance
ValueIndexer
Inherited Members

Remarks

A ValueIndexer is associated with exactly one object level when it is created. The available indexer overloads depend on that object level.

Element paths use period-delimited positions such as PID.3.1 or REF.2.1.0.1. Segment, field, component, repetition, and subcomponent identifiers are interpreted by EDIParser.PathNavigator.

Properties

this[int]

Gets or sets the value of a specified field repetition.

public string this[int fieldRepetitionIndex] { get; set; }

Parameters

fieldRepetitionIndex int

The one-based field-repetition index.

Property Value

string

The value of the specified field repetition.

Exceptions

ArgumentException

Thrown when setting a value through an indexer that is not associated with a field.

IndexOutOfRangeException

Thrown when the repetition index is outside the field's supported range.

this[int, string]

Gets or sets a value in a specified occurrence of a matching segment.

public string this[int segmentIndex, string element] { get; set; }

Parameters

segmentIndex int

The one-based occurrence of the segment identified by the element path.

element string

The period-delimited EDI element path identifying the requested value.

Property Value

string

The value identified by the segment occurrence and element path.

Remarks

The segment index is relative to segments having the segment name specified by the first part of element. It is not the absolute position in the complete segment collection.

Exceptions

ArgumentException

Thrown when setting a value through an indexer that is not associated with a parser, or when the element path is empty.

IndexOutOfRangeException

Thrown when segmentIndex is less than one while setting a value.

this[int, string, int]

Gets or sets a value in a specified segment occurrence and field repetition.

public string this[int segmentIndex, string element, int fieldRepetitionIndex] { get; set; }

Parameters

segmentIndex int

The one-based occurrence of the segment identified by the element path.

element string

The period-delimited EDI element path identifying the requested value.

fieldRepetitionIndex int

The one-based field-repetition position.

Property Value

string

The value identified by the segment occurrence, element path, and field repetition.

Exceptions

ArgumentException

Thrown when setting a value through an indexer that is not associated with a parser, or when the element path is empty.

IndexOutOfRangeException

Thrown when either index is less than one while setting a value.

this[string]

Gets or sets a value using an EDI element path.

public string this[string element] { get; set; }

Parameters

element string

The period-delimited EDI element path identifying the requested value.

Property Value

string

The value identified by the element path.

Remarks

When associated with a parser, this indexer accesses the first matching segment and the first field repetition.

When associated with a segment, field, component, or repetition, the element path is resolved relative to that object.

Setting a value is supported only when the indexer is associated with a parser.

Exceptions

ArgumentException

Thrown when setting a value through an indexer that is not associated with a parser, or when the element path is empty.

this[string, int]

Gets a nested value from a specified field repetition or sets the value of that repetition.

public string this[string element, int fieldRepetitionIndex] { get; set; }

Parameters

element string

The period-delimited element path identifying the nested value.

fieldRepetitionIndex int

The one-based field-repetition index.

Property Value

string

The nested value identified by the element path and field repetition.

Remarks

The getter resolves the supplied element path. The setter assigns the complete value of the specified field repetition.

Exceptions

ArgumentException

Thrown when setting a value through an indexer that is not associated with a field.

IndexOutOfRangeException

Thrown when the repetition index is outside the field's supported range.

Events

AddSegment

Occurs when setting a value causes a new segment to be added to a parser.

public event Action<object, int, Segment>? AddSegment

Event Type

Action<object, int, Segment>

Remarks

The event arguments contain the event sender, the one-based position of the added segment, and the newly created segment.