Example #1
0
 public static Int64 GetHashKey64(this String obj)
 {
     fixed(char *c = obj)
     {
         return((long)HashHandle64.ComputeHashCode((byte *)c, obj.Length * sizeof(char), 0));
     }
 }
Example #2
0
        public static Int64 GetValueTypeHashKey64(object obj)
        {
            if (obj is IUnique)
            {
                return(((IUnique)obj).KeyBlock);
            }

            Type t = obj.GetType();

            if (t.IsPrimitive)
            {
                byte *ps = stackalloc byte[8];
                Marshal.StructureToPtr(obj, (IntPtr)ps, false);
                return(*(long *)ps);
            }

            if (obj is DateTime)
            {
                return(((DateTime)obj).ToBinary());
            }
            if (obj is Enum)
            {
                return(Convert.ToInt32(obj));
            }

            if (t.IsLayoutSequential)
            {
                byte *ps = stackalloc byte[8];
                ExtractOperation.ValueStructureToPointer(obj, ps, 0);
                return(*(long *)ps);
            }


            return((long)HashHandle64.ComputeHashCode(obj.GetBytes()));
        }
Example #3
0
 public static Int64 GetHashKey64(this IList obj)
 {
     if (obj is Byte[])
     {
         return(GetHashKey64((Byte[])obj));
     }
     return((long)HashHandle64.ComputeHashCode(obj.GetBytes()));
 }
Example #4
0
 public static Byte[] GetHashBytes64(this Object obj)
 {
     if (obj is ValueType)
     {
         return(GetValueTypeHashBytes64(obj));
     }
     if (obj is string)
     {
         return((((string)obj)).GetHashBytes64());
     }
     if (obj is IList)
     {
         return(GetHashBytes64((IList)obj));
     }
     return(HashHandle64.ComputeHash(obj.GetBytes()));
 }
Example #5
0
 public static Int64 GetHashKey64(this Object obj)
 {
     if (obj is ValueType)
     {
         return(GetValueTypeHashKey64(obj));
     }
     if (obj is IUnique)
     {
         return(((IUnique)obj).KeyBlock);
     }
     if (obj is string)
     {
         return((((string)obj)).GetHashKey64());
     }
     if (obj is IList)
     {
         return(GetHashKey64((IList)obj));
     }
     return((long)HashHandle64.ComputeHashCode(obj.GetBytes()));
 }
Example #6
0
        public static Byte[] GetValueTypeHashBytes64(object obj)
        {
            if (obj is IUnique)
            {
                return(((IUnique)obj).GetKeyBytes());
            }

            if (obj.GetType().IsPrimitive)
            {
                byte[] s = new byte[8];
                fixed(byte *ps = s)
                {
                    Marshal.StructureToPtr(obj, (IntPtr)ps, false);
                    return(s);
                }
            }

            if (obj is DateTime)
            {
                return(((DateTime)obj).ToBinary().GetBytes());
            }
            if (obj is Enum)
            {
                return(Convert.ToInt32(obj).GetBytes());
            }

            if (obj.GetType().IsLayoutSequential)
            {
                byte[] s = new byte[8];
                fixed(byte *ps = s)
                {
                    ExtractOperation.ValueStructureToPointer(obj, ps, 0);
                    return(s);
                }
            }

            return(((long)HashHandle64.ComputeHashCode(obj.GetBytes())).GetBytes());
        }
Example #7
0
 public static Byte[] GetHashBytes64(this Byte[] bytes)
 {
     return(HashHandle64.ComputeHash(bytes));
 }
Example #8
0
 public static Byte[] GetHashBytes64(this String obj)
 {
     fixed(char *c = obj)
     return(HashHandle64.ComputeHash((byte *)c, obj.Length * sizeof(char), 0));
 }
Example #9
0
 public static Int64 GetHashKey64(this Byte[] bytes)
 {
     return((long)HashHandle64.ComputeHashCode(bytes));
 }
Example #10
0
 public static Byte[] GetHashBytes64(this IList obj)
 {
     return(HashHandle64.ComputeHash(obj.GetBytes()));
 }
Example #11
0
 public override unsafe UInt64 ComputeHashCode(byte[] bytes)
 {
     return(HashHandle64.ComputeHashCode(bytes));
 }
Example #12
0
 public override unsafe UInt64 ComputeHashCode(byte *bytes, int length, uint seed = 0)
 {
     return(HashHandle64.ComputeHashCode(bytes, length, 0));
 }
Example #13
0
 public override unsafe Byte[] ComputeHash(byte[] bytes)
 {
     return(HashHandle64.ComputeHash(bytes));
 }
Example #14
0
 public override unsafe Byte[] ComputeHash(byte *bytes, int length, uint seed = 0)
 {
     return(HashHandle64.ComputeHash(bytes, length, 0));
 }