Exemplo n.º 1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ClassName != null ? ClassName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AsString != null ? AsString.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Image != null ? Image.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Hash;
         hashCode = (hashCode * 397) ^ IsTrue.GetHashCode();
         return(hashCode);
     }
 }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            switch (Tag)
            {
            case SymbolTag.Atom: return(AsAtom.GetHashCode());

            case SymbolTag.Number: return(AsNumber.GetHashCode());

            case SymbolTag.String: return(AsString.GetHashCode());

            case SymbolTag.Quote: return(AsQuote.GetHashCode());

            case SymbolTag.Symbols: return(AsSymbols.Aggregate(0, (hash, symbol) => hash ^ symbol.GetHashCode()));

            default: throw new InexhausiveException();
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public override int GetHashCode()
        {
            switch (Type)
            {
            case LdValueType.Null:
                return(0);

            case LdValueType.Bool:
                return(AsBool.GetHashCode());

            case LdValueType.Number:
                return(AsFloat.GetHashCode());

            case LdValueType.String:
                return(AsString.GetHashCode());

            case LdValueType.Array:
            {
                var h = new HashCodeBuilder();
                foreach (var item in AsList(Convert.Json))
                {
                    h = h.With(item);
                }
                return(h.Value);
            }

            case LdValueType.Object:
            {
                var h    = new HashCodeBuilder();
                var d    = AsDictionary(Convert.Json);
                var keys = d.Keys.ToArray();
                Array.Sort(keys);         // inefficient, but ensures determinacy
                foreach (var key in keys)
                {
                    h = h.With(key).With(d[key]);
                }
                return(h.Value);
            }

            default:
                return(0);
            }
        }
Exemplo n.º 4
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (bodyTypeCase_ == BodyTypeOneofCase.AsBytes)
            {
                hash ^= AsBytes.GetHashCode();
            }
            if (bodyTypeCase_ == BodyTypeOneofCase.AsString)
            {
                hash ^= AsString.GetHashCode();
            }
            if (Truncated != false)
            {
                hash ^= Truncated.GetHashCode();
            }
            hash ^= (int)bodyTypeCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }