Пример #1
0
        private IDocumentStore InitDocumentStore(AutofacCreationConverter converter)
        {
            IDocumentStore ds;
            if (_ds != null)
                ds = _ds;
            else if (ConnectionStringName != null)
            {
                ds = new DocumentStore
                    {
                        ConnectionStringName = ConnectionStringName
                    };
                ds.Initialize();
            }
            else if (!string.IsNullOrEmpty(Url))
            {
                var store = new DocumentStore
                    {
                        Url = Url,
                    };
                if (!string.IsNullOrEmpty(DefaultDatabase))
                    store.DefaultDatabase = DefaultDatabase;
                store.Initialize();

                ds = store;
            }
            else
            {
                ds = new DocumentStore
                    {
                        Url = "http://localhost:9901"
                    };
                ds.Initialize();
            }

            if (converter != null && UseCreationConverter)
            {
                ds.Conventions.CustomizeJsonSerializer += s => s.Converters.Add(converter);
            }

            ds.Conventions.DisableProfiling = true;
            ds.Conventions.JsonContractResolver = new RecordClrTypeInJsonContractResolver();
            ds.Conventions.CustomizeJsonSerializer += s => s.TypeNameHandling = TypeNameHandling.Arrays;

            if (CreateIndexes)
                IndexCreation.CreateIndexes(typeof (RavenDataStoreModule).Assembly, ds);
            //ds.DatabaseCommands.EnsureDatabaseExists()

            //global::Raven.Client.Indexes.IndexCreation.CreateIndexes(typeof(RegionTrajectoryIndex).Assembly, ds);

            return ds;
        }
        private IDocumentStore InitDocumentStore(AutofacCreationConverter converter)
        {
            var shardStrategy = new ShardStrategy(_shards)
                {
                    ShardAccessStrategy = new ParallelShardAccessStrategy(),
                    ShardResolutionStrategy = this
                };

            var ds = new ShardedDocumentStore(shardStrategy);
            ds.Initialize();
            if (converter != null)
            {
                ds.Conventions.CustomizeJsonSerializer += s => s.Converters.Add(converter);
            }
            return ds;
        }