예제 #1
0
        internal static long ComposeGenericTypeCode(Type interfaceType, int baseTypeCode)
        {
            if (!interfaceType.IsGenericType)
            {
                return(baseTypeCode);
            }

            string args = TypeUtils.GetGenericTypeArgs(interfaceType.GetGenericArguments(), t => true);
            int    hash = Utils.CalculateIdHash(args);

            return((((long)(hash & 0x00FFFFFF)) << 32) + baseTypeCode);
        }
예제 #2
0
 internal long GetTypeCode(Type interfaceType)
 {
     if (interfaceType.IsGenericType && this.IsGeneric)
     {
         string args = TypeUtils.GetGenericTypeArgs(interfaceType.GetGenericArguments(), t => true);
         int    hash = Utils.CalculateIdHash(args);
         return((((long)(hash & 0x00FFFFFF)) << 32) + GrainTypeCode);
     }
     else
     {
         return(GrainTypeCode);
     }
 }
예제 #3
0
        /// <summary>Get a consistent hash value for this silo address.</summary>
        /// <returns>Consistent hash value for this silo address.</returns>
        public int GetConsistentHashCode()
        {
            if (hashCodeSet)
            {
                return(hashCode);
            }

            // Note that Port cannot be used because Port==0 matches any non-zero Port value for .Equals
            string siloAddressInfoToHash = Endpoint + Generation.ToString(CultureInfo.InvariantCulture);

            hashCode    = Utils.CalculateIdHash(siloAddressInfoToHash);
            hashCodeSet = true;
            return(hashCode);
        }