惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
T
Tor Project blog
G
GRAHAM CLULEY
S
Security Affairs
P
Palo Alto Networks Blog
TaoSecurity Blog
TaoSecurity Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
aimingoo的专栏
aimingoo的专栏
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 三生石上(FineUI控件)
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CERT Recently Published Vulnerability Notes
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
Check Point Blog
宝玉的分享
宝玉的分享
Forbes - Security
Forbes - Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
The Last Watchdog
The Last Watchdog
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
H
Heimdal Security Blog
Recorded Future
Recorded Future
L
LangChain Blog
WordPress大学
WordPress大学
Know Your Adversary
Know Your Adversary
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog
B
Blog
H
Help Net Security
T
Tailwind CSS Blog
The Hacker News
The Hacker News
雷峰网
雷峰网
P
Proofpoint News Feed
博客园 - Franky
Attack and Defense Labs
Attack and Defense Labs
有赞技术团队
有赞技术团队
S
Schneier on Security
T
Troy Hunt's Blog
云风的 BLOG
云风的 BLOG
Hacker News - Newest:
Hacker News - Newest: "LLM"
Blog — PlanetScale
Blog — PlanetScale
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed

博客园 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!)

好久没发言了,随便写一个吧 ASP.NET WEB FORM 子父窗体之间参数的传递 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) showModalDialog子窗口怎样向父窗口传参数 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 javascrpt 退出灰色 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 怎样使一个层垂直居中于浏览器中 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 梅花雨日历Demo(VS2005) 在配置使用Membership或其他的Providers的ASP.NET2.0时一定要设置applicationName属性 怎么在ASP.NET 2.0中使用Membership ASP.NET结合存储过程写的通用搜索分页程序 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 存储过程分页 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!) - 博客园 PetShop 4架构分析 17种正则表达式 利用Visual C#实现任务栏通知窗口 C#中父窗口和子窗口之间实现控件互操作 ASP.NET动态生成HTML页面 转换字符串中汉字为其拼音缩写(C#) 在C#中设置打印机纸张大小,如此简单 最好用的在线编辑器CuteEditor 好几天没有些东西了
PetShop4.0 工厂模式及Profile Provider实现
怎能笑的私藏(藏什么呀?还没有想好,乱堆!) · 2006-09-18 · via 博客园 - 怎能笑的私藏(藏什么呀?还没有想好,乱堆!)

第一部份:工厂模式

一、项目名称及描述:(实现步骤为:4-3-6-5-2-1)
1、WEB=表示层
2、BLL=业务逻辑层
3、IDAL=数据访问层接口定义
4、Model=业务实体
5、DALFactory=数据层的抽象工厂(创建反射)
6、SQLServerDAL=SQLServer数据访问层 / oracleDAL=Oracle数据访问层

DBUtility 数据库访问组件基础类

二、项目引用关系
1、Web 引用 BLL。
2、BLL 引用 IDAL,Model,使用DALFactory创建实例。
3、IDAL 引用 Model。
4、Model 无引用。
5、DALFactory 引用IDAL,通过读取web.config里设置的程序集,加载类的实例,返回给BLL使用。
6、SQLServerDAL 引用 Model和IDAL,被DALFactory加载的程序集,实现接口里的方法。

三、实现步骤
1、创建Model,实现业务实体。
2、创建IDAL,实现接口。
3、创建SQLServerDAL,实现接口里的方法。
4、增加web.config里的配置信息,为SQLServerDAL的程序集。
5、创建DALFactory,返回程序集的指定类的实例。
6、创建BLL,调用DALFactory,得到程序集指定类的实例,完成数据操作方法。
7、创建WEB,调用BLL里的数据操作方法。

注意:
1、web.config里的程序集名称必须与SQLServerDAL里的输出程序集名称一致。
2、DALFactory里只需要一个DataAccess类,可以完成创建所有的程序集实例。
3、项目创建后,注意修改各项目的默认命名空间和程序集名称。
4、注意修改解决方案里的项目依赖。
5、注意在解决方案里增加各项目引用。

第二部份:Profile的使用(也是工厂方法)
概述:PetShop的Profile通过自己的ProfileProvider来实现。

一、项目名称及描述
1、Profile=Profile的数据访问层
2、ProfileDALFactory=ProfileDAL的工厂类(反射创建ProfileDAL)
3、IProfileDAL=Profile的数据访问层接口定义
4、SQLProfileDAL=SQL Server 的Profile Providers 做用户状态管理

二、项目引用关系
1、Profile 引用 ProfileDALFactory,IProfileDAL,Model。通过ProfileDALFactory的方法创建程序集实例。
2、ProfileDALFactory 引用 IProfileDAL。实现程序集实例的方法。
3、IProfileDAL 引用 Model。实现接口。
4、SQLProfileDAL 引用 Model,IProfileDAL。被ProfileDALFactory加载的程序集,实现接口里的方法。

三、实现步骤
1、创建Model,实现业务实体。
2、创建IProfileDAL,实现接口。
3、创建SQLProfileDAL,实现接口里的方法。
4、增加web.config里的配置信息,为SQLProfileDAL的程序集。
5、创建ProfileDALFactory,返回程序集的指定类的实例。
6、创建Profile,实现Profile Provider。
7、在web.config文件中增加配置节profile,增加属性及类型,provider为Profile。
例:
<system.web>
<profileautomaticSaveEnabled="false" defaultProvider="默认的Profile Provider">
<providers>
<addname="自己命名的Provider名称" connectionStringName="配置文件里的数据库链接名称" type="自己的Provider实现类,需要自己重写" applicationName="自己定义的应用程序名称"/>
</providers>
<properties>
<addname="自己命名的Profile名称" type="自己的类,需要构建" allowAnonymous="false" provider="上面的自己命名的Provider名称"/>
</properties>
</profile>
</system.web>

注意事项:
1、Profile的type可以为自己的类,包括业务实例或方法等。
2、通过重写ProfileProvider里的部份方法,实现在自己的数据库里记录自己想要的个性化用户信息。
3、如果每个用户有大量的数据信息,则该类数据信息不要通过Profile来记录。
4、被定义为Profile的type的类,必须在类定义前增加[Serializable]以实现可序列化。
5、接口定义的类型必须为类。
6、Profile Provider类里必须增加System.Web.Profile和System.Configuration的引用到项目中。
7、如果需要支持匿名用户,增加<anonymousIdentification enabled="true" />到web.config里,在profile之间。
8、使用Profile.Save方法后,将调用ProfileDALFactory里的方法将数据保存到数据库。