We have 2 OpenLdap
servers. One is the latest out of the box version. The other one is an older heavily customized version.
Both implementations really follows a similar logic. Take the connection for example.
Here is the interface
namespace Infrastructure.Interfaces
{
public interface ISessionService
{
LdapConnection GetConnection();
}
}
Each of the implementations will make use of this interface to get a connection.
New Server
namespace Infrastructure.NewLdap.Service
{
public class SessionService : ISessionService
{
LdapConnection GetConnection()
{
.....
}
}
}
Old Server
namespace Infrastructure.OldLdap.Service
{
public class SessionService : ISessionService
{
LdapConnection GetConnection()
{
.....
}
}
}
Each of the implementations are in different Projects. Each project will have a different app.config
with the right credentials etc. Along with this there is a IConfigService
which will have all the credentials etc loaded into it from the app.config
.
namespace Infrastructure.Interfaces
{
public interface IConfigService
{
string ServerAddress { get; }
...
...
}
}
Again each project will have its own implementation of this.
The repositories in each project will be different, because of the way we access data in each of the servers. The old server will be used to query only so we are using it to import users into the new server.
How would I use Simple Injector
to inject these services into the same interface but depending on which repository is used, the right implementation will be pulled in? If that makes sense?
Infrastructure.OldLdap.SomeRepo
UseInterfaces.ISessionService
Registered withOldLdap.Service.SessionService
Infrastructure.NewLdap.SomeOtherRepo
UseInterfaces.ISessionService
Registered withNewLdap.Service.SessionService
Is this even possible, Also does this break the Liskov Substitution Principle
.
Am I better to write each implementation as it's own thing? If so, won't this break the DRY
principle?
Hope this is not to broad, thank you in advance.