MongoDB.Driver.MongoCollectionSettings.ToString C# (CSharp) Метод

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

Returns a string representation of the settings.
public ToString ( ) : string
Результат string
        public override string ToString()
        {
            if (_isFrozen)
            {
                return _frozenStringRepresentation;
            }

            return string.Format(
                "{4}AssignIdOnInsert={0};{5}GuidRepresentation={1};ReadPreference={2};WriteConcern={3}",
                _assignIdOnInsert, _guidRepresentation, _readPreference, _writeConcern,
                _collectionName.HasBeenSet ? string.Format("CollectionName={0};", _collectionName.Value) : "",
                _defaultDocumentType.HasBeenSet ? string.Format("DefaultDocumentType={0};", _defaultDocumentType.Value) : "");
        }

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::ToString