抽象工廠模式,BLL層如何使用工廠的代碼?

 

說明:書寫AbstractDALFactory的ChooseFactory()方法那一行時,如果先寫等號右邊的代碼時,不會出現智能感知,只有先寫等號左邊的代碼,才能出現 

 

namespace MySchool.BLL
{
    
public static class ClassManager
    
{
        
//調用數據訪問層統一數據訪問方式
        private static AbstractDALFactory factory = AbstractDALFactory.ChooseFactory();
        
private static IClassService classService = factory.CreateClass();
        
/// 通過班級名稱得到班級ID
        public static int GetClassIDByClassName(string className)
        
{
            
try
            
{
                
return Convert.ToInt32(classService.GetClassIDByClassName(className));
            }

            
catch (Exception ex)
            
{
                
throw new Exception(ex.ToString());
            }

        }

    }

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章