HashByteArray() static private method

static private HashByteArray ( byte rgbValue, int length ) : int
rgbValue byte
length int
return int
Exemplo n.º 1
0
        // For hashing purpose
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override int GetHashCode()
        {
            if (IsNull)
            {
                return(0);
            }

            byte[] rgbSortKey;
            if (FBinarySort())
            {
                rgbSortKey = x_UnicodeEncoding.GetBytes(m_value.TrimEnd());
            }
            else
            {
                // VSDevDiv 479660
                //  GetHashCode should not throw just because this instance has an invalid LCID or compare options.
                CompareInfo    cmpInfo;
                CompareOptions options;
                try {
                    SetCompareInfo();
                    cmpInfo = m_cmpInfo;
                    options = CompareOptionsFromSqlCompareOptions(m_flag);
                }
                catch (ArgumentException) {
                    // SetCompareInfo throws this when instance's LCID is unsupported
                    // CompareOptionsFromSqlCompareOptions throws this when instance's options are invalid
                    cmpInfo = CultureInfo.InvariantCulture.CompareInfo;
                    options = CompareOptions.None;
                }
                rgbSortKey = cmpInfo.GetSortKey(m_value.TrimEnd(), options).KeyData;
            }

            return(SqlBinary.HashByteArray(rgbSortKey, rgbSortKey.Length));
        }
Exemplo n.º 2
0
 public override int GetHashCode()
 {
     byte[] bytes;
     if (this.IsNull)
     {
         return(0);
     }
     if (this.FBinarySort())
     {
         bytes = x_UnicodeEncoding.GetBytes(this.m_value.TrimEnd(new char[0]));
     }
     else
     {
         CompareOptions none;
         System.Globalization.CompareInfo cmpInfo;
         try
         {
             this.SetCompareInfo();
             cmpInfo = this.m_cmpInfo;
             none    = CompareOptionsFromSqlCompareOptions(this.m_flag);
         }
         catch (ArgumentException)
         {
             cmpInfo = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
             none    = CompareOptions.None;
         }
         bytes = cmpInfo.GetSortKey(this.m_value.TrimEnd(new char[0]), none).KeyData;
     }
     return(SqlBinary.HashByteArray(bytes, bytes.Length));
 }