public IUnitOfWorkCompleteHandle Begin(UnitOfWorkOptions options) { _childScope = _scopeResolver.BeginScope(); options.FillDefaultsForNonProvidedOptions(_defaultOptions); IUnitOfWork outerUow = _currentUnitOfWorkProvider.Current; if (options.Scope == TransactionScopeOption.Required && outerUow != null) { return(new InnerUnitOfWorkCompleteHandle()); } var uow = _childScope.Resolve <IUnitOfWork>(); uow.Completed += (sender, args) => { _currentUnitOfWorkProvider.Current = null; }; uow.Failed += (sender, args) => { _currentUnitOfWorkProvider.Current = null; }; uow.Disposed += (sender, args) => { _childScope.Dispose(); }; //Inherit filters from outer UOW if (outerUow != null) { options.FillOuterUowFiltersForNonProvidedOptions(outerUow.Filters.ToList()); } uow.Begin(options); _currentUnitOfWorkProvider.Current = uow; return(uow); }
public void Migrate <TDbContext, TConfiguration>(string nameOrConnectionString, Assembly migrationAssembly, Action <string> logger) where TDbContext : DbContext where TConfiguration : DbMigrationsConfiguration <TDbContext>, new() { logger($"MigrationStrategy: DbContext starting for {typeof(TDbContext).GetTypeInfo().Name}..."); using (IScopeResolver scope = _resolver.BeginScope()) { var dbInitializer = scope.Resolve <StoveDbContextMigration <TDbContext> >(); dbInitializer.Migrate(logger); } logger($"MigrationStrategy: DbContext finished succesfully for {typeof(TDbContext).GetTypeInfo().Name}."); }
public void Migrate <TDbContext, TConfiguration>(string nameOrConnectionString, Assembly migrationAssembly, Action <string> logger) where TDbContext : DbContext where TConfiguration : DbMigrationsConfiguration <TDbContext>, new() { logger($"MigrationStrategy: DbContext starting for {typeof(TDbContext).GetTypeInfo().Name}..."); using (IScopeResolver scope = _resolver.BeginScope()) { var dbContext = scope.Resolve <TDbContext>(new { nameOrConnectionString }); var dbInitializer = new MigrateDatabaseToLatestVersion <TDbContext, TConfiguration>(true, new TConfiguration()); dbInitializer.InitializeDatabase(dbContext); } logger($"MigrationStrategy: DbContext finished succesfully for {typeof(TDbContext).GetTypeInfo().Name}."); }
/// <summary> /// Constructor. /// </summary> public StoveMemoryCacheManager(IScopeResolver scopeResolver, ICachingConfiguration configuration) : base(scopeResolver.BeginScope(), configuration) { }
/// <summary> /// Initializes a new instance of the <see cref="StoveRedisCacheManager" /> class. /// </summary> public StoveRedisCacheManager([NotNull] IScopeResolver scopeResolver, [NotNull] ICachingConfiguration configuration) : base(scopeResolver.BeginScope(), configuration) { }
/// <summary> /// Resolves handler object from Ioc container. /// </summary> /// <returns>Resolved handler object</returns> public IEventHandler GetHandler() { _childScope = _scopeResolver.BeginScope(); return((IEventHandler)_childScope.Resolve(HandlerType)); }