Table of Contents

Class Utils

Namespace
DurableTask.Core.Common
Assembly
DurableTask.Core.dll

Utility Methods

public static class Utils
Inheritance
Utils
Inherited Members

Fields

DateTimeSafeMaxValue

Gets a safe maximum datetime value that accounts for timezone

public static readonly DateTime DateTimeSafeMaxValue

Field Value

DateTime

Methods

BuildOrchestrationState(OrchestrationRuntimeState)

Builds a new OrchestrationState from the supplied OrchestrationRuntimeState

public static OrchestrationState BuildOrchestrationState(OrchestrationRuntimeState runtimeState)

Parameters

runtimeState OrchestrationRuntimeState

Returns

OrchestrationState

DelayWithCancellation(TimeSpan, CancellationToken)

Delay for a specified period of time with support for cancellation.

public static Task DelayWithCancellation(TimeSpan timeout, CancellationToken cancellationToken)

Parameters

timeout TimeSpan

The amount of time to delay.

cancellationToken CancellationToken

Token for cancelling the delay.

Returns

Task

A task which completes when either the timeout expires or the cancellation token is triggered.

EscapeJson(string)

Escapes the supplied input

public static string EscapeJson(string inputJson)

Parameters

inputJson string

Returns

string

ExecuteWithRetries(Func<Task>, string, string, int, int)

Executes the supplied action until successful or the supplied number of attempts is reached

public static Task ExecuteWithRetries(Func<Task> retryAction, string sessionId, string operation, int numberOfAttempts, int delayInAttemptsSecs)

Parameters

retryAction Func<Task>
sessionId string
operation string
numberOfAttempts int
delayInAttemptsSecs int

Returns

Task

ExecuteWithRetries<T>(Func<Task<T>>, string, string, int, int)

Executes the supplied action until successful or the supplied number of attempts is reached

public static Task<T> ExecuteWithRetries<T>(Func<Task<T>> retryAction, string sessionId, string operation, int numberOfAttempts, int delayInAttemptsSecs)

Parameters

retryAction Func<Task<T>>
sessionId string
operation string
numberOfAttempts int
delayInAttemptsSecs int

Returns

Task<T>

Type Parameters

T

GetCompressedStream(Stream)

Caller disposes the returned stream

public static Stream GetCompressedStream(Stream input)

Parameters

input Stream

Returns

Stream

GetDecompressedStreamAsync(Stream)

Caller disposes the returned stream

public static Task<Stream> GetDecompressedStreamAsync(Stream input)

Parameters

input Stream

Returns

Task<Stream>

IsExecutionAborting(Exception)

Returns true if an exception represents an aborting execution; false otherwise.

public static bool IsExecutionAborting(Exception exception)

Parameters

exception Exception

Returns

bool

IsFatal(Exception)

Returns true or false whether an exception is considered fatal

public static bool IsFatal(Exception exception)

Parameters

exception Exception

Returns

bool

IsGzipStream(Stream)

Returns true or false whether the supplied stream is a compressed stream

public static bool IsGzipStream(Stream stream)

Parameters

stream Stream

Returns

bool

ReadBytesFromStream(Stream)

Reads bytes from the supplied stream

public static byte[] ReadBytesFromStream(Stream objectStream)

Parameters

objectStream Stream

Returns

byte[]

ReadObjectFromByteArray<T>(byte[])

Deserializes an Object from the supplied bytes

public static T ReadObjectFromByteArray<T>(byte[] serializedBytes)

Parameters

serializedBytes byte[]

Returns

T

Type Parameters

T

ReadObjectFromStream<T>(Stream)

Reads and deserializes an Object from the supplied stream

public static T ReadObjectFromStream<T>(Stream objectStream)

Parameters

objectStream Stream

Returns

T

Type Parameters

T

RetrieveCause(string, DataConverter)

Retrieves the exception from a previously serialized exception

public static Exception RetrieveCause(string details, DataConverter converter)

Parameters

details string
converter DataConverter

Returns

Exception

SerializeCause(Exception, DataConverter)

Serializes the supplied exception to a string

public static string SerializeCause(Exception originalException, DataConverter converter)

Parameters

originalException Exception
converter DataConverter

Returns

string

Truncate(string, int)

Extension method to truncate a string to the supplied length

public static string Truncate(this string input, int maxLength)

Parameters

input string
maxLength int

Returns

string

UnusedParameter(object)

NoOp utility method

public static void UnusedParameter(object parameter)

Parameters

parameter object

The parameter.

WriteObjectToStream(Stream, object)

Serializes and appends the supplied object to the supplied stream

public static void WriteObjectToStream(Stream objectStream, object obj)

Parameters

objectStream Stream
obj object

WriteStringToStream(string, bool, out long)

Writes the supplied string input to a MemoryStream, optionally compressing the string, returns the stream

public static Stream WriteStringToStream(string input, bool compress, out long originalStreamSize)

Parameters

input string
compress bool
originalStreamSize long

Returns

Stream