示例#1
0
        /// <summary>
        /// Gets a new <see cref="IMigrationManager{TContext}"/> from the
        /// service scope factory
        /// </summary>
        /// <param name="handler">The handler to receive the manager</param>
        /// <returns>A task to be awaited</returns>
        protected async Task UsingManagerAsync(Func <IMigrationManager <TContext>, Task> handler)
        {
            using (var scope = InstanceScopeFactory.Build())
            {
                Logger.LogDebug(null, "Resolving migration manager from service collection");
                var manager = scope.GetRequiredInstance <IMigrationManager <TContext> >();

                await handler(manager).ConfigureAwait(false);
            }
        }
示例#2
0
        /// <summary>
        /// Gets a new <see cref="IMigration{TContext}"/> from the service
        /// scope factory for the given type
        /// </summary>
        /// <param name="migrationType">The migration type to resolve</param>
        /// <param name="handler">The handler to receive the migration</param>
        /// <returns>A task to be awaited</returns>
        protected async Task UsingMigrationAsync(Type migrationType, Func <IMigration <TContext>, Task> handler)
        {
            using (var scope = InstanceScopeFactory.Build())
            {
                Logger.LogDebug(null,
                                "Resolving migration of type '{migrationType}' from service collection",
                                migrationType.ToString());
                var migration = (IMigration <TContext>)scope.GetRequiredInstance(migrationType);

                await handler(migration).ConfigureAwait(false);
            }
        }