MongoDB.Driver.MongoClientSettings.GetHashCode C# (CSharp) Метод

GetHashCode() публичный Метод

Gets the hash code.
public GetHashCode ( ) : int
Результат int
        public override int GetHashCode()
        {
            if (_isFrozen)
            {
                return _frozenHashCode;
            }

            // see Effective Java by Joshua Bloch
            int hash = 17;
            hash = 37 * hash + _connectionMode.GetHashCode();
            hash = 37 * hash + _connectTimeout.GetHashCode();
            hash = 37 * hash + _credentialsStore.GetHashCode();
            hash = 37 * hash + ((_defaultCredentials == null) ? 0 : _defaultCredentials.GetHashCode());
            hash = 37 * hash + _guidRepresentation.GetHashCode();
            hash = 37 * hash + _ipv6.GetHashCode();
            hash = 37 * hash + _maxConnectionIdleTime.GetHashCode();
            hash = 37 * hash + _maxConnectionLifeTime.GetHashCode();
            hash = 37 * hash + _maxConnectionPoolSize.GetHashCode();
            hash = 37 * hash + _minConnectionPoolSize.GetHashCode();
            hash = 37 * hash + _readPreference.GetHashCode();
            hash = 37 * hash + ((_replicaSetName == null) ? 0 : _replicaSetName.GetHashCode());
            hash = 37 * hash + _secondaryAcceptableLatency.GetHashCode();
            foreach (var server in _servers)
            {
                hash = 37 * hash + server.GetHashCode();
            }
            hash = 37 * hash + _socketTimeout.GetHashCode();
            hash = 37 * hash + _useSsl.GetHashCode();
            hash = 37 * hash + _verifySslCertificate.GetHashCode();
            hash = 37 * hash + _waitQueueSize.GetHashCode();
            hash = 37 * hash + _waitQueueTimeout.GetHashCode();
            hash = 37 * hash + _writeConcern.GetHashCode();
            return hash;
        }

Usage Example

        public void TestFreeze()
        {
            var settings = new MongoClientSettings();
            settings.ReadPreference = new ReadPreference();
            settings.WriteConcern = new WriteConcern();

            Assert.IsFalse(settings.IsFrozen);
            Assert.IsFalse(settings.CredentialsStore.IsFrozen);
            Assert.IsFalse(settings.ReadPreference.IsFrozen);
            Assert.IsFalse(settings.WriteConcern.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.IsTrue(settings.CredentialsStore.IsFrozen);
            Assert.IsTrue(settings.ReadPreference.IsFrozen);
            Assert.IsTrue(settings.WriteConcern.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());
        }
All Usage Examples Of MongoDB.Driver.MongoClientSettings::GetHashCode