public static RavenServicesBuilder AddRaven( this IServiceCollection serviceCollection, RavenOptions options) { serviceCollection.TryAdd(new ServiceCollection() .AddSingleton <IDocumentStore> (p => new DocumentStore { Url = options.Url != null ? options.Url : "http://localhost:8080", DefaultDatabase = options.Database != null ? options.Database : "", Conventions = options.Conventions != null ? options.Conventions : new DocumentConvention(), ApiKey = options.ApiKey != null ? options.ApiKey : "", Credentials = options.Credentials != null ? options.Credentials : null }.Initialize()) .AddScoped <IAsyncDocumentSession> (p => p.GetRequiredService <IDocumentStore>().OpenAsyncSession())); return(new RavenServicesBuilder(serviceCollection)); }
public static RavenServicesBuilder AddRaven( this IServiceCollection serviceCollection, RavenOptions options) { serviceCollection.TryAdd(new ServiceCollection() .AddSingleton<IDocumentStore> (p => new DocumentStore { Url = options.Url != null ? options.Url : "http://localhost:8080", DefaultDatabase = options.Database != null ? options.Database : "", Conventions = options.Conventions != null ? options.Conventions : new DocumentConvention(), ApiKey = options.ApiKey != null ? options.ApiKey : "", Credentials = options.Credentials != null ? options.Credentials : null }.Initialize()) .AddScoped<IAsyncDocumentSession> (p => p.GetRequiredService<IDocumentStore>().OpenAsyncSession())); return new RavenServicesBuilder(serviceCollection); }