www.pudn.com > WorkflowDesigner.rar > DataAccessFactory.cs, change:2007-11-16,size:1616b


using System; 
using System.Configuration; 
namespace DataAccess 
{ 
	/// <summary> 
	/// DataAccessHelper  
	/// </summary> 
	public sealed class DataAccessFactory 
	{ 
		private DataAccessFactory(){} 
		private static DatabaseProperty defaultDatabaseProperty; 
		public static DatabaseProperty DefaultDatabaseProperty 
		{ 
			get{return defaultDatabaseProperty;} 
			set{defaultDatabaseProperty=value;} 
		} 
		public static IDataAccess CreateDataAccess(DatabaseProperty pp) 
		{ 
			IDataAccess dataAccess; 
			switch(pp.DatabaseType) 
			{ 
				case(DatabaseType.MSSQLServer): 
					dataAccess = new MSSqlDataAccess(pp.ConnectionString); 
					break; 
				case(DatabaseType.Oracle): 
					dataAccess = new OracleDataAccess(pp.ConnectionString); 
					break; 
				case(DatabaseType.OleDBSupported): 
					dataAccess = new OleDbDataAccess(pp.ConnectionString); 
					break; 
				default: 
					dataAccess=new MSSqlDataAccess(pp.ConnectionString); 
					break; 
			} 
			return dataAccess; 
		} 
		public static IDataAccess CreateDataAccess() 
		{ 
            defaultDatabaseProperty.ConnectionString = ConfigurationSettings.AppSettings["ConnectionString"].ToString(); 
            defaultDatabaseProperty.DatabaseType = (DatabaseType)Enum.Parse(typeof(DatabaseType), ConfigurationSettings.AppSettings["DatabaseType"].ToString()); 
            defaultDatabaseProperty.UserID = ConfigurationSettings.AppSettings["UserID"].ToString(); 
            defaultDatabaseProperty.UserID = ConfigurationSettings.AppSettings["Password"].ToString(); 
            return CreateDataAccess(defaultDatabaseProperty); 
		} 
	} 
}