public static string LoggingIdentifier(this IGrain grain) { var type = grain.GetType(); try { string temp = null; if (typeof(IGrainWithIntegerKey).IsAssignableFrom(type)) { return($"[{grain.GetPrimaryKeyLong()}] "); } else if (typeof(IGrainWithIntegerCompoundKey).IsAssignableFrom(type)) { var key = grain.GetPrimaryKeyLong(out temp); return($"[{key} {temp}] "); } else if (typeof(IGrainWithGuidKey).IsAssignableFrom(type)) { return($"[{grain.GetPrimaryKey()}] "); } else if (typeof(IGrainWithGuidCompoundKey).IsAssignableFrom(type)) { var key = grain.GetPrimaryKey(out temp); return($"[{key} {temp}] "); } else if (typeof(IGrainWithStringKey).IsAssignableFrom(type)) { return($"[{grain.GetPrimaryKeyString()}] "); } } catch { } // Don't throw for logging methods. return(string.Empty); }
/// <summary> /// Returns runtime identity of the given grain /// </summary> /// <param name="grain">Runtime grain instance</param> /// <returns>Id assigned to the grain</returns> public static string Of(IGrain grain) { string id; grain.GetPrimaryKeyLong(out id); return(id); }
static string IdentityOf(IGrain grain) { string identity; grain.GetPrimaryKeyLong(out identity); return(identity); }
/// <summary> /// Returns runtime identity of the given grain /// </summary> /// <param name="grain">Runtime grain instance</param> /// <returns>Id assigned to the grain</returns> public static string Of(IGrain grain) { string id; grain.GetPrimaryKeyLong(out id); return id; }