Example #1
0
        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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        static string IdentityOf(IGrain grain)
        {
            string identity;

            grain.GetPrimaryKeyLong(out identity);
            return(identity);
        }
Example #4
0
 /// <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;
 }