Class DataPointCounter
Provides utility methods for counting data points by their source within complex object graphs. This class uses reflection to traverse object hierarchies and identify DataPoint<T> instances, aggregating counts by their associated SourceAttribute.
Inherited Members
Namespace: IAI.DT.DataModel.Utilities
Assembly: IAI.DT.DataModel.dll
Syntax
public static class DataPointCounter
Remarks
This utility is primarily used for billing and auditing purposes to track the number of data points consumed from different data sources during operations. It handles circular references and complex nested structures including collections.
Methods
CountDataPointsBySource(object)
Counts all DataPoint<T> instances within an object graph, grouped by their source. Uses reflection to recursively traverse the object hierarchy, including nested objects and collections.
Declaration
public static List<(string Point, string Source)> CountDataPointsBySource(this object instance)
Parameters
| Type | Name | Description |
|---|---|---|
| object | instance | The object instance to count data points within. |
Returns
| Type | Description |
|---|---|
| List<(string Point, string Source)> | A dictionary where keys are source names (from SourceAttribute) and values are the count of data points from that source. |
Remarks
This method:
- Traverses all public and non-public fields and properties
- Handles circular references to prevent infinite loops
- Processes collections and nested objects recursively
- Only counts DataPoint instances that have a SourceAttribute