public InitializerConfig(EntityFrameworkSection entityFrameworkSettings, KeyValueConfigurationCollection appSettings)
        {
            DebugCheck.NotNull(entityFrameworkSettings);
            DebugCheck.NotNull(appSettings);

            _entityFrameworkSettings = entityFrameworkSettings;
            _appSettings = appSettings;
        }
        internal AppConfig(
            ConnectionStringSettingsCollection connectionStrings,
            KeyValueConfigurationCollection appSettings,
            EntityFrameworkSection entityFrameworkSettings,
            ProviderServicesFactory providerServicesFactory = null)
        {
            DebugCheck.NotNull(connectionStrings);

            _connectionStrings = connectionStrings;
            _appSettings = appSettings ?? new KeyValueConfigurationCollection();
            _entityFrameworkSettings = entityFrameworkSettings ?? new EntityFrameworkSection();
            _providerServicesFactory = providerServicesFactory ?? new ProviderServicesFactory();

            _providerServices = new Lazy<IList<NamedDbProviderService>>(
                () => _entityFrameworkSettings
                          .Providers
                          .OfType<ProviderElement>()
                          .Select(
                              e => new NamedDbProviderService(
                                       e.InvariantName,
                                       _providerServicesFactory.GetInstance(e.ProviderTypeName, e.InvariantName)))
                          .ToList());

            if (_entityFrameworkSettings.DefaultConnectionFactory.ElementInformation.IsPresent)
            {
                _defaultConnectionFactory = new Lazy<IDbConnectionFactory>(
                    () =>
                        {
                            var setting = _entityFrameworkSettings.DefaultConnectionFactory;

                            try
                            {
                                var type = setting.GetFactoryType();
                                var args = setting.Parameters.GetTypedParameterValues();
                                return (IDbConnectionFactory)Activator.CreateInstance(type, args);
                            }
                            catch (Exception ex)
                            {
                                throw new InvalidOperationException(
                                    Strings.SetConnectionFactoryFromConfigFailed(setting.FactoryTypeName), ex);
                            }
                        }, isThreadSafe: true);
            }
            else
            {
                _defaultConnectionFactory = _defaultDefaultConnectionFactory;
            }
        }
        internal AppConfig(
            ConnectionStringSettingsCollection connectionStrings,
            KeyValueConfigurationCollection appSettings,
            EntityFrameworkSection entityFrameworkSettings)
        {
            //Contract.Requires(connectionStrings != null);

            _connectionStrings = connectionStrings;
            _appSettings = appSettings;
            _entityFrameworkSettings = entityFrameworkSettings ?? new EntityFrameworkSection();

            if (_entityFrameworkSettings.DefaultConnectionFactory.ElementInformation.IsPresent)
            {
                _defaultConnectionFactory = new Lazy<IDbConnectionFactory>(
                    () =>
                        {
                            var setting = _entityFrameworkSettings.DefaultConnectionFactory;

                            try
                            {
                                var type = setting.GetFactoryType();
                                var args = setting.Parameters.GetTypedParameterValues();
                                return (IDbConnectionFactory)Activator.CreateInstance(type, args);
                            }
                            catch (Exception ex)
                            {
                                throw new InvalidOperationException(
                                    Strings.SetConnectionFactoryFromConfigFailed(setting.FactoryTypeName), ex);
                            }
                        }, isThreadSafe: true);
            }
            else
            {
                _defaultConnectionFactory = _defaultDefaultConnectionFactory;
            }
        }
Exemple #4
0
        public ProviderConfig(EntityFrameworkSection entityFrameworkSettings)
        {
            DebugCheck.NotNull(entityFrameworkSettings);

            _entityFrameworkSettings = entityFrameworkSettings;
        }
        public QueryCacheConfig(EntityFrameworkSection entityFrameworkSection)
        {
            DebugCheck.NotNull(entityFrameworkSection);

            _entityFrameworkSection = entityFrameworkSection;
        }
        public ProviderConfig(EntityFrameworkSection entityFrameworkSettings)
        {
            //Contract.Requires(entityFrameworkSettings != null);

            _entityFrameworkSettings = entityFrameworkSettings;
        }
 public ProviderConfig(EntityFrameworkSection entityFrameworkSettings)
 {
     _entityFrameworkSettings = entityFrameworkSettings;
 }