Created
January 4, 2013 11:47
-
-
Save ChrisMcKee/4452028 to your computer and use it in GitHub Desktop.
Repository Factory Interface / Implementation (using ninject/nhibernate)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Core.Repository | |
| { | |
| using Core.Model; | |
| using Core.Model.Some; | |
| public interface IRepositoryFactory | |
| { | |
| ISomeRepository SomeRepository(); | |
| IRepository<SomeObjectType> SomeObjectTypeRepository(); | |
| IRepository<T> Repository<T>() where T : class; | |
| } | |
| } | |
| namespace Data.Repository | |
| { | |
| using Core.Model; | |
| using Core.Model.Some; | |
| using Core.Repository; | |
| using Ninject; | |
| public class RepositoryFactory : IRepositoryFactory | |
| { | |
| private readonly IKernel _kernel; | |
| public RepositoryFactory(IKernel kernel) | |
| { | |
| _kernel = kernel; | |
| } | |
| public ISomeRepository SomeRepository() | |
| { | |
| return _kernel.Get<ISomeRepository>(); | |
| } | |
| public IRepository<SomeObjectType> SomeObjectTypeRepository() | |
| { | |
| return _kernel.Get<IRepository<SomeObjectType>>(); | |
| } | |
| public IRepository<T> Repository<T>() where T : class | |
| { | |
| return _kernel.Get<IRepository<T>>(); | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment