MarkdownObjectDataExtensions Class
Typed helper methods for storing and retrieving data on IMarkdownObject.
public static class MarkdownObjectDataExtensionsMethods
| Name | Description |
|---|---|
| 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.csGets 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
markdownObjectIMarkdownObject- The markdown object.
Returns
T? The stored value if it matches T; otherwise default.
Exceptions
ArgumentNullException- Thrown if
markdownObjectis null.
GetData<T>(IMarkdownObject, DataKey<T>)
MarkdownObjectDataExtensions.csGets 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
markdownObjectIMarkdownObject- The markdown object.
keyDataKey<T>- The typed key to read.
Returns
T? The stored value if it matches T; otherwise default.
Exceptions
ArgumentNullException- Thrown if
markdownObjectorkeyis null.
GetData<T>(IMarkdownObject, object)
MarkdownObjectDataExtensions.csGets the data associated with the specified key.
public static T? GetData<T>(this IMarkdownObject markdownObject, object key)Type parameters
T- Expected data type.
Parameters
markdownObjectIMarkdownObject- The markdown object.
keyobject- The key to read.
Returns
T? The stored value if it matches T; otherwise default.
Exceptions
ArgumentNullException- Thrown if
markdownObjectorkeyis null.
SetData overloads
SetData<T>(IMarkdownObject, DataKey<T>, T)
MarkdownObjectDataExtensions.csSets 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
markdownObjectIMarkdownObject- The markdown object.
keyDataKey<T>- The typed key to write.
valueT- The value to store.
Exceptions
ArgumentNullException- Thrown if
markdownObjectorkeyis null.
SetData<T>(IMarkdownObject, T)
MarkdownObjectDataExtensions.csSets data on the conventional type key (typeof(T)).
public static void SetData<T>(this IMarkdownObject markdownObject, T value)Type parameters
T- Value type.
Parameters
markdownObjectIMarkdownObject- The markdown object.
valueT- The value to store.
Exceptions
ArgumentNullException- Thrown if
markdownObjectis null.
TryGetData overloads
TryGetData<T>(IMarkdownObject, DataKey<T>, T?)
MarkdownObjectDataExtensions.csTries 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
markdownObjectIMarkdownObject- The markdown object.
keyDataKey<T>- The typed key to read.
valueT?- The output value if found and type-compatible.
Returns
bool true if the value exists and matches T; otherwise false.
Exceptions
ArgumentNullException- Thrown if
markdownObjectorkeyis null.
TryGetData<T>(IMarkdownObject, object, T?)
MarkdownObjectDataExtensions.csTries 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
markdownObjectIMarkdownObject- The markdown object.
keyobject- The key to read.
valueT?- The output value if found and type-compatible.
Returns
bool true if the value exists and matches T; otherwise false.
Exceptions
ArgumentNullException- Thrown if
markdownObjectorkeyis null.