@@ -37,12 +37,29 @@ public ActiveDatabaseContext Use(IDatabaseContext context)
3737 return new ActiveDatabaseContext ( this , current ) ;
3838 }
3939
40- public bool Contains ( string connectionString )
40+ public bool Contains ( string name )
4141 {
42- return DatabaseContexts . Find ( candidate => candidate . Connection . ConnectionString . Equals ( connectionString , StringComparison . OrdinalIgnoreCase ) ) != null ;
42+ return DatabaseContexts . Find ( candidate => candidate . Name . Equals ( name , StringComparison . OrdinalIgnoreCase ) ) != null ;
4343 }
4444
45- public void Add ( IDatabaseContext context )
45+ public bool ContainsConnectionString ( string connectionString )
46+ {
47+ return DatabaseContexts . Find ( candidate => candidate . Connection . ConnectionString . Equals ( connectionString , StringComparison . OrdinalIgnoreCase ) ) != null ;
48+ }
49+
50+ public IDatabaseContext GetConnectionString ( string connectionString )
51+ {
52+ var result = DatabaseContexts . Find ( candidate => candidate . Connection . ConnectionString . Equals ( connectionString , StringComparison . OrdinalIgnoreCase ) ) ;
53+
54+ if ( result == null )
55+ {
56+ throw new Exception ( string . Format ( Resources . DatabaseContextConnectionStringNotFoundException , connectionString ) ) ;
57+ }
58+
59+ return result ;
60+ }
61+
62+ public void Add ( IDatabaseContext context )
4663 {
4764 if ( Find ( context ) != null )
4865 {
@@ -75,13 +92,13 @@ public void Remove(IDatabaseContext context)
7592 DatabaseContexts . Remove ( candidate ) ;
7693 }
7794
78- public IDatabaseContext Get ( string connectionString )
95+ public IDatabaseContext Get ( string name )
7996 {
80- var result = DatabaseContexts . Find ( candidate => candidate . Connection . ConnectionString . Equals ( connectionString , StringComparison . OrdinalIgnoreCase ) ) ;
97+ var result = DatabaseContexts . Find ( candidate => candidate . Name . Equals ( name , StringComparison . OrdinalIgnoreCase ) ) ;
8198
8299 if ( result == null )
83100 {
84- throw new Exception ( string . Format ( Resources . DatabaseContextConnectionStringNotFoundException , DbConnectionExtensions . SecuredConnectionString ( connectionString ) ) ) ;
101+ throw new Exception ( string . Format ( Resources . DatabaseContextNameNotFoundException , name ) ) ;
85102 }
86103
87104 return result ;
0 commit comments