Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetState<T>() method #208

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Abstractions/Entities/TaskEntityOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public abstract class TaskEntityOperation
/// </summary>
public abstract bool HasInput { get; }

/// <summary>
/// Gets the input for this operation.
/// </summary>
/// <typeparam name="T">The type to deserialize the input as.</typeparam>
/// <returns>The deserialized input type.</returns>
public virtual T? GetInput<T>() => (T?)this.GetInput(typeof(T));

/// <summary>
/// Gets the input for this operation.
/// </summary>
Expand Down
12 changes: 10 additions & 2 deletions src/Abstractions/Entities/TaskEntityState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ namespace Microsoft.DurableTask.Entities;
public abstract class TaskEntityState
{
/// <summary>
/// Gets the current state for the entity this context is for. This will return <c>null</c> if no state is present,
/// regardless if <paramref name="type"/> is a value-type or not.
/// Gets the current state of the entity. This will return <c>null</c> if no state is present, regardless if
/// <typeparamref name="T"/> is a value-type or not.
/// </summary>
/// <typeparam name="T">The type to retrieve.</typeparam>
/// <returns>The entity state.</returns>
public virtual T? GetState<T>() => (T?)this.GetState(typeof(T));

/// <summary>
/// Gets the current state of the entity. This will return <c>null</c> if no state is present, regardless if
/// <paramref name="type"/> is a value-type or not.
/// </summary>
/// <param name="type">The type to retrieve the state as.</param>
/// <returns>The entity state.</returns>
Expand Down
Loading