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

            _databaseInitializerResolver = databaseInitializerResolver;

            _resolvers.Add(new TransactionContextInitializerResolver());
            _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<Func<DbContext, IDbModelCacheKey>>(new DefaultModelCacheKeyFactory().Create));
            _resolvers.Add(new SingletonDependencyResolver<IManifestTokenResolver>(new DefaultManifestTokenResolver()));
            _resolvers.Add(new SingletonDependencyResolver<Func<DbConnection, string, HistoryContext>>(HistoryContext.DefaultFactory));
            _resolvers.Add(new SingletonDependencyResolver<IPluralizationService>(new EnglishPluralizationService()));
            _resolvers.Add(new SingletonDependencyResolver<AttributeProvider>(new AttributeProvider()));
            _resolvers.Add(new SingletonDependencyResolver<Func<DbContext, Action<string>, DatabaseLogFormatter>>((c, w) => new DatabaseLogFormatter(c, w)));
            _resolvers.Add(new SingletonDependencyResolver<Func<TransactionHandler>>(() => new DefaultTransactionHandler(), k => k is ExecutionStrategyKey));

#if NET40
            _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryResolver>(new Net40DefaultDbProviderFactoryResolver()));
#else
            _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryResolver>(new DefaultDbProviderFactoryResolver()));
#endif
            _resolvers.Add(new SingletonDependencyResolver<Func<IMetadataAnnotationSerializer>>(
                () => new ClrTypeAnnotationSerializer(), XmlConstants.ClrTypeAnnotation));
            _resolvers.Add(new SingletonDependencyResolver<Func<IMetadataAnnotationSerializer>>(
                () => new IndexAnnotationSerializer(), IndexAnnotation.AnnotationName));
        }
예제 #2
0
        public RootDependencyResolver(
            DefaultProviderServicesResolver defaultProviderServicesResolver,
            DatabaseInitializerResolver databaseInitializerResolver)
        {
            DebugCheck.NotNull(defaultProviderServicesResolver);
            DebugCheck.NotNull(databaseInitializerResolver);

            _databaseInitializerResolver = databaseInitializerResolver;

            _resolvers.Add(new TransactionContextInitializerResolver());
            _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 LocalDbConnectionFactory()));
            _resolvers.Add(new SingletonDependencyResolver <Func <DbContext, IDbModelCacheKey> >(new DefaultModelCacheKeyFactory().Create));
            _resolvers.Add(new SingletonDependencyResolver <IManifestTokenResolver>(new DefaultManifestTokenResolver()));
            _resolvers.Add(new SingletonDependencyResolver <Func <DbConnection, string, HistoryContext> >(HistoryContext.DefaultFactory));
            _resolvers.Add(new SingletonDependencyResolver <IPluralizationService>(new EnglishPluralizationService()));
            _resolvers.Add(new SingletonDependencyResolver <AttributeProvider>(new AttributeProvider()));
            _resolvers.Add(new SingletonDependencyResolver <Func <DbContext, Action <string>, DatabaseLogFormatter> >((c, w) => new DatabaseLogFormatter(c, w)));
            _resolvers.Add(new SingletonDependencyResolver <Func <TransactionHandler> >(() => new DefaultTransactionHandler(), k => k is ExecutionStrategyKey));

#if NET40
            _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryResolver>(new Net40DefaultDbProviderFactoryResolver()));
#else
            _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryResolver>(new DefaultDbProviderFactoryResolver()));
#endif
            _resolvers.Add(new SingletonDependencyResolver <Func <IMetadataAnnotationSerializer> >(
                               () => new ClrTypeAnnotationSerializer(), XmlConstants.ClrTypeAnnotation));
            _resolvers.Add(new SingletonDependencyResolver <Func <IMetadataAnnotationSerializer> >(
                               () => new IndexAnnotationSerializer(), IndexAnnotation.AnnotationName));
        }
        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<Func<DbContext, IDbModelCacheKey>>(new DefaultModelCacheKeyFactory().Create));
            _resolvers.Add(new SingletonDependencyResolver<IManifestTokenResolver>(new DefaultManifestTokenResolver()));
            _resolvers.Add(new SingletonDependencyResolver<Func<DbConnection, string, HistoryContext>>(HistoryContext.DefaultFactory));
            _resolvers.Add(new SingletonDependencyResolver<IPluralizationService>(new EnglishPluralizationService()));
            _resolvers.Add(new SingletonDependencyResolver<AttributeProvider>(new AttributeProvider()));
            _resolvers.Add(new SingletonDependencyResolver<Func<DbContext, Action<string>, DbCommandLogger>>((c, w) => new DbCommandLogger(c, w)));

#if NET40
            _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryResolver>(new Net40DefaultDbProviderFactoryResolver()));
#else
            _resolvers.Add(new SingletonDependencyResolver<IDbProviderFactoryResolver>(new DefaultDbProviderFactoryResolver()));
#endif
        }
        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 <Func <DbContext, IDbModelCacheKey> >(new DefaultModelCacheKeyFactory().Create));
            _resolvers.Add(new SingletonDependencyResolver <IManifestTokenResolver>(new DefaultManifestTokenResolver()));
            _resolvers.Add(new SingletonDependencyResolver <Func <DbConnection, string, HistoryContext> >(HistoryContext.DefaultFactory));
            _resolvers.Add(new SingletonDependencyResolver <IPluralizationService>(new EnglishPluralizationService()));
            _resolvers.Add(new SingletonDependencyResolver <AttributeProvider>(new AttributeProvider()));
            _resolvers.Add(new SingletonDependencyResolver <Func <DbContext, Action <string>, DbCommandLogger> >((c, w) => new DbCommandLogger(c, w)));

#if NET40
            _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryResolver>(new Net40DefaultDbProviderFactoryResolver()));
#else
            _resolvers.Add(new SingletonDependencyResolver <IDbProviderFactoryResolver>(new DefaultDbProviderFactoryResolver()));
#endif
        }
예제 #5
0
 public virtual IEnumerable <object> GetServices(Type type, object key)
 {
     if (type == typeof(DbProviderServices))
     {
         DefaultProviderServicesResolver.CheckKey(key);
     }
     return(Enumerable.Empty <object>());
 }
예제 #6
0
 public RootDependencyResolver(
     DefaultProviderServicesResolver defaultProviderServicesResolver,
     DatabaseInitializerResolver databaseInitializerResolver)
 {
     this._databaseInitializerResolver = databaseInitializerResolver;
     this._resolvers.Add((IDbDependencyResolver) new TransactionContextInitializerResolver());
     this._resolvers.Add((IDbDependencyResolver)this._databaseInitializerResolver);
     this._resolvers.Add((IDbDependencyResolver) new DefaultExecutionStrategyResolver());
     this._resolvers.Add((IDbDependencyResolver) new CachingDependencyResolver((IDbDependencyResolver)defaultProviderServicesResolver));
     this._resolvers.Add((IDbDependencyResolver) new CachingDependencyResolver((IDbDependencyResolver) new DefaultProviderFactoryResolver()));
     this._resolvers.Add((IDbDependencyResolver) new CachingDependencyResolver((IDbDependencyResolver) new DefaultInvariantNameResolver()));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <IDbConnectionFactory>((IDbConnectionFactory) new SqlConnectionFactory()));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <Func <DbContext, IDbModelCacheKey> >(new Func <DbContext, IDbModelCacheKey>(new DefaultModelCacheKeyFactory().Create)));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <IManifestTokenResolver>((IManifestTokenResolver) new DefaultManifestTokenResolver()));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <Func <DbConnection, string, HistoryContext> >(HistoryContext.DefaultFactory));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <IPluralizationService>((IPluralizationService) new EnglishPluralizationService()));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <AttributeProvider>(new AttributeProvider()));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <Func <DbContext, Action <string>, DatabaseLogFormatter> >((Func <DbContext, Action <string>, DatabaseLogFormatter>)((c, w) => new DatabaseLogFormatter(c, w))));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <Func <TransactionHandler> >((Func <TransactionHandler>)(() => (TransactionHandler) new DefaultTransactionHandler()), (Func <object, bool>)(k => k is ExecutionStrategyKey)));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <IDbProviderFactoryResolver>((IDbProviderFactoryResolver) new DefaultDbProviderFactoryResolver()));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <Func <IMetadataAnnotationSerializer> >((Func <IMetadataAnnotationSerializer>)(() => (IMetadataAnnotationSerializer) new ClrTypeAnnotationSerializer()), (object)"ClrType"));
     this._resolvers.Add((IDbDependencyResolver) new SingletonDependencyResolver <Func <IMetadataAnnotationSerializer> >((Func <IMetadataAnnotationSerializer>)(() => (IMetadataAnnotationSerializer) new IndexAnnotationSerializer()), (object)"Index"));
 }
예제 #7
0
 public virtual object GetService(Type type, object key)
 {
     if (type == typeof(DbProviderServices))
     {
         throw new InvalidOperationException(Strings.EF6Providers_NoProviderFound((object)DefaultProviderServicesResolver.CheckKey(key)));
     }
     return((object)null);
 }