Skip to content

GrainExtensions Methods

Extension methods for grains.

AsReference(IAddressable)

staticextension
View source
public static TGrainInterface AsReference<TGrainInterface>(this IAddressable grain)
Returns a typed reference to the provided grain.

Parameters

grainIAddressable
The grain to convert.

Returns

A strongly typed reference to the provided grain which implements TGrainInterface.

AsReference(IAddressable, Type)

staticextension
View source
public static object AsReference(this IAddressable grain, Type interfaceType)
Returns a typed reference to the provided grain.

Parameters

grainIAddressable
The grain to convert.
interfaceTypeType
The type of the grain interface.

Returns

A strongly typed reference to the provided grain which implements interfaceType.

Cast(IAddressable)

staticextension
View source
public static TGrainInterface Cast<TGrainInterface>(this IAddressable grain)
Returns a typed reference to the provided grain.

Parameters

grainIAddressable
The grain to convert.

Returns

A strongly typed reference to the provided grain which implements TGrainInterface.

Cast(IAddressable, Type)

staticextension
View source
public static object Cast(this IAddressable grain, Type interfaceType)
Returns a typed reference to the provided grain.

Parameters

grainIAddressable
The grain to convert.
interfaceTypeType
The type of the grain interface.

Returns

A strongly typed reference to the provided grain which implements interfaceType.

GetGrainId(IAddressable)

staticextension
View source
public static GrainId GetGrainId(this IAddressable grain)
Returns the grain id corresponding to the provided grain.

Parameters

grainIAddressable
The grain

Returns

The grain id corresponding to the provided grain.

Exceptions

System.ArgumentException
The provided value has the wrong type or has no id.

GetPrimaryKey(IAddressable)

staticextension
View source
public static Guid GetPrimaryKey(this IAddressable grain)
Returns the System.Guid representation of a grain primary key.

Parameters

grainIAddressable
The grain to find the primary key for.

Returns

A System.Guid representing the primary key for this grain.

Exceptions

System.InvalidOperationException
The provided grain does not have a System.Guid-based key.

GetPrimaryKey(IAddressable, string?)

staticextension
View source
public static Guid GetPrimaryKey(this IAddressable grain, out string? keyExt)
Returns the System.Guid representation of a grain primary key.

Parameters

grainIAddressable
The grain to find the primary key for.
keyExtstring?
The output parameter to return the extended key part of the grain primary key, if extended primary key was provided for that grain.

Returns

A System.Guid representing the primary key for this grain.

Exceptions

System.InvalidOperationException
The provided grain does not have a System.Guid-based key.

GetPrimaryKeyLong(IAddressable)

staticextension
View source
public static long GetPrimaryKeyLong(this IAddressable grain)
Returns the long representation of a grain primary key.

Parameters

grainIAddressable
The grain to find the primary key for.

Returns

A long representing the primary key for this grain.

Exceptions

System.InvalidOperationException
The provided grain does not have a System.Int64-based key.

GetPrimaryKeyLong(IAddressable, string?)

staticextension
View source
public static long GetPrimaryKeyLong(this IAddressable grain, out string? keyExt)
Returns the long representation of a grain primary key.

Parameters

grainIAddressable
The grain to find the primary key for.
keyExtstring?
The output parameter to return the extended key part of the grain primary key, if extended primary key was provided for that grain.

Returns

A long representing the primary key for this grain.

Exceptions

System.InvalidOperationException
The provided grain does not have a System.Int64-based key.

GetPrimaryKeyString(IAddressable)

staticextension
View source
public static string GetPrimaryKeyString(this IAddressable grain)
Returns the string primary key of the grain.

Parameters

grainIAddressable
The grain to find the primary key for.

Returns

A string representing the primary key for this grain.

IsPrimaryKeyBasedOnLong(IAddressable)

staticextension
View source
public static bool IsPrimaryKeyBasedOnLong(this IAddressable grain)
Returns whether part of the primary key is of type long.

Parameters

grainIAddressable
The target grain.

Exceptions

System.InvalidOperationException
The provided grain does not have a System.Int64-based key.