MarkdownObjectDataExtensions Class

Typed helper methods for storing and retrieving data on IMarkdownObject.

public static class MarkdownObjectDataExtensions

Methods

NameDescription
GetData<T>(IMarkdownObject)Gets the data associated with the conventional type key (typeof(T)).
GetData<T>(IMarkdownObject, DataKey<T>)Gets the data associated with the specified typed key.
GetData<T>(IMarkdownObject, object)Gets the data associated with the specified key.
SetData<T>(IMarkdownObject, DataKey<T>, T)Sets data on the specified typed key.
SetData<T>(IMarkdownObject, T)Sets data on the conventional type key (typeof(T)).
TryGetData<T>(IMarkdownObject, DataKey<T>, T?)Tries to get the data associated with the specified typed key.
TryGetData<T>(IMarkdownObject, object, T?)Tries to get the data associated with the specified key.

GetData overloads

GetData<T>(IMarkdownObject)

MarkdownObjectDataExtensions.cs

Gets the data associated with the conventional type key (typeof(T)).

public static T? GetData<T>(this IMarkdownObject markdownObject)
Type parameters
T
Expected data type.
Parameters
markdownObject IMarkdownObject
The markdown object.
Returns

T? The stored value if it matches T; otherwise default.

Exceptions
ArgumentNullException
Thrown if markdownObject is null.

GetData<T>(IMarkdownObject, DataKey<T>)

MarkdownObjectDataExtensions.cs

Gets the data associated with the specified typed key.

public static T? GetData<T>(this IMarkdownObject markdownObject, DataKey<T> key)
Type parameters
T
Expected data type.
Parameters
markdownObject IMarkdownObject
The markdown object.
key DataKey<T>
The typed key to read.
Returns

T? The stored value if it matches T; otherwise default.

Exceptions
ArgumentNullException
Thrown if markdownObject or key is null.

GetData<T>(IMarkdownObject, object)

MarkdownObjectDataExtensions.cs

Gets the data associated with the specified key.

public static T? GetData<T>(this IMarkdownObject markdownObject, object key)
Type parameters
T
Expected data type.
Parameters
markdownObject IMarkdownObject
The markdown object.
key object
The key to read.
Returns

T? The stored value if it matches T; otherwise default.

Exceptions
ArgumentNullException
Thrown if markdownObject or key is null.

SetData overloads

SetData<T>(IMarkdownObject, DataKey<T>, T)

MarkdownObjectDataExtensions.cs

Sets data on the specified typed key.

public static void SetData<T>(this IMarkdownObject markdownObject, DataKey<T> key, T value)
Type parameters
T
Value type.
Parameters
markdownObject IMarkdownObject
The markdown object.
key DataKey<T>
The typed key to write.
value T
The value to store.
Exceptions
ArgumentNullException
Thrown if markdownObject or key is null.

SetData<T>(IMarkdownObject, T)

MarkdownObjectDataExtensions.cs

Sets data on the conventional type key (typeof(T)).

public static void SetData<T>(this IMarkdownObject markdownObject, T value)
Type parameters
T
Value type.
Parameters
markdownObject IMarkdownObject
The markdown object.
value T
The value to store.
Exceptions
ArgumentNullException
Thrown if markdownObject is null.

TryGetData overloads

TryGetData<T>(IMarkdownObject, DataKey<T>, T?)

MarkdownObjectDataExtensions.cs

Tries to get the data associated with the specified typed key.

public static bool TryGetData<T>(this IMarkdownObject markdownObject, DataKey<T> key, out T? value)
Type parameters
T
Expected data type.
Parameters
markdownObject IMarkdownObject
The markdown object.
key DataKey<T>
The typed key to read.
value T?
The output value if found and type-compatible.
Returns

bool true if the value exists and matches T; otherwise false.

Exceptions
ArgumentNullException
Thrown if markdownObject or key is null.

TryGetData<T>(IMarkdownObject, object, T?)

MarkdownObjectDataExtensions.cs

Tries to get the data associated with the specified key.

public static bool TryGetData<T>(this IMarkdownObject markdownObject, object key, out T? value)
Type parameters
T
Expected data type.
Parameters
markdownObject IMarkdownObject
The markdown object.
key object
The key to read.
value T?
The output value if found and type-compatible.
Returns

bool true if the value exists and matches T; otherwise false.

Exceptions
ArgumentNullException
Thrown if markdownObject or key is null.