Class ItemObjectCollection
- Namespace
- EDIParser
- Assembly
- EDIParser.dll
Provides the base implementation for the parser's one-based keyed collections.
public class ItemObjectCollection : IEnumerable
- Inheritance
-
ItemObjectCollection
- Implements
- Derived
- Inherited Members
Remarks
Items are stored in insertion order and may also be associated with string keys. Numeric positional access in derived collections is one-based to preserve the behavior of the original VB implementation.
When IgnoreMissingItem is enabled, an out-of-range or missing-key lookup returns the collection's configured placeholder item.
Properties
Count
Gets the number of items contained in the collection.
public int Count { get; }
Property Value
IgnoreMissingItem
Gets or sets a value indicating whether missing collection items return a placeholder object instead of throwing an exception.
public bool IgnoreMissingItem { get; set; }
Property Value
RawItems
Gets a read-only view of the objects contained in the collection.
protected IReadOnlyList<object> RawItems { get; }
Property Value
Methods
Contains(string)
Determines whether the collection contains the specified key.
public bool Contains(string key)
Parameters
keystringThe key to locate.
Returns
GetByKey(string)
Gets an item using its collection key.
protected object GetByKey(string key)
Parameters
keystringThe key associated with the requested item.
Returns
- object
The item associated with the specified key.
Exceptions
- ArgumentException
Thrown when the key does not exist and IgnoreMissingItem is disabled.
GetByObject(object)
Gets an item by comparing it with the objects contained in the collection.
protected object GetByObject(object index)
Parameters
indexobjectThe object to locate.
Returns
- object
The matching item.
Exceptions
- ArgumentException
Thrown when no matching item is found and IgnoreMissingItem is disabled.
GetByOneBasedIndex(int)
Gets an item using a one-based positional index.
protected object GetByOneBasedIndex(int index)
Parameters
indexintThe one-based index of the item.
Returns
- object
The item at the specified position.
Exceptions
- ArgumentOutOfRangeException
Thrown when
indexis less than one.- ArgumentException
Thrown when the index exceeds the collection size and IgnoreMissingItem is disabled.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator GetEnumerator()
Returns
- IEnumerator
An enumerator for the collection.
TryGetByKey(string, out object?)
Attempts to retrieve an item using its collection key.
protected bool TryGetByKey(string key, out object? item)
Parameters
keystringThe key associated with the requested item.
itemobjectWhen this method returns, contains the matching item or null when the key is not found.