| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- /* Copyright 2010-present MongoDB Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using MongoDB.Bson;
- using MongoDB.Bson.Serialization;
- namespace MongoDB.Driver
- {
- /// <summary>
- /// Base class for implementors of <see cref="IMongoIndexManager{TDocument}"/>.
- /// </summary>
- /// <typeparam name="TDocument">The type of the document.</typeparam>
- public abstract class MongoIndexManagerBase<TDocument> : IMongoIndexManager<TDocument>
- {
- // public properties
- /// <inheritdoc />
- public abstract CollectionNamespace CollectionNamespace { get; }
- /// <inheritdoc />
- public abstract IBsonSerializer<TDocument> DocumentSerializer { get; }
- /// <inheritdoc />
- public abstract MongoCollectionSettings Settings { get; }
- // public methods
- /// <inheritdoc />
- [Obsolete("Use CreateOne with a CreateIndexModel instead.")]
- public virtual string CreateOne(IndexKeysDefinition<TDocument> keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- var model = new CreateIndexModel<TDocument>(keys, options);
- var result = CreateMany(new[] { model }, cancellationToken);
- return result.Single();
- }
- /// <inheritdoc />
- public virtual string CreateOne(
- CreateIndexModel<TDocument> model,
- CreateOneIndexOptions options = null,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- var createManyIndexOptions = ToCreateManyIndexesOptions(options);
- var result = CreateMany(new[] { model }, createManyIndexOptions, cancellationToken);
- return result.Single();
- }
- /// <inheritdoc />
- [Obsolete("Use CreateOne with a CreateIndexModel instead.")]
- public virtual string CreateOne(IClientSessionHandle session, IndexKeysDefinition<TDocument> keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- var model = new CreateIndexModel<TDocument>(keys, options);
- var result = CreateMany(session, new[] { model }, cancellationToken);
- return result.Single();
- }
-
- /// <inheritdoc />
- public virtual string CreateOne(
- IClientSessionHandle session,
- CreateIndexModel<TDocument> model,
- CreateOneIndexOptions options = null,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- var createManyIndexOptions = ToCreateManyIndexesOptions(options);
- var result = CreateMany(session, new[] { model }, createManyIndexOptions, cancellationToken);
- return result.Single();
- }
- /// <inheritdoc />
- [Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")]
- public virtual async Task<string> CreateOneAsync(IndexKeysDefinition<TDocument> keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- var model = new CreateIndexModel<TDocument>(keys, options);
- var result = await CreateManyAsync(new[] { model }, cancellationToken).ConfigureAwait(false);
- return result.Single();
- }
- /// <inheritdoc />
- public virtual async Task<string> CreateOneAsync(
- CreateIndexModel<TDocument> model,
- CreateOneIndexOptions options = null,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- var createManyIndexOptions = ToCreateManyIndexesOptions(options);
- var result = await CreateManyAsync(new[] { model }, createManyIndexOptions, cancellationToken).ConfigureAwait(false);
- return result.Single();
- }
- /// <inheritdoc />
- [Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")]
- public virtual async Task<string> CreateOneAsync(IClientSessionHandle session, IndexKeysDefinition<TDocument> keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
- {
- var model = new CreateIndexModel<TDocument>(keys, options);
- var result = await CreateManyAsync(session, new[] { model }, cancellationToken).ConfigureAwait(false);
- return result.Single();
- }
- /// <inheritdoc />
- public virtual async Task<string> CreateOneAsync(
- IClientSessionHandle session,
- CreateIndexModel<TDocument> model,
- CreateOneIndexOptions options = null,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- var createManyIndexOptions = ToCreateManyIndexesOptions(options);
- var result = await CreateManyAsync(session, new[] { model }, createManyIndexOptions, cancellationToken).ConfigureAwait(false);
- return result.Single();
- }
- /// <inheritdoc />
- public virtual IEnumerable<string> CreateMany(IEnumerable<CreateIndexModel<TDocument>> models, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual IEnumerable<string> CreateMany(
- IEnumerable<CreateIndexModel<TDocument>> models,
- CreateManyIndexesOptions options,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual IEnumerable<string> CreateMany(IClientSessionHandle session, IEnumerable<CreateIndexModel<TDocument>> models, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual IEnumerable<string> CreateMany(IClientSessionHandle session, IEnumerable<CreateIndexModel<TDocument>> models, CreateManyIndexesOptions options,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual Task<IEnumerable<string>> CreateManyAsync(IEnumerable<CreateIndexModel<TDocument>> models, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual Task<IEnumerable<string>> CreateManyAsync(IEnumerable<CreateIndexModel<TDocument>> models, CreateManyIndexesOptions options,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual Task<IEnumerable<string>> CreateManyAsync(IClientSessionHandle session, IEnumerable<CreateIndexModel<TDocument>> models, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual Task<IEnumerable<string>> CreateManyAsync(
- IClientSessionHandle session,
- IEnumerable<CreateIndexModel<TDocument>> models,
- CreateManyIndexesOptions options,
- CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual void DropAll(DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual void DropAll(CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual void DropAll(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual void DropAll(IClientSessionHandle session, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual Task DropAllAsync(DropIndexOptions options, CancellationToken cancellationToken)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public abstract Task DropAllAsync(CancellationToken cancellationToken = default(CancellationToken));
- /// <inheritdoc />
- public virtual Task DropAllAsync(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual Task DropAllAsync(IClientSessionHandle session, DropIndexOptions options, CancellationToken cancellationToken)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual void DropOne(string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual void DropOne(string name, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual void DropOne(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual void DropOne(IClientSessionHandle session, string name, DropIndexOptions options, CancellationToken cancellationToken)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public abstract Task DropOneAsync(string name, CancellationToken cancellationToken = default(CancellationToken));
- /// <inheritdoc />
- public virtual Task DropOneAsync(string name, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual Task DropOneAsync(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual Task DropOneAsync(IClientSessionHandle session, string name, DropIndexOptions options, CancellationToken cancellationToken)
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual IAsyncCursor<BsonDocument> List(CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public virtual IAsyncCursor<BsonDocument> List( IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- /// <inheritdoc />
- public abstract Task<IAsyncCursor<BsonDocument>> ListAsync(CancellationToken cancellationToken = default(CancellationToken));
- /// <inheritdoc />
- public virtual Task<IAsyncCursor<BsonDocument>> ListAsync(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken))
- {
- throw new NotImplementedException();
- }
- private CreateManyIndexesOptions ToCreateManyIndexesOptions(CreateOneIndexOptions options)
- {
- return new CreateManyIndexesOptions { MaxTime = options?.MaxTime };
- }
- }
- }
|