public static SqlServerDocumentDbRegistration RegisterSqlServerDocumentDb (this IWindsorContainer @this, SqlServerDocumentDbRegistration registration, string connectionName, Dependency sessionInterceptor = null) { Contract.Requires(registration != null); Contract.Requires(!connectionName.IsNullOrWhiteSpace()); //We don't want to get any old interceptor that might have been registered by someone else. sessionInterceptor = sessionInterceptor ?? Dependency.OnValue<IDocumentDbSessionInterceptor>(NullOpDocumentDbSessionInterceptor.Instance); var connectionString = Dependency.OnValue(typeof(string),@this.Resolve<IConnectionStringProvider>().GetConnectionString(connectionName).ConnectionString); @this.Register( Component.For<IDocumentDb>() .ImplementedBy<SqlServerDocumentDb>() .DependsOn(connectionString) .LifestylePerWebRequest() .Named(registration.DocumentDbName), Component.For(Seq.OfTypes<IDocumentDbSession, IDocumentDbUpdater, IDocumentDbReader, IDocumentDbBulkReader, IUnitOfWorkParticipant, IDocumentUpdatedNotifier>()) .ImplementedBy<DocumentDbSession>() .DependsOn(registration.DocumentDb, sessionInterceptor) .LifestylePerWebRequest() .Named(registration.SessionName) ); @this.WhenTesting() .ReplaceDocumentDb(registration.DocumentDbName); return registration; }
public static SqlServerDocumentDbRegistration RegisterSqlServerDocumentDb (this IWindsorContainer @this, SqlServerDocumentDbRegistration registration, string connectionName, Dependency sessionInterceptor = null) { Contract.Requires(registration != null); Contract.Requires(!connectionName.IsNullOrWhiteSpace()); //We don't want to get any old interceptor that might have been registered by someone else. sessionInterceptor = sessionInterceptor ?? Dependency.OnValue <IDocumentDbSessionInterceptor>(NullOpDocumentDbSessionInterceptor.Instance); var connectionString = Dependency.OnValue(typeof(string), @this.Resolve <IConnectionStringProvider>().GetConnectionString(connectionName).ConnectionString); @this.Register( Component.For <IDocumentDb>() .ImplementedBy <SqlServerDocumentDb>() .DependsOn(connectionString) .LifestylePerWebRequest() .Named(registration.DocumentDbName), Component.For(Seq.OfTypes <IDocumentDbSession, IDocumentDbUpdater, IDocumentDbReader, IDocumentDbBulkReader, IUnitOfWorkParticipant, IDocumentUpdatedNotifier>()) .ImplementedBy <DocumentDbSession>() .DependsOn(registration.DocumentDb, sessionInterceptor) .LifestylePerWebRequest() .Named(registration.SessionName) ); @this.WhenTesting() .ReplaceDocumentDb(registration.DocumentDbName); return(registration); }