public NotificationsService(Routes routes, IRepository repository)
        {
            Check.IsNotNull(routes, "routes");
            Check.IsNotNull(repository, "repository");

            this.routes = routes;
            this.repository = repository;

            Log.InfoFormat("Service initialized. Repository: [{0}].", repository.GetType());
        }
Example #2
0
 /// <summary>
 /// Register a repository with the unit of work
 /// </summary>
 /// <param name="repository">A repository derived from irepository</param>
 public void Register (IRepository repository)
 {
     _repositories.Add(repository.GetType().Name, repository);
 }
Example #3
0
 public IUnitOfWork GetUnit(IRepository repo)
 {
     Type tipo = factory[repo.GetType().Name];
     return (IUnitOfWork)Activator.CreateInstance(tipo);
 }
Example #4
0
 /// <summary>
 /// 强制转换指定仓库的数据提供程序为关系数据库的数据提供程。
 /// 如果该仓库的 <see cref="IRepository.DataProvider"/> 不是此类型的子类,则会抛出异常。
 /// </summary>
 /// <param name="repository"></param>
 /// <returns></returns>
 public static RdbDataProvider Get(IRepository repository)
 {
     var dp = repository.DataProvider as RdbDataProvider;
     if (dp == null)
     {
         throw new InvalidProgramException(string.Format(
             "{0} 仓库类型使用的数据提供程序类型是 {1},该类型不能转换为关系数据库的数据提供程序。",
             repository.GetType(),
             repository.DataProvider.GetType()
             ));
     }
     return dp;
 }