MongoDB.Driver.MongoCollectionSettings.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 + ((_collectionName.Value == null) ? 0 : _collectionName.Value.GetHashCode());
            hash = 37 * hash + _assignIdOnInsert.Value.GetHashCode();
            hash = 37 * hash + ((_defaultDocumentType.Value == null) ? 0 : _defaultDocumentType.Value.GetHashCode());
            hash = 37 * hash + _guidRepresentation.Value.GetHashCode();
            hash = 37 * hash + ((_readPreference.Value == null) ? 0 : _readPreference.Value.GetHashCode());
            hash = 37 * hash + ((_writeConcern.Value == null) ? 0 :_writeConcern.Value.GetHashCode());
            return hash;
        }

Usage Example

        public void TestAll()
        {
            var server = MongoServer.Create();
            var database = server["test"];
            var settings = new MongoCollectionSettings<BsonDocument>(database, "collection")
            {
                AssignIdOnInsert = true,
                SafeMode = SafeMode.Create(5, TimeSpan.FromSeconds(5)),
                SlaveOk = true
            };

            Assert.AreEqual("collection", settings.CollectionName);
            Assert.AreEqual(true, settings.AssignIdOnInsert);
            Assert.AreEqual(typeof(BsonDocument), settings.DefaultDocumentType);
            Assert.AreEqual(GuidRepresentation.CSharpLegacy, settings.GuidRepresentation);
            Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(5)), settings.SafeMode);
            Assert.AreEqual(true, settings.SlaveOk);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode = settings.GetHashCode();
            var stringRepresentation = settings.ToString();
            Assert.AreEqual(settings, settings);

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