Skip to content

Utils Methods

The Utils class contains a variety of utility methods for use in application and grain code.

DictionaryToString(ICollection<KeyValuePair<T1, T2>>, Func<T2, string?>, string?)

static
View source
public static string DictionaryToString<T1, T2>(ICollection<KeyValuePair<T1, T2>> dict, Func<T2, string?>? toString = null, string? separator = null)
Returns a human-readable text string that describes a dictionary that maps objects to objects.

Parameters

dictICollection<KeyValuePair<T1, T2>>
The dictionary to describe.
toStringFunc<T2, string?>
Converts the element to a string. If none specified, System.Object.ToString will be used.
separatorstring?
The separator to use. If none specified, the elements should appear separated by a new line.

Returns

A string assembled by wrapping the string descriptions of the individual pairs with square brackets and separating them with commas. Each key-value pair is represented as the string description of the key followed by the string description of the value, separated by " -> ", and enclosed in curly brackets.

EnumerableToString(IEnumerable<T>, Func<T, string>, string, bool)

static
View source
public static string EnumerableToString<T>(IEnumerable<T>? collection, Func<T, string>? toString = null, string separator = ", ", bool putInBrackets = true)
Returns a human-readable text string that describes an IEnumerable collection of objects.

Parameters

collectionIEnumerable<T>
The IEnumerable to describe.
toStringFunc<T, string>
Converts the element to a string. If none specified, System.Object.ToString will be used.
separatorstring
The separator to use.
putInBracketsbool
Puts elements within brackets

Returns

A string assembled by wrapping the string descriptions of the individual elements with square brackets and separating them with commas.

ToGatewayAddress(Uri)

staticextension
View source
public static SiloAddress? ToGatewayAddress(this Uri uri)
Parse a Uri as a Silo address, excluding the generation identifier.

Parameters

uriUri
The input Uri

ToGatewayUri(IPEndPoint)

staticextension
View source
public static Uri ToGatewayUri(this IPEndPoint ep)
Represent an IP end point in the gateway URI format..

Parameters

epIPEndPoint
The input IP end point

ToGatewayUri(SiloAddress)

staticextension
View source
public static Uri ToGatewayUri(this SiloAddress address)
Represent a silo address in the gateway URI format.

Parameters

addressSiloAddress
The input silo address

ToIPEndPoint(Uri)

staticextension
View source
public static IPEndPoint? ToIPEndPoint(this Uri uri)
Parse a Uri as an IPEndpoint.

Parameters

uriUri
The input Uri