/* 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
{
///
/// Base class for implementors of .
///
/// The type of the document.
public abstract class MongoIndexManagerBase : IMongoIndexManager
{
// public properties
///
public abstract CollectionNamespace CollectionNamespace { get; }
///
public abstract IBsonSerializer DocumentSerializer { get; }
///
public abstract MongoCollectionSettings Settings { get; }
// public methods
///
[Obsolete("Use CreateOne with a CreateIndexModel instead.")]
public virtual string CreateOne(IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
var model = new CreateIndexModel(keys, options);
var result = CreateMany(new[] { model }, cancellationToken);
return result.Single();
}
///
public virtual string CreateOne(
CreateIndexModel model,
CreateOneIndexOptions options = null,
CancellationToken cancellationToken = default(CancellationToken))
{
var createManyIndexOptions = ToCreateManyIndexesOptions(options);
var result = CreateMany(new[] { model }, createManyIndexOptions, cancellationToken);
return result.Single();
}
///
[Obsolete("Use CreateOne with a CreateIndexModel instead.")]
public virtual string CreateOne(IClientSessionHandle session, IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
var model = new CreateIndexModel(keys, options);
var result = CreateMany(session, new[] { model }, cancellationToken);
return result.Single();
}
///
public virtual string CreateOne(
IClientSessionHandle session,
CreateIndexModel model,
CreateOneIndexOptions options = null,
CancellationToken cancellationToken = default(CancellationToken))
{
var createManyIndexOptions = ToCreateManyIndexesOptions(options);
var result = CreateMany(session, new[] { model }, createManyIndexOptions, cancellationToken);
return result.Single();
}
///
[Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")]
public virtual async Task CreateOneAsync(IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
var model = new CreateIndexModel(keys, options);
var result = await CreateManyAsync(new[] { model }, cancellationToken).ConfigureAwait(false);
return result.Single();
}
///
public virtual async Task CreateOneAsync(
CreateIndexModel 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();
}
///
[Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")]
public virtual async Task CreateOneAsync(IClientSessionHandle session, IndexKeysDefinition keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
var model = new CreateIndexModel(keys, options);
var result = await CreateManyAsync(session, new[] { model }, cancellationToken).ConfigureAwait(false);
return result.Single();
}
///
public virtual async Task CreateOneAsync(
IClientSessionHandle session,
CreateIndexModel 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();
}
///
public virtual IEnumerable CreateMany(IEnumerable> models, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual IEnumerable CreateMany(
IEnumerable> models,
CreateManyIndexesOptions options,
CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual IEnumerable CreateMany(IClientSessionHandle session, IEnumerable> models, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual IEnumerable CreateMany(IClientSessionHandle session, IEnumerable> models, CreateManyIndexesOptions options,
CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual Task> CreateManyAsync(IEnumerable> models, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual Task> CreateManyAsync(IEnumerable> models, CreateManyIndexesOptions options,
CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual Task> CreateManyAsync(IClientSessionHandle session, IEnumerable> models, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual Task> CreateManyAsync(
IClientSessionHandle session,
IEnumerable> models,
CreateManyIndexesOptions options,
CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual void DropAll(DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual void DropAll(CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual void DropAll(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual void DropAll(IClientSessionHandle session, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual Task DropAllAsync(DropIndexOptions options, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
///
public abstract Task DropAllAsync(CancellationToken cancellationToken = default(CancellationToken));
///
public virtual Task DropAllAsync(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual Task DropAllAsync(IClientSessionHandle session, DropIndexOptions options, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
///
public virtual void DropOne(string name, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual void DropOne(string name, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual void DropOne(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual void DropOne(IClientSessionHandle session, string name, DropIndexOptions options, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
///
public abstract Task DropOneAsync(string name, CancellationToken cancellationToken = default(CancellationToken));
///
public virtual Task DropOneAsync(string name, DropIndexOptions options, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual Task DropOneAsync(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual Task DropOneAsync(IClientSessionHandle session, string name, DropIndexOptions options, CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
///
public virtual IAsyncCursor List(CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public virtual IAsyncCursor List( IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
///
public abstract Task> ListAsync(CancellationToken cancellationToken = default(CancellationToken));
///
public virtual Task> ListAsync(IClientSessionHandle session, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}
private CreateManyIndexesOptions ToCreateManyIndexesOptions(CreateOneIndexOptions options)
{
return new CreateManyIndexesOptions { MaxTime = options?.MaxTime };
}
}
}