Guest User

Untitled

a guest
Nov 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. public interface IRepositoryFactory
  2.     {
  3.         IProjectRepository CreateProjectRepository();
  4.         IConfigurationRepository CreateConfigurationRepository();
  5.         ICostCategoryRepository CreateCostCategoryRepository();
  6.         ICostRepository CreateCostRepository();
  7.     }
  8.  
  9.     public class SampleRepositoryFactory : IRepositoryFactory
  10.     {
  11.         private IProjectRepository _cachedProjectRepository;
  12.         private ICostRepository _cachedCostRepository;
  13.  
  14.         ...
  15.  
  16.  
  17.         public IProjectRepository CreateProjectRepository()
  18.         {
  19.             if(_cachedProjectRepository == null)
  20.                 _cachedProjectRepository = new SampleProjectRepository();
  21.  
  22.             return _cachedProjectRepository;
  23.         }
  24.  
  25.         public IConfigurationRepository CreateConfigurationRepository()
  26.         {
  27.             ....
  28.         }
  29.  
  30.         public ICostCategoryRepository CreateCostCategoryRepository()
  31.         {
  32.            ....
  33.         }
  34.  
  35.         public ICostRepository CreateCostRepository()
  36.         {
  37.             ...
  38.         }
  39.     }
Add Comment
Please, Sign In to add comment