src/Orleans.Core.Abstractions/Core/GrainExtensions.cs
/// <summary>
/// Returns the grain id corresponding to the provided grain.
/// </summary>
/// <param name="grain">The grain</param>
/// <returns>The grain id corresponding to the provided grain.</returns>
/// <exception cref="ArgumentException">The provided value has the wrong type or has no id.</exception>
Returns the grain id corresponding to the provided grain.
Returns the grain id corresponding to the provided grain .
public static GrainId GetGrainId(this IAddressable grain)
        {
            var grainId = grain switch
            {
                Grain grainBase => grainBase.GrainId,
                GrainReference grainReference => grainReference.GrainId,
                IGrainBase grainActivation => grainActivation.GrainContext.GrainId,
                ISystemTargetBase systemTarget => systemTarget.GrainId,
                _ => throw new ArgumentException(GetWrongGrainTypeErrorMessage(grain), nameof(grain))
            };
            if (grainId.IsDefault)
            {
                throw new ArgumentException(WRONG_GRAIN_ERROR_MSG, nameof(grain));
            }
            return grainId;
        }
public static GrainId GetGrainId ( this IAddressable grain ) { var grainId = grain switch { Grain grainBase => grainBase . GrainId , GrainReference grainReference => grainReference . GrainId , IGrainBase grainActivation => grainActivation . GrainContext . GrainId , ISystemTargetBase systemTarget => systemTarget . GrainId , _ => throw new ArgumentException ( GetWrongGrainTypeErrorMessage ( grain ) , nameof ( grain ) ) } ; if ( grainId . IsDefault ) { throw new ArgumentException ( WRONG_GRAIN_ERROR_MSG , nameof ( grain ) ) ; } return grainId ; }
Returns the grain id corresponding to the provided grain.
Returns the grain id corresponding to the provided grain .
The grain id corresponding to the provided grain.
The grain id corresponding to the provided grain .
The provided value has the wrong type or has no id.
The provided value has the wrong type or has no id .
IAddressable
this
grain
None