Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //使用MSSQL連線
            DBConnectFactory factory   = new DBConnectFactory();
            IDBConnection    mssqlConn = factory.GetConnection(ConnectionEnum.MSSQL);

            mssqlConn.DoConnect();

            //使用Oracle連線
            IDBConnection oracleConn = factory.GetConnection(ConnectionEnum.Oracle);

            oracleConn.DoConnect();

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //分別建立工廠
            DBConnectFactory mssqlFactory  = new MSSQLConnectFactory();
            IDBConnection    mssqlConn     = mssqlFactory.CreateDBConnectFactory();
            DBConnectFactory oracleFacotry = new OracleConnectFactory();
            IDBConnection    oracleConn    = oracleFacotry.CreateDBConnectFactory();
            DBConnectFactory mysqlFactory  = new MYSQLConnectFactory();
            IDBConnection    mysqlConn     = mysqlFactory.CreateDBConnectFactory();

            //開始生產(建立連線)
            mssqlConn.DoConnect();
            oracleConn.DoConnect();
            mysqlConn.DoConnect();

            Console.ReadLine();
        }