public IDatabase CreateDatabase(IConfiguration configuration, string adminUser, string identification, string token)
{
lock (this) {
if (configuration == null)
throw new ArgumentNullException("configuration");
var databaseName = configuration.GetString("database.name");
if (String.IsNullOrEmpty(databaseName))
throw new ArgumentException("The configuration must specify a database name.");
if (DatabaseExists(databaseName))
throw new InvalidOperationException(String.Format("Database '{0}' already exists in the system.", databaseName));
var dbContext = Context.CreateDatabaseContext(configuration);
var database = new Database(this, dbContext);
if (database.Exists)
throw new InvalidOperationException(String.Format("The database '{0}' was already created.", databaseName));
database.Create(adminUser, identification, token);
database.Open();
if (databases == null)
databases = new Dictionary<string, Database>();
databases[databaseName] = database;
return database;
}
}