/// <summary>
		/// 
		/// </summary>
		/// <param name="settings"></param>
		/// <returns></returns>
		public static IConnectionProvider NewConnectionProvider(IDictionary settings)
		{
			IConnectionProvider connections = null;
			string providerClass = settings[Environment.ConnectionProvider] as string;
			if (providerClass != null)
			{
				try
				{
					log.Info("Initializing connection provider: " + providerClass);
					connections = (IConnectionProvider) Activator.CreateInstance(ReflectHelper.ClassForName(providerClass));
				}
				catch (Exception e)
				{
					log.Fatal("Could not instantiate connection provider", e);
					throw new HibernateException("Could not instantiate connection provider: " + providerClass, e);
				}
			}
			else if (settings[Environment.ConnectionString] != null || settings[Environment.ConnectionStringName] != null)
			{
				connections = new DriverConnectionProvider();
			}
			else
			{
				log.Info("No connection provider specified, UserSuppliedConnectionProvider will be used.");
				connections = new UserSuppliedConnectionProvider();
			}
			connections.Configure(settings);
			return connections;
		}
Ejemplo n.º 2
0
        // cannot be instantiated
        public static IConnectionProvider NewConnectionProvider(IDictionary <string, string> settings)
        {
            IConnectionProvider connections;
            string providerClass;

            if (settings.TryGetValue(Environment.ConnectionProvider, out providerClass))
            {
                try
                {
                    log.Info("Initializing connection provider: " + providerClass);
                    connections =
                        (IConnectionProvider)
                        Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(providerClass));
                }
                catch (Exception e)
                {
                    log.Fatal("Could not instantiate connection provider", e);
                    throw new HibernateException("Could not instantiate connection provider: " + providerClass, e);
                }
            }
            else if (settings.ContainsKey(Environment.ConnectionString) || settings.ContainsKey(Environment.ConnectionStringName))
            {
                connections = new DriverConnectionProvider();
            }
            else
            {
                log.Info("No connection provider specified, UserSuppliedConnectionProvider will be used.");
                connections = new UserSuppliedConnectionProvider();
            }
            connections.Configure(settings);
            return(connections);
        }
		public static IConnectionProvider NewConnectionProvider(IDictionary<string, string> settings)
		{
			IConnectionProvider connections;
			string providerClass;
			if (settings.TryGetValue(Environment.ConnectionProvider, out providerClass))
			{
				try
				{
					log.Info("Initializing connection provider: " + providerClass);
					connections =
						(IConnectionProvider)
						Environment.BytecodeProvider.ObjectsFactory.CreateInstance(ReflectHelper.ClassForName(providerClass));
				}
				catch (Exception e)
				{
					log.Fatal("Could not instantiate connection provider", e);
					throw new HibernateException("Could not instantiate connection provider: " + providerClass, e);
				}
			}
			else if (settings.ContainsKey(Environment.ConnectionString) || settings.ContainsKey(Environment.ConnectionStringName))
			{
				connections = new DriverConnectionProvider();
			}
			else
			{
				log.Info("No connection provider specified, UserSuppliedConnectionProvider will be used.");
				connections = new UserSuppliedConnectionProvider();
			}
			connections.Configure(settings);
			return connections;
		}
        /// <summary>
        ///
        /// </summary>
        /// <param name="settings"></param>
        /// <returns></returns>
        public static IConnectionProvider NewConnectionProvider(IDictionary settings)
        {
            IConnectionProvider connections = null;
            string providerClass            = settings[Environment.ConnectionProvider] as string;

            if (providerClass != null)
            {
                try
                {
                    log.Info("Intitializing connection provider: " + providerClass);
                    connections = ( IConnectionProvider )Activator.CreateInstance(ReflectHelper.ClassForName(providerClass));
                }
                catch (Exception e)
                {
                    log.Fatal("Could not instantiate connection provider", e);
                    throw new HibernateException("Could not instantiate connection provider: " + providerClass);
                }
            }
            else
            {
                connections = new UserSuppliedConnectionProvider();
            }
            connections.Configure(settings);
            return(connections);
        }