public IDocumentStore Initialize()
{
try
{
#if !CLIENT
if (configuration != null)
{
DocumentDatabase = new Raven.Database.DocumentDatabase(configuration);
DocumentDatabase.SpinBackgroundWorkers();
databaseCommandsGenerator = () => new EmbededDatabaseCommands(DocumentDatabase, Conventions);
}
else
#endif
{
databaseCommandsGenerator = ()=>new ServerClient(Url, Conventions, credentials);
asyncDatabaseCommandsGenerator = ()=>new AsyncServerClient(Url, Conventions, credentials);
}
if(Conventions.DocumentKeyGenerator == null)// don't overwrite what the user is doing
{
var generator = new MultiTypeHiLoKeyGenerator(DatabaseCommands, 1024);
Conventions.DocumentKeyGenerator = entity => generator.GenerateDocumentKey(Conventions, entity);
}
}
catch (Exception)
{
Dispose();
throw;
}
return this;
}