I have the following classes which I'm having issues with resolving using SimpleInjector.
Config Interface
Namespace Infrastructure.Base
public interface ILdapConfigService { ..... }
Session Interface
Namespace Infrastructure.Base
public interface ISessionService { LdapConnection GetConnection(); }
Session Implementation
public class SessionService : ISessionService {
public SessionService (ILdapConfigService ldapConfigService) { ... }
}
Config Service Implementation 1
namespace Infrastructure.Old
public class OldConfigService : ILdapConfigService { .... }
Config Service Implementation 2
namespace Infrastructure.New
public class NewConfigService : ILdapConfigService { .... }
The idea is to have the session service interface and implementation in a base project. Then have different projects which implements the config service.
The different projects will have services which makes use of a repository in the base class too.
I need to know how to register these interfaces, or is it even possible to register it like this?
Infrastructure.New.SomeService uses Infrastructure.Base.IRepository. Infrastructure.Old.SomeOtherService uses Infrastructure.Base.IRepository.
Infrastructure.Base.Repository implements Infrastructure.Base.IRepository. Infrastructure.Base.Repository uses Infrastructure.Base.ISessionService.
Infrastructure.Base.SessionService implements Infrastructure.Base.ISessionService. Infrastructure.Base.SessionService uses Infrastructure.Base.ILdapConfigService.
Infrastructure.New.LdapConfigService implements Infrastructure.Base.ILdapConfigService.
Infrastructure.Old.LdapConfigService implements Infrastructure.Base.ILdapConfigService.
How can I register this logic with Simple Injector. I used RegisterConditional but that did not quite work, because the consumer of ILdapConfigService sits in base.
Is my design pattern perhaps flawed?
Aucun commentaire:
Enregistrer un commentaire