读petshop3.0--多层应用架构(z)
来源:互联网 发布:网络管理软件下载 编辑:程序博客网 时间:2024/05/17 10:03
petshop是C#实现的petstore,具体和技术无关的情况就不多介绍了。
petshop3.0比petshop1和2都有了较大的改变,主要是设计方面的。看一下里面的8个工程和1个站点就知道它肯定分了不少层。
一.概况介绍。
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。
Utility:
公用模块,一组帮助器类,其他业务层和数据访问层可能会使用到的一些公用方法。
petshop3.0比petshop1和2都有了较大的改变,主要是设计方面的。看一下里面的8个工程和1个站点就知道它肯定分了不少层。
一.概况介绍。
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。
Utility:
公用模块,一组帮助器类,其他业务层和数据访问层可能会使用到的一些公用方法。
- 读petshop3.0--多层应用架构(z)
- 读petshop3.0--多层应用架构
- petshop3.0--多层应用架构
- 企业多层分布式应用架构
- 企业多层分布式应用架构
- 企业多层分布式应用架构
- petshop3.0-jcc学习笔记(一)系统架构
- petshop3.0-jcc学习笔记(一)系统架构
- .NET三层经典架构PetShop3.0分析连载一
- .NET三层经典架构PetShop3.0分析之表现层
- .NET三层经典架构PetShop3.0分析连载一
- .NET三层经典架构PetShop3.0分析之表现层
- .NET三层经典架构PetShop3.0分析连载一
- .NET三层经典架构PetShop3.0分析连载[一]
- .NET三层经典架构PetShop3.0分析之表现层
- .NET三层经典架构PetShop3.0分析之表现层
- PB和EAServer共筑多层应用架构
- 基于J2EE轻量级架构的多层应用的研究
- 初识SOA
- Inno setup 5使用技巧
- 帮助文件的制作Microsoft Help Workshop 4.3 修正版
- 我的2005年
- 修改ACCESS数据库字段属性
- 读petshop3.0--多层应用架构(z)
- 两段经典的图片验证码程序之二
- 关于打印系列之一
- [Factory Method]:Source Sample
- C#操作XML
- 两段经典的图片验证码程序之一
- [php生成无限级select]用正则遍历数组生成,只查两次数据库
- ActiveX控件的MFC设计之旅-第3步
- Java用户界面本地化实例讲解