public static IServiceCollection AddCustomCouchbase(this IServiceCollection services) { var resolver = services.BuildServiceProvider(); using (var scope = resolver.CreateScope()) { var config = scope.ServiceProvider.GetService <IConfiguration>(); var couchbaseOption = new CouchbaseOptions(); config.Bind(CouchbaseSectionName, couchbaseOption); services.AddSingleton(couchbaseOption); var servers = new List <Uri>(); foreach (var server in couchbaseOption.Servers) { servers.Add(new Uri(server)); } var cluster = new Cluster(new ClientConfiguration { Servers = servers }); cluster.Authenticate(new PasswordAuthenticator(couchbaseOption.UserName, couchbaseOption.Password)); services.AddSingleton(x => cluster.OpenBucket(couchbaseOption.DefaultBucket)); services.AddTransient <ProfileRepository>(); return(services); } }
public BehaviorRepository(CouchbaseOptions options) : base(options) { }