public RootDependencyResolver(
            DefaultProviderServicesResolver defaultProviderServicesResolver,
            DatabaseInitializerResolver databaseInitializerResolver)
        {
            DebugCheck.NotNull(defaultProviderServicesResolver);
            DebugCheck.NotNull(databaseInitializerResolver);

            _databaseInitializerResolver = databaseInitializerResolver;

            _resolvers.Add(_databaseInitializerResolver);
            _resolvers.Add(new DefaultExecutionStrategyResolver());
            _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver));
            _resolvers.Add(new CachingDependencyResolver(new DefaultProviderFactoryResolver()));
            _resolvers.Add(new CachingDependencyResolver(new DefaultInvariantNameResolver()));
            _resolvers.Add(new SingletonDependencyResolver <IDbConnectionFactory>(new SqlConnectionFactory()));
            _resolvers.Add(new SingletonDependencyResolver <IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory()));
            _resolvers.Add(new SingletonDependencyResolver <IManifestTokenService>(new DefaultManifestTokenService()));
            _resolvers.Add(new SingletonDependencyResolver <HistoryContextFactory>((e, d) => new HistoryContext(e, d)));
            _resolvers.Add(new SingletonDependencyResolver <IPluralizationService>(new EnglishPluralizationService()));
            _resolvers.Add(new SingletonDependencyResolver <IViewAssemblyCache>(new ViewAssemblyCache()));
            _resolvers.Add(new SingletonDependencyResolver <AttributeProvider>(new AttributeProvider()));

#if NET40
            _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryService>(new Net40DefaultDbProviderFactoryService()));
#else
            _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryService>(new DefaultDbProviderFactoryService()));
#endif
        }
Esempio n. 2
0
        public RootDependencyResolver(
            DefaultProviderServicesResolver defaultProviderServicesResolver,
            DatabaseInitializerResolver databaseInitializerResolver)
        {
            DebugCheck.NotNull(defaultProviderServicesResolver);
            DebugCheck.NotNull(databaseInitializerResolver);

            _databaseInitializerResolver = databaseInitializerResolver;

            _resolvers.Add(_databaseInitializerResolver);

            _resolvers.Add(
                new TransientDependencyResolver <MigrationSqlGenerator>(
                    () => new SqlServerMigrationSqlGenerator(), "System.Data.SqlClient"));

            _resolvers.Add(
                new TransientDependencyResolver <MigrationSqlGenerator>(
                    () => new SqlCeMigrationSqlGenerator(), "System.Data.SqlServerCe.4.0"));

            _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver));
            _resolvers.Add(new SingletonDependencyResolver <IDbConnectionFactory>(new SqlConnectionFactory()));
            _resolvers.Add(new SingletonDependencyResolver <IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory()));
            _resolvers.Add(new SingletonDependencyResolver <IManifestTokenService>(new DefaultManifestTokenService()));
            _resolvers.Add(new SingletonDependencyResolver <IHistoryContextFactory>(new DefaultHistoryContextFactory()));
            _resolvers.Add(new ThreadLocalDependencyResolver <IDbCommandInterceptor>(() => new DefaultCommandInterceptor()));
            _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryService>(new DefaultDbProviderFactoryService()));
        }
        public RootDependencyResolver(
            DefaultProviderServicesResolver defaultProviderServicesResolver,
            DatabaseInitializerResolver databaseInitializerResolver)
        {
            DebugCheck.NotNull(defaultProviderServicesResolver);
            DebugCheck.NotNull(databaseInitializerResolver);

            _databaseInitializerResolver = databaseInitializerResolver;

            _resolvers.Add(_databaseInitializerResolver);
            _resolvers.Add(new DefaultExecutionStrategyResolver());
            _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver));
            _resolvers.Add(new CachingDependencyResolver(new DefaultProviderFactoryResolver()));
            _resolvers.Add(new CachingDependencyResolver(new DefaultInvariantNameResolver()));
            _resolvers.Add(new SingletonDependencyResolver<IDbConnectionFactory>(new SqlConnectionFactory()));
            _resolvers.Add(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory()));
            _resolvers.Add(new SingletonDependencyResolver<IManifestTokenService>(new DefaultManifestTokenService()));
            _resolvers.Add(new SingletonDependencyResolver<HistoryContextFactory>((e, d) => new HistoryContext(e, d)));
            _resolvers.Add(new SingletonDependencyResolver<IPluralizationService>(new EnglishPluralizationService()));
            _resolvers.Add(new SingletonDependencyResolver<IViewAssemblyCache>(new ViewAssemblyCache()));
            _resolvers.Add(new SingletonDependencyResolver<AttributeProvider>(new AttributeProvider()));

#if NET40
            _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryService>(new Net40DefaultDbProviderFactoryService()));
#else
            _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryService>(new DefaultDbProviderFactoryService()));
#endif
        }
Esempio n. 4
0
        public RootDependencyResolver(
            DefaultProviderServicesResolver defaultProviderServicesResolver,
            DatabaseInitializerResolver databaseInitializerResolver)
        {
            DebugCheck.NotNull(defaultProviderServicesResolver);
            DebugCheck.NotNull(databaseInitializerResolver);

            _databaseInitializerResolver = databaseInitializerResolver;

            _resolvers.Add(_databaseInitializerResolver);

            _resolvers.Add(
                new TransientDependencyResolver<MigrationSqlGenerator>(
                    () => new SqlServerMigrationSqlGenerator(), "System.Data.SqlClient"));

            _resolvers.Add(
                new TransientDependencyResolver<MigrationSqlGenerator>(
                    () => new SqlCeMigrationSqlGenerator(), "System.Data.SqlServerCe.4.0"));

            _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver));
            _resolvers.Add(new SingletonDependencyResolver<IDbConnectionFactory>(new SqlConnectionFactory()));
            _resolvers.Add(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory()));
            _resolvers.Add(new SingletonDependencyResolver<IManifestTokenService>(new DefaultManifestTokenService()));
            _resolvers.Add(new SingletonDependencyResolver<IHistoryContextFactory>(new DefaultHistoryContextFactory()));
            _resolvers.Add(new ThreadLocalDependencyResolver<IDbCommandInterceptor>(() => new DefaultCommandInterceptor()));
            _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryService>(new DefaultDbProviderFactoryService()));
        }
        public RootDependencyResolver(
            MigrationsConfigurationResolver migrationsConfigurationResolver,
            DefaultProviderServicesResolver defaultProviderServicesResolver)
        {
            _migrationsConfigurationResolver = migrationsConfigurationResolver;

            _resolvers.Add(_migrationsConfigurationResolver);
            _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver));
            _resolvers.Add(new SingletonDependencyResolver<IDbConnectionFactory>(new SqlConnectionFactory()));
            _resolvers.Add(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory()));
        }
        public void GetService_can_be_accessed_from_multiple_threads_concurrently()
        {
            for (var i = 0; i < 30; i++)
            {
                var bag      = new ConcurrentBag <DbProviderServices>();
                var resolver = new DefaultProviderServicesResolver();

                ExecuteInParallel(() => bag.Add(resolver.GetService <DbProviderServices>("System.Data.SqlClient")));

                Assert.Equal(20, bag.Count);
                Assert.True(bag.All(c => SqlProviderServices.Instance == c));
            }
        }
        public void GetService_can_be_accessed_from_multiple_threads_concurrently()
        {
            for (var i = 0; i < 30; i++)
            {
                var bag = new ConcurrentBag<DbProviderServices>();
                var resolver = new DefaultProviderServicesResolver();

                ExecuteInParallel(() => bag.Add(resolver.GetService<DbProviderServices>("System.Data.SqlClient")));

                Assert.Equal(20, bag.Count);
                Assert.True(bag.All(c => SqlProviderServices.Instance == c));
            }
        }
        public RootDependencyResolver(
            MigrationsConfigurationResolver migrationsConfigurationResolver,
            DefaultProviderServicesResolver defaultProviderServicesResolver,
            DatabaseInitializerResolver databaseInitializerResolver)
        {
            Contract.Requires(migrationsConfigurationResolver != null);
            Contract.Requires(defaultProviderServicesResolver != null);
            Contract.Requires(databaseInitializerResolver != null);

            _databaseInitializerResolver = databaseInitializerResolver;

            _resolvers.Add(_databaseInitializerResolver);
            _resolvers.Add(migrationsConfigurationResolver);
            _resolvers.Add(new CachingDependencyResolver(defaultProviderServicesResolver));
            _resolvers.Add(new SingletonDependencyResolver<IDbConnectionFactory>(new SqlConnectionFactory()));
            _resolvers.Add(new SingletonDependencyResolver<IDbModelCacheKeyFactory>(new DefaultModelCacheKeyFactory()));
        }