private IDataSourceAdapter Create(IMongoDbSourceAdapterConfiguration configuration)
        {
            Guard.NotNull("configuration", configuration);

            if (String.IsNullOrEmpty(configuration.ConnectionString))
            {
                throw Errors.ConnectionStringMissing();
            }

            if (String.IsNullOrEmpty(configuration.Collection))
            {
                throw Errors.CollectionNameMissing();
            }

            if (!String.IsNullOrEmpty(configuration.QueryFile) && !String.IsNullOrEmpty(configuration.Query))
            {
                throw Errors.AmbiguousQuery();
            }

            if (!String.IsNullOrEmpty(configuration.ProjectionFile) && !String.IsNullOrEmpty(configuration.Projection))
            {
                throw Errors.AmbiguousProjection();
            }

            var adapter = new MongoDbSourceAdapter(GetInstanceConfiguration(configuration));

            adapter.Initialize();
            return(adapter);
        }
        /// <summary>
        /// Creates a new instance of <see cref="IDataSourceAdapter" /> with the provided configuration.
        /// </summary>
        /// <param name="configuration">Data source adapter configuration.</param>
        /// <param name="context">Data transfer operation context.</param>
        /// <param name="cancellation">Cancellation token.</param>
        /// <returns>Task that represents asynchronous create operation.</returns>
        public async Task <IDataSourceAdapter> CreateAsync(IMongoDbSourceAdapterConfiguration configuration, IDataTransferContext context, CancellationToken cancellation)
        {
            Guard.NotNull("configuration", configuration);

            if (String.IsNullOrEmpty(configuration.ConnectionString))
            {
                throw Errors.ConnectionStringMissing();
            }

            if (String.IsNullOrEmpty(configuration.Collection))
            {
                throw Errors.CollectionNameMissing();
            }

            var adapter = new MongoDbSourceAdapter(GetInstanceConfiguration(configuration));
            await adapter.Initialize(cancellation);

            return(adapter);
        }