@@ -196,6 +196,87 @@ public OrchestrationMetadata(string name, string instanceId)
196196 return this . DataConverter . Deserialize < T > ( this . SerializedCustomStatus ) ;
197197 }
198198
199+ /// <summary>
200+ /// Asynchronously deserializes the orchestration's input into an object of the specified type.
201+ /// </summary>
202+ /// <remarks>
203+ /// This method can only be used when inputs and outputs are explicitly requested from the
204+ /// <see cref="DurableTaskClient.GetInstancesAsync(string, CancellationToken)"/> or
205+ /// <see cref="DurableTaskClient.WaitForInstanceCompletionAsync(string, CancellationToken)"/> method that produced
206+ /// this <see cref="OrchestrationMetadata"/> object.
207+ /// </remarks>
208+ /// <typeparam name="T">The type to deserialize the orchestration input into.</typeparam>
209+ /// <param name="cancellationToken">Cancellation token.</param>
210+ /// <returns>Returns the deserialized input value.</returns>
211+ /// <exception cref="InvalidOperationException">
212+ /// Thrown if this metadata object was fetched without the option to read inputs and outputs.
213+ /// </exception>
214+ public async ValueTask < T ? > ReadInputAsAsync < T > ( CancellationToken cancellationToken = default )
215+ {
216+ if ( ! this . RequestedInputsAndOutputs )
217+ {
218+ throw new InvalidOperationException (
219+ $ "The { nameof ( this . ReadInputAsAsync ) } method can only be used on { nameof ( OrchestrationMetadata ) } objects " +
220+ "that are fetched with the option to include input data." ) ;
221+ }
222+
223+ return await this . DataConverter . DeserializeAsync < T > ( this . SerializedInput , cancellationToken ) ;
224+ }
225+
226+ /// <summary>
227+ /// Asynchronously deserializes the orchestration's output into an object of the specified type.
228+ /// </summary>
229+ /// <remarks>
230+ /// This method can only be used when inputs and outputs are explicitly requested from the
231+ /// <see cref="DurableTaskClient.GetInstancesAsync(string, CancellationToken)"/> or
232+ /// <see cref="DurableTaskClient.WaitForInstanceCompletionAsync(string, CancellationToken)"/> method that produced
233+ /// this <see cref="OrchestrationMetadata"/> object.
234+ /// </remarks>
235+ /// <typeparam name="T">The type to deserialize the orchestration output into.</typeparam>
236+ /// <param name="cancellationToken">Cancellation token.</param>
237+ /// <returns>Returns the deserialized output value.</returns>
238+ /// <exception cref="InvalidOperationException">
239+ /// Thrown if this metadata object was fetched without the option to read inputs and outputs.
240+ /// </exception>
241+ public async ValueTask < T ? > ReadOutputAsAsync < T > ( CancellationToken cancellationToken = default )
242+ {
243+ if ( ! this . RequestedInputsAndOutputs )
244+ {
245+ throw new InvalidOperationException (
246+ $ "The { nameof ( this . ReadOutputAsAsync ) } method can only be used on { nameof ( OrchestrationMetadata ) } objects " +
247+ "that are fetched with the option to include output data." ) ;
248+ }
249+
250+ return await this . DataConverter . DeserializeAsync < T > ( this . SerializedOutput , cancellationToken ) ;
251+ }
252+
253+ /// <summary>
254+ /// Asynchronously deserializes the orchestration's custom status value into an object of the specified type.
255+ /// </summary>
256+ /// <remarks>
257+ /// This method can only be used when inputs and outputs are explicitly requested from the
258+ /// <see cref="DurableTaskClient.GetInstancesAsync(string, CancellationToken)"/> or
259+ /// <see cref="DurableTaskClient.WaitForInstanceCompletionAsync(string, CancellationToken)"/> method that produced
260+ /// this <see cref="OrchestrationMetadata"/> object.
261+ /// </remarks>
262+ /// <typeparam name="T">The type to deserialize the orchestration' custom status into.</typeparam>
263+ /// <param name="cancellationToken">Cancellation token.</param>
264+ /// <returns>Returns the deserialized custom status value.</returns>
265+ /// <exception cref="InvalidOperationException">
266+ /// Thrown if this metadata object was fetched without the option to read inputs and outputs.
267+ /// </exception>
268+ public async ValueTask < T ? > ReadCustomStatusAsAsync < T > ( CancellationToken cancellationToken = default )
269+ {
270+ if ( ! this . RequestedInputsAndOutputs )
271+ {
272+ throw new InvalidOperationException (
273+ $ "The { nameof ( this . ReadCustomStatusAsAsync ) } method can only be used on { nameof ( OrchestrationMetadata ) } " +
274+ " objects that are fetched with the option to include input and output data." ) ;
275+ }
276+
277+ return await this . DataConverter . DeserializeAsync < T > ( this . SerializedCustomStatus , cancellationToken ) ;
278+ }
279+
199280 /// <summary>
200281 /// Generates a user-friendly string representation of the current metadata object.
201282 /// </summary>
0 commit comments