Language

SlackModel Class

Definition

Base class for Slack model objects that expose dot-notation path navigation via Get<T>(String) and TryGet<T>(String, T).

public abstract class SlackModel
type SlackModel = class
Public MustInherit Class SlackModel
Inheritance
SlackModel
Derived

Remarks

Subclasses that are plain POCOs (e.g. SlackResponse, EventEnvelope) rely on the default GetData() implementation, which lazily serializes the instance to a JsonObject on first use so every field β€” including [JsonExtensionData] catch-alls β€” is reachable by path. Subclasses that are themselves backed by a JsonObject (e.g. EventContent) override GetData() to return that object directly, avoiding redundant serialization.

Subclasses whose JSON field names differ from their C# property names (e.g. EventEnvelope maps "event_content" β†’ "event") override NormalizePath(String) to remap the alias before navigation.

Constructors

Name Description
SlackModel()

Methods

Name Description
Get<T>(String)

Gets a value at the given dot-notation path. Supports dot-separated property access and bracket array indexing (e.g. "message.attachments[0].text"). Returns default when the path does not exist or the value cannot be converted to T.

GetData()

Returns the JsonObject used for path navigation. The default implementation lazily serializes this instance via JsonSerializer.SerializeToNode, making every property and [JsonExtensionData] field addressable. Override when the subclass is already backed by a JsonObject to return it directly.

NormalizePath(String)

Normalizes a caller-supplied path before it is passed to the navigator. Override to remap C# property-name aliases to their JSON field names. The default implementation returns the path unchanged.

TryGet<T>(String, T)

Tries to get a value at the given dot-notation path. Returns false when the path does not exist or the value cannot be converted to T.

Applies to