Class Sealed
public sealed class ParsedTable

Namespace: SharpMeter.Core.Tables

A fully deserialized PSEM table with named, typed fields.

Properties

NameDescription
Definition Gets the table definition used for parsing.
Description Gets the table description.
DisplayName Gets the table display name (e.g., "ST1").
Fields Gets the parsed fields in order.
RawData Gets the raw table data.

Definition

TableDefinition ParsedTable.Definition { get; init; }

Gets the table definition used for parsing.

Description

string ParsedTable.Description { get; }

Gets the table description.

DisplayName

string ParsedTable.DisplayName { get; }

Gets the table display name (e.g., "ST1").

Fields

ImmutableArray<ParsedTableField> ParsedTable.Fields { get; init; }

Gets the parsed fields in order.

RawData

ReadOnlyMemory<byte> ParsedTable.RawData { get; init; }

Gets the raw table data.

Methods

NameDescription
GetField(string fieldName) Gets a parsed field by name.
GetValue(string fieldName) Gets the display value of a field by name.

GetField(string fieldName)

ParsedTableField? ParsedTable.GetField(string fieldName)

Gets a parsed field by name.

Parameters

NameTypeDescription
fieldNamestringThe field name to find.

Returns: The parsed field, or null if not found.

GetValue(string fieldName)

string? ParsedTable.GetValue(string fieldName)

Gets the display value of a field by name.

Parameters

NameTypeDescription
fieldNamestringThe field name to find.

Returns: The display value, or null if not found.

View Source
/// <summary>
///     A fully deserialized PSEM table with named, typed fields.
/// </summary>
public sealed class ParsedTable
{
#region Properties
    /// <summary>Gets the table definition used for parsing.</summary>
    public required TableDefinition Definition { get; init; }
    /// <summary>Gets the raw table data.</summary>
    public required ReadOnlyMemory<byte> RawData { get; init; }
    /// <summary>Gets the parsed fields in order.</summary>
    public required ImmutableArray<ParsedTableField> Fields { get; init; }
    /// <summary>Gets the table display name (e.g., "ST1").</summary>
    public string DisplayName => Definition.DisplayName;
    /// <summary>Gets the table description.</summary>
    public string Description => Definition.Description;

#endregion
#region Methods
    /// <summary>
    ///     Gets a parsed field by name.
    /// </summary>
    /// <param name = "fieldName">The field name to find.</param>
    /// <returns>The parsed field, or null if not found.</returns>
    public ParsedTableField? GetField(string fieldName) => Fields.FirstOrDefault(f => f.Definition.Name.Equals(fieldName, StringComparison.Ordinal));
    /// <summary>
    ///     Gets the display value of a field by name.
    /// </summary>
    /// <param name = "fieldName">The field name to find.</param>
    /// <returns>The display value, or null if not found.</returns>
    public string? GetValue(string fieldName) => GetField(fieldName)?.DisplayValue;
#endregion
}
Was this page helpful?