What should I register with my IoC container?
If you are going to use an IoC container, regardless of which one, here is what needs to be registered, and some thoughts about object lifetime. If we do not specify a lifetime, you can assume that singleton is acceptable.
Highway.Data
IRepositoryshould resolve toRepositoryon either a transient (new every request) or per web request (if you’re in a website) object lifetime.IEventManagershould resolve toEventManagerILogshould resolve to either a Common.Logging implementation for your chosen logger, or an instance ofNoOpLoggerfrom Common.Logging.
Highway.Data.EntityFramework
IDataContextshould resolve toDataContexton either a transient (new every request).- Your IoC will need to inject a connection string, named
connectionStringto the constructor, in whatever way such primitive dependencies are handled by your container.
- Your IoC will need to inject a connection string, named
IMappingConfigurationshould resolve to a type you have created that implements this interface and maps all of your entities.IContextConfigurationshould resolve toDefaultContextConfigurationor a class you’ve created should you need to change how the Context is configured from our defaults.
Highway.Data.NHibernate
IDataContextshould resolve toDataContexton either a transient (new every request).ISessionshould resolve to a call to your configuredISessionFactory. These are standard NHibernate interfaces, and you should follow their guidance regarding object lifetime.
Highway.Data.RavenDb
IDataContextshould resolve toDataContexton either a transient (new every request).IDocumentSessionshould resolve to a call to your configuredIDocumentStore. These are standard RavenDb interfaces, and you should follow their guidance regarding object lifetime.