Esempio n. 1
0
        public IDocumentStore Initialise()
        {
            try
            {
                if (String.IsNullOrEmpty(server))
                {
                    var embeddedDatabase = new DocumentDatabase(new RavenConfiguration {DataDirectory = DataDirectory});
                    embeddedDatabase.SpinBackgroundWorkers();
                    DatabaseCommands = new EmbededDatabaseCommands(embeddedDatabase);
                }
                else
                {
                    DatabaseCommands = new ServerClient(server, port);
                }
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }

            return this;
        }
Esempio n. 2
0
        public IDocumentStore Initialise()
        {
            try
            {
            #if !CLIENT
                if (configuration != null)
                {
                    var embeddedDatabase = new Raven.Database.DocumentDatabase(configuration);
                    embeddedDatabase.SpinBackgroundWorkers();
                    DatabaseCommands = new EmbededDatabaseCommands(embeddedDatabase, Conventions);
                }
                else
            #endif
                {
                    DatabaseCommands = new ServerClient(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;
        }