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
Methods
BuildOrchestrationState(OrchestrationRuntimeState)
Builds a new OrchestrationState from the supplied OrchestrationRuntimeState
public static OrchestrationState BuildOrchestrationState(OrchestrationRuntimeState runtimeState)
Parameters
runtimeState
OrchestrationRuntimeState
Returns
DelayWithCancellation(TimeSpan, CancellationToken)
Delay for a specified period of time with support for cancellation.
public static Task DelayWithCancellation(TimeSpan timeout, CancellationToken cancellationToken)
Parameters
timeout
TimeSpanThe amount of time to delay.
cancellationToken
CancellationTokenToken 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
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
stringoperation
stringnumberOfAttempts
intdelayInAttemptsSecs
int
Returns
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
stringoperation
stringnumberOfAttempts
intdelayInAttemptsSecs
int
Returns
- Task<T>
Type Parameters
T
GetCompressedStream(Stream)
Caller disposes the returned stream
public static Stream GetCompressedStream(Stream input)
Parameters
input
Stream
Returns
GetDecompressedStreamAsync(Stream)
Caller disposes the returned stream
public static Task<Stream> GetDecompressedStreamAsync(Stream input)
Parameters
input
Stream
Returns
IsExecutionAborting(Exception)
Returns true if an exception represents an aborting execution; false otherwise.
public static bool IsExecutionAborting(Exception exception)
Parameters
exception
Exception
Returns
IsFatal(Exception)
Returns true or false whether an exception is considered fatal
public static bool IsFatal(Exception exception)
Parameters
exception
Exception
Returns
IsGzipStream(Stream)
Returns true or false whether the supplied stream is a compressed stream
public static bool IsGzipStream(Stream stream)
Parameters
stream
Stream
Returns
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
stringconverter
DataConverter
Returns
SerializeCause(Exception, DataConverter)
Serializes the supplied exception to a string
public static string SerializeCause(Exception originalException, DataConverter converter)
Parameters
originalException
Exceptionconverter
DataConverter
Returns
Truncate(string, int)
Extension method to truncate a string to the supplied length
public static string Truncate(this string input, int maxLength)
Parameters
Returns
UnusedParameter(object)
NoOp utility method
public static void UnusedParameter(object parameter)
Parameters
parameter
objectThe parameter.
WriteObjectToStream(Stream, object)
Serializes and appends the supplied object to the supplied stream
public static void WriteObjectToStream(Stream objectStream, object obj)
Parameters
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)