Class IdentifierCollection
- Namespace
- combit.Reporting
- Assembly
- combit.ListLabel31.CrossPlatform.dll
Represents a collection of identifiers, each associated with an ExpressionValue. This class allows for adding, removing, and accessing values by key, and supports reverting to previous values.
public class IdentifierCollection : IDictionary<string, ExpressionValue>, ICollection<KeyValuePair<string, ExpressionValue>>, IEnumerable<KeyValuePair<string, ExpressionValue>>, IEnumerable, IDisposable
- Inheritance
-
IdentifierCollection
- Implements
- Inherited Members
Constructors
IdentifierCollection(ListLabel, ILogger?, string)
Initializes a new instance of the IdentifierCollection class with the specified parent.
public IdentifierCollection(ListLabel parent, ILogger? logger, string collectionId)
Parameters
parentListLabelThe ListLabel instance that owns this identifier collection.
loggerILoggerThe logger to be used for logging messages.
collectionIdstringThe id of the logger, used for logging messages.
Properties
Count
Gets the number of key-value pairs contained in the active dictionary.
public int Count { get; }
Property Value
IsReadOnly
Gets a value indicating whether the identifier collection is read-only.
public bool IsReadOnly { get; }
Property Value
this[string]
public ExpressionValue this[string key] { get; set; }
Parameters
keystring
Property Value
Keys
Gets a collection containing the keys in the active dictionary.
public ICollection<string> Keys { get; }
Property Value
Values
Gets a collection containing the values in the active dictionary.
public ICollection<ExpressionValue> Values { get; }
Property Value
Methods
Add(KeyValuePair<string, ExpressionValue>)
Adds an item to the ICollection<T>.
public void Add(KeyValuePair<string, ExpressionValue> item)
Parameters
itemKeyValuePair<string, ExpressionValue>The object to add to the ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Add(string, object)
Adds a new identifier and associated value to the collection.
public virtual void Add(string name, object value)
Parameters
namestringThe key to associate with the value.
valueobjectThe value to associate with the key, which will be converted to an ExpressionValue.
Exceptions
- ListLabelException
Thrown if the collection is in revert mode.
Add(string, object?, LlFieldType)
Adds a new identifier and associated value with a specified field type to the collection.
public virtual void Add(string name, object? value, LlFieldType fieldType)
Parameters
namestringThe key to associate with the value.
valueobjectThe value to associate with the key.
fieldTypeLlFieldTypeThe combit.Reporting.LlFieldType that defines how the value should be interpreted.
Exceptions
- ListLabelException
Thrown if the collection is in revert mode.
Add(string, ExpressionValue)
Adds the specified key-value pair to the collection.
public void Add(string key, ExpressionValue value)
Parameters
keystringThe key to add.
valueExpressionValueThe ExpressionValue to associate with the key.
Exceptions
- ListLabelException
Thrown if the collection is in revert mode.
AddFromInterface(ITableRow)
Adds values from an ITableRow to the collection, using the table name as a prefix.
public virtual void AddFromInterface(ITableRow value)
Parameters
Remarks
AddFromInterface(ITableRow) does not take 1:1 relations into consideration. If those are required use DefineData(IDataProvider, ITableRow)instead.
AddFromInterface(ITableRow, string)
Adds values from an ITableRow to the collection, using the specified prefix.
public virtual void AddFromInterface(ITableRow value, string prefix)
Parameters
valueITableRowThe ITableRow whose values are to be added.
prefixstringThe prefix to apply to all added keys.
Remarks
AddFromInterface(ITableRow, string) does not take 1:1 relations into consideration. If those are required use DefineData(IDataProvider, ITableRow)instead.
AddFromObject(string, object)
public virtual void AddFromObject(string prefix, object value)
Parameters
prefixstringThe prefix for the property or field names of the object.
valueobjectThe object whose properties or fields are to be added to the collection.
Exceptions
- ListLabelException
Thrown if the object type is unsupported.
AddFromObject(string, object, bool)
Adds values from an object to the collection, optionally limiting to only browsable properties. The object cannot be a DataTable or DataSet.
public virtual void AddFromObject(string prefix, object value, bool onlyBrowsableProperties)
Parameters
prefixstringThe prefix for the property or field names of the object.
valueobjectThe object whose properties or fields are to be added to the collection.
onlyBrowsablePropertiesboolIndicates whether to add only properties marked as browsable.
Clear()
Removes all items from the ICollection<T>.
public void Clear()
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Contains(KeyValuePair<string, ExpressionValue>)
Determines whether the ICollection<T> contains a specific value.
public bool Contains(KeyValuePair<string, ExpressionValue> item)
Parameters
itemKeyValuePair<string, ExpressionValue>The object to locate in the ICollection<T>.
Returns
- bool
true if
itemis found in the ICollection<T>; otherwise, false.
ContainsKey(string)
Determines whether the IDictionary<TKey, TValue> contains an element with the specified key.
public bool ContainsKey(string key)
Parameters
keystringThe key to locate in the IDictionary<TKey, TValue>.
Returns
- bool
true if the IDictionary<TKey, TValue> contains an element with the key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.
ContainsMissingIdentifiers()
Checks if there are any missing identifiers present. Logs ans returns true if there are missing identifiers, otherwise false.
public bool ContainsMissingIdentifiers()
Returns
- bool
A boolean indicating the presence of missing identifiers.
CopyTo(KeyValuePair<string, ExpressionValue>[], int)
Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.
public void CopyTo(KeyValuePair<string, ExpressionValue>[] array, int arrayIndex)
Parameters
arrayKeyValuePair<string, ExpressionValue>[]The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.
arrayIndexintThe zero-based index in
arrayat which copying begins.
Exceptions
- ArgumentNullException
arrayis null.- ArgumentOutOfRangeException
arrayIndexis less than 0.- ArgumentException
The number of elements in the source ICollection<T> is greater than the available space from
arrayIndexto the end of the destinationarray.
CreateSnapshot()
Creates a snapshot of the current object state.
public ShortGuid CreateSnapshot()
Returns
- ShortGuid
A combit.Reporting.Helpers.ShortGuid that uniquely identifies the created snapshot.
DefineData(IDataProvider, ITableRow)
Passes the columns of a data row and (recursively) its 1:1-related rows from other tables as either fields or variables.
public void DefineData(IDataProvider dataSource, ITableRow row)
Parameters
dataSourceIDataProviderThe data provider to use.
rowITableRowThe table row to define.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<KeyValuePair<string, ExpressionValue>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<string, ExpressionValue>>
An enumerator that can be used to iterate through the collection.
Remove(KeyValuePair<string, ExpressionValue>)
Removes the first occurrence of a specific object from the ICollection<T>.
public bool Remove(KeyValuePair<string, ExpressionValue> item)
Parameters
itemKeyValuePair<string, ExpressionValue>The object to remove from the ICollection<T>.
Returns
- bool
true if
itemwas successfully removed from the ICollection<T>; otherwise, false. This method also returns false ifitemis not found in the original ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Remove(string)
Removes the element with the specified key from the IDictionary<TKey, TValue>.
public bool Remove(string key)
Parameters
keystringThe key of the element to remove.
Returns
- bool
true if the element is successfully removed; otherwise, false. This method also returns false if
keywas not found in the original IDictionary<TKey, TValue>.
Exceptions
- ArgumentNullException
keyis null.- NotSupportedException
The IDictionary<TKey, TValue> is read-only.
RemoveSnapshot(ShortGuid)
Removes a previously created snapshot, releasing any resources associated with it.
public void RemoveSnapshot(ShortGuid id)
Parameters
idShortGuidThe combit.Reporting.Helpers.ShortGuid identifying the snapshot to remove.
ResetToSnapshot(ShortGuid, bool)
Restores the object state to a previously created snapshot and optionally removes the associated snapshot.
public void ResetToSnapshot(ShortGuid id, bool removeSnapshot = true)
Parameters
idShortGuidThe combit.Reporting.Helpers.ShortGuid identifying the snapshot to restore.
removeSnapshotboolIf
true, removes the snapshot after restoring; otherwise, retains the snapshot.
TryGetValue(string, out ExpressionValue)
Gets the value associated with the specified key.
public bool TryGetValue(string key, out ExpressionValue value)
Parameters
keystringThe key whose value to get.
valueExpressionValueWhen this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the
valueparameter. This parameter is passed uninitialized.
Returns
- bool
true if the object that implements IDictionary<TKey, TValue> contains an element with the specified key; otherwise, false.
Exceptions
- ArgumentNullException
keyis null.