• 工厂模式概况


    一.概况介绍。
    Model:
    模型层,封装业务实体,一般和数据库模式对应。
    例如:
           public class AccountInfo {
     
                  // Internal member variables
                  private string _userId;
                  private string _password;
                  private string _email;
                  private AddressInfo _address;
                  private string _language;
                  private string _category;
                  private bool _showFavorites;
                  private bool _showBanners;
                  。。。
           }
    IDAL:
    数据访问接口层,主要是一些dao接口。
    例如:
           public interface IAccount
           {
                  AccountInfo SignIn(string userId, string password);
                  AddressInfo GetAddress(string userId);
                  void Insert(AccountInfo account);
                  void Update(AccountInfo Account);
           }
     
    OracleDAL:
    oracle实现的数据访问层。
     
    SQLServerDAL:
    sql实现的数据访问层。
    OracleDAL和SQLServerDAL中的类都实现了IDAL中的接口。属于dao实现。
     
    DALFactory
    负责确定是使用oracle实现还是mssql实现。通过在web.config中的配置确定使用哪一个dal实现(通过反射,动态生成访问类是PetShop.SQLServerDAL还是PetShop.OracleDAL命名空间中的类)。
                  <add key="WebDAL" value="PetShop.SQLServerDAL"/>
                  <add key="OrdersDAL" value="PetShop.SQLServerDAL"/>
           public class Account
           {
                  public static PetShop.IDAL.IAccount Create()
                  {                 
                          /// Look up the DAL implementation we should be using
                         string path = System.Configuration.ConfigurationSettings.AppSettings["WebDAL"];
                         string className = path + ".Account";
     
                         // Using the evidence given in the config file load the appropriate assembly and class
                         return (PetShop.IDAL.IAccount) Assembly.Load(path).CreateInstance(className);
                  }
           }
     
    BLL:
    业务访问层。通过DALFactory,读取配置,决定使用何种dal实现。
           public class Account {        
                   public AccountInfo SignIn(string userId, string password) {
     
     
                         if ((userId.Trim() == string.Empty) || (password.Trim() == string.Empty))
                                return null;
     
                         // 通过DALFactory调用具体的dal实现。
                         IAccount dal = PetShop.DALFactory.Account.Create();
     
                         // Try to sign in with the given credentials
                         AccountInfo account = dal.SignIn(userId, password);
     
                         // Return the account
                         return account;
                  }
                  。。。
    }
     
    Web:
    表现层,主要包括了Web 页面(aspx)和用户控件(ascx)控件及自定义服务器控件SimplePager和ViewStatePager。

  • 相关阅读:
    c++新特性之std::atomic
    PyQt 演示Demo1
    RxCPP(二)关键元素
    c++11 random_device 真随机数最简单应用
    PyQT5 安装与入门
    RxCPP(一)编程模型入门 调度
    RxCpp(四)Qt/GUI编程
    RxCPP(一)编程模型入门
    Flask 学习80.FlaskRESTX使用reqparse 解析器trim=True去掉字符两边空格 上海
    Flask 学习81.FlaskRESTX使用reqparse 解析器去掉值为None的参数 上海
  • 原文地址:https://www.cnblogs.com/strivers/p/1864449.html
Copyright © 2020-2023  润新知