freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

畢業(yè)設(shè)計----個人博客系統(tǒng)的設(shè)計與實現(xiàn)(參考版)

2024-12-05 18:07本頁面
  

【正文】 業(yè)務(wù)邏輯 層的實現(xiàn) 由于本課題中業(yè)務(wù)邏輯比較簡單,所以業(yè)務(wù)邏輯層的實現(xiàn)也比較簡單,基本是對數(shù)據(jù)訪問層操作的封裝,讓表示層與數(shù)據(jù)訪問層解耦。 SetNullableValue、 GetNullableValue 這兩個方法其實主要是方便數(shù)據(jù)庫中的空值和 C代碼中 NULL 進(jìn)行轉(zhuǎn)換。 connectionString 這個 是靜態(tài)的字段,包含了數(shù)據(jù)訪問的連接。這個類是密封類,不可以繼承(也無需繼承)。 } /// summary 24 /// Execute the sql query, then return the rows39。 } /// summary /// Get nullable value /// /summary /// param name=fieldValue/param /// returns/returns public static object GetNullableValue(object fieldValue) { if (fieldValue == ) return null。 } } /// summary /// Set nullable value to parameters /// /summary /// param name=fieldValue/param /// param name=parameter/param public static void SetNullableValue(object fieldValue, SqlParameter parameter) { if (fieldValue == null) = 。 = cmdType。 = connection。 代碼分析五( ): public sealed class SQLServerHelper { //Sql server connection string public static readonly string connectionString = [SQLServerConnectionString]。 } ?? 部分代碼省略 ?? } 23 } 3. SQLServer:類庫。 } /// summary /// Create leavewords logic class /// /summary /// returns/returns public static ILeavewordsBLL CreateLeavewordsBLL() { return (ILeavewordsBLL)(LeavewordsBLL)。 namespace { /// summary /// Business Logic Layer factory, create the specified logic object /// Using Abstract Factory, Facace Design Pattern and Reflection, Caching mechanism /// /summary public sealed class BLLFactory { /// summary /// Create blog settings logic class /// /summary /// returnsBlogInfo BLL/returns public static IBlogInfoBLL CreateBlogInfoBLL() { return (IBlogInfoBLL)(BlogInfoBLL)。 using 。 using 。 } /// summary /// Create Leavewords data access layer class 22 /// /summary /// returnsLeavewords DAL/returns public static ILeavewordsDAL CreateLeavewordsDAL() { return (ILeavewordsDAL)(LeavewordsDAL)。 namespace { public sealed class DALFactory { /// summary /// Create BlogInfo data access layer class /// /summary /// returnsBlogInfo DAL/returns public static IBlogInfoDAL CreateBlogInfoDAL() { return (IBlogInfoDAL)(BlogInfoDAL)。 using 。 using 。然后 先去緩存里找,如果有就返回如果沒有就 利用反射把對象 Create出來,同時也會 把這個對象插入到緩存中去。第一句,會從緩存里根據(jù)一個 Key取出一個 完整的命名空間的名字,如果不存在則會到,同時會插入到緩存中去。只不過讀取的 節(jié)點不一樣。其實從名稱都可以知道是做什么用處的。 } return fullBLLObject。 fullBLLObject = (bllName).CreateInstance(fullBLLClassName)。 if (fullBLLObject == null) { //BLL class name doesn39。 //Get the full BLL class name string fullBLLClassName = bllName + . + className。 (BLL, bllObject, fileDependency)。t exist in the cache, //then insert new one into the cache CacheDependency fileDependency = new CacheDependency(())。 } /// summary /// Get BLL object method. /// /summary /// param name=classNameThe name of the BLL class/param /// returnsThe object value/returns public static object GetBLLObject(string className) { //Get BLL namespace from cache object bllObject = (BLL)。 (className, fullDALObject, fileDependency)。t exist in the cache, //then insert new one into the cache CacheDependency fileDependency = new CacheDependency(())。 //Get DAL class from cache object fullDALObject = (className)。 } //Convert object type to string type, then get the DAL namespace string dalName = ()。 dalObject = [DAL].ToString()。 if (dalObject == null) { //DAL namespace doesn39。 using 。 using 。另一個方法是把一個對象往緩存里面加,注意最后一個參數(shù)是一個緩存依賴,這個參數(shù)是指如果這個依賴的文件 (或者其他什么 )一旦變化了,那么緩存里的東西就會銷毀。顧名思義就是一個從緩存里取,一個 是把對象 往緩存里加。 (key, value, cacheDependency)。 return cache[key]。 using 。 using 。 using 。產(chǎn)生 DAL 或者 BLL 的實現(xiàn)。 文件列表如圖 211。 圖 212 數(shù)據(jù)訪問模塊 1. DAL:類庫。樸素實現(xiàn)的示意圖如圖 211 所示。在本 系統(tǒng)的實現(xiàn) 中,將各種封裝對數(shù)據(jù)庫操作的輔助類叫做 DALHelper 類,如對 SQLServer 數(shù)據(jù)庫進(jìn)行操作的輔助類就叫做 SQLServerHelper,它包含了四個方法: ExecuteSQLNonQurey、 ExecuteSQLReader、ExecuteProcedureNonQurey、 ExecuteProcedureReader,分別用于執(zhí)行 存儲過程返回不同的結(jié)果 。在本系統(tǒng)中都將采用存儲過程。 5. 返回結(jié)果。 2. 生成存儲過程可用參數(shù)形式。 4. 返回結(jié)果。 2. 動態(tài)組合 SQL 語句。 具體到本課題中,數(shù)據(jù)訪問層的樸素實現(xiàn)操作一般分為 以下兩種方式 。本系統(tǒng)采用 數(shù)據(jù)訪問層的樸素實現(xiàn),就是指傳統(tǒng)的通過執(zhí)行 SQL 語句或調(diào)用存儲過程實現(xiàn)對數(shù)據(jù)庫的操作。 數(shù)據(jù) 訪問層的實現(xiàn) 數(shù)據(jù)訪問層的實現(xiàn)一般有兩種方式: 基于樸素的 實現(xiàn)和基于 ORM 框架的實現(xiàn) 。例如 SQLServerDAL 下和 OracleDAL 下都有 UserInfoDAL,至于運行時具體實例化哪個,是通過 中配置實現(xiàn)的。實際上, IDAL 和 IBLL 分別是一個工程,它里面是一組接口,這里不是指工廠直接實例化接口 17 (實際上接口也是不可能被實例化的)。 最終反射工廠結(jié)構(gòu)圖如圖29所示。 有了反射機制,我們就可以從配置文件(一般是在 )讀出配置信息后,不是根據(jù)這個信息實例化相應(yīng)的 工廠,而是讓反射工廠通過這些信息,動態(tài)加載相應(yīng)程序集中的類,這樣每個層次只需要一個工廠就可以完成依賴注入,即使以后出現(xiàn)新的實現(xiàn),也不需要修改或添加工廠,只要在配置文件中寫明程序集的名字即可。它幫助程序設(shè)計人員在程序運行時利用一些信息去動態(tài)地使用類型,這些信息在設(shè)計時是未知的,這種能力可以用于后期綁定。而利用反射機制簡化后的 Abstract Factory 則可以叫做 Reflection Abstract Factory,也叫反射工廠。因此,當(dāng)層次的實現(xiàn)過多時,整個系統(tǒng)就會存在很多工廠,這些工廠不僅使代碼變得臃腫,也難以維護(hù)。從上文可以看出,就數(shù)據(jù)訪問層而言,每個數(shù)據(jù)訪問層實現(xiàn)都要對應(yīng)一個工廠,業(yè)務(wù)邏輯層當(dāng)然也是如此。如圖 28所示。此時,用戶和帖子的業(yè)務(wù)邏輯層類 UserBLL 與 PostBLL 作為客戶類,不應(yīng)該與具體的數(shù)據(jù)訪問層類耦合,而應(yīng)該先定義接口 IUserDAL 與 IPostDAL 接 口 , 讓 業(yè) 務(wù) 邏 輯 層 與 這 兩 個 接 口 耦 合 。它的中文譯名叫做“抽象工廠” , 其定義是這樣的:提供一個接口,用于創(chuàng)建相關(guān)或依賴對象的家族,而不需要指定具體類。 鑒于 .NET 平臺上的“反射”機制對依賴
點擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1