﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-dotnet2004-最新评论</title><link>http://www.cnblogs.com/dotnet2004/CommentsRSS.aspx</link><description /><language>zh-cn</language><pubDate>Tue, 30 Nov 2004 09:20:09 GMT</pubDate><lastBuildDate>Tue, 30 Nov 2004 09:20:09 GMT</lastBuildDate><generator>cnblogs</generator><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/12/04/71066.html#72782</link><dc:creator>Stephen</dc:creator><author>Stephen</author><pubDate>Sat, 04 Dec 2004 06:00:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/12/04/71066.html#72782</guid><description><![CDATA[谢谢大家的热心！特别感谢wayfarer ，写得清晰有条理，让我受益匪浅！：）<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">Stephen</a> 2004-12-04 14:00 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/12/04/71066.html#72782#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/12/03/71066.html#72290</link><dc:creator>yyanghhong</dc:creator><author>yyanghhong</author><pubDate>Thu, 02 Dec 2004 17:33:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/12/03/71066.html#72290</guid><description><![CDATA[我采用Adapter Pattern和IOC的Dependency Injection Pattern做过这种设计, 施行过程大概是这样的, <br><br>不一上来就做框架, 先用其中一个provider做几个通用的例子, 比如用SQLClient调用Stored proc, query, insert.. 然后用Refactorting里的Extract Interface方法, 先做一个DBAdapter interface, 再做一个类SQLClientAdapter把所有和 SQLClient相关的操作都提取出来, 做为DBAdapter和SQLClientAdapter的方法, 如果你的应用需要访问oracle, 再做一个OracleClientAdapter, 实现DBAdapter 的所有方法.<br><br><br>这样一来你的程序只需要用到DBAdapter interface, 然后用IOC的Dependency Injection Pattern方法创建 DBAdapter(可以用spring.net或pico.net),  这样你就可以通过修改配置文件来切换adapter了. <br><br>当然也可以用Factory Method Pattern的方法来配置Adapter, 不过始终需要修改code, IOC其实是对Factory Method Pattern的一种加强, 并且他还可以替换Singleton Pattern 和Prototype Pattern<br><br><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">yyanghhong</a> 2004-12-03 01:33 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/12/03/71066.html#72290#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/12/01/71066.html#71249</link><dc:creator>烂瓶子</dc:creator><author>烂瓶子</author><pubDate>Tue, 30 Nov 2004 16:11:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/12/01/71066.html#71249</guid><description><![CDATA[<P /><DIV style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid"><DIV><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" width="11" align="top" /><SPAN style="COLOR: #0000ff">using</SPAN><SPAN style="COLOR: #000000"> System;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" width="11" align="top" /></SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000"> XTEAM.XBLOG.Common<br /><IMG id="Codehighlighter1_44_3425_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_44_3425_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" width="11" align="top" style="DISPLAY: none" /></SPAN><SPAN id="Codehighlighter1_44_3425_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_44_3425_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">enum</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider<br /><IMG id="Codehighlighter1_77_109_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_77_109_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />    </SPAN><SPAN id="Codehighlighter1_77_109_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_77_109_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        SQLServer </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        OLEDB </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />    }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> ConnectionString<br /><IMG id="Codehighlighter1_143_446_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_143_446_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />    </SPAN><SPAN id="Codehighlighter1_143_446_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_143_446_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> ConnectionString()<br /><IMG id="Codehighlighter1_176_180_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_176_180_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_176_180_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_176_180_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> strConnectionString </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> getConnectionString()<br /><IMG id="Codehighlighter1_283_443_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_283_443_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_283_443_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_283_443_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(strConnectionString </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)<br /><IMG id="Codehighlighter1_323_408_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_323_408_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_323_408_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_323_408_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                strConnectionString </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">从web.config文件中获得连接字符串 获取Web.config参数的方法还没写，注意用异常</SPAN><SPAN style="COLOR: #008000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" /></SPAN><SPAN style="COLOR: #000000">            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> strConnectionString;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />    }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> DataBaseProviderString<br /><IMG id="Codehighlighter1_487_826_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_487_826_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />    </SPAN><SPAN id="Codehighlighter1_487_826_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_487_826_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> DataBaseProviderString()<br /><IMG id="Codehighlighter1_526_530_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_526_530_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_526_530_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_526_530_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> strDataBaseProviderString </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> getDataBaseProviderString()<br /><IMG id="Codehighlighter1_645_823_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_645_823_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_645_823_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_645_823_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(strDataBaseProviderString </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)<br /><IMG id="Codehighlighter1_691_782_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_691_782_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_691_782_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_691_782_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                strDataBaseProviderString </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">""</SPAN><SPAN style="COLOR: #000000">;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">从web.config文件中获得数据源类型 获取Web.config参数的方法还没写，注意用异常</SPAN><SPAN style="COLOR: #008000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" /></SPAN><SPAN style="COLOR: #000000">            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> strDataBaseProviderString;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />    }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">sealed</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> DataBaseProviderFactory<br /><IMG id="Codehighlighter1_875_1367_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_875_1367_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />    </SPAN><SPAN id="Codehighlighter1_875_1367_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_875_1367_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider dataBaseProvider;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> DataBaseProviderFactory()<br /><IMG id="Codehighlighter1_966_1273_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_966_1273_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_966_1273_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_966_1273_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">从web.config文件中获得连接数据源类型</SPAN><SPAN style="COLOR: #008000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /></SPAN><SPAN style="COLOR: #000000">            </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> strDataBaseProviderString </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> DataBaseProviderString.getDataBaseProviderString();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(strDataBaseProviderString </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> )<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                dataBaseProvider </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.SQLServer;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(strDataBaseProviderString </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                dataBaseProvider </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.OLEDB;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider getDataBaseProvider()<br /><IMG id="Codehighlighter1_1332_1364_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_1332_1364_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_1332_1364_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_1332_1364_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> dataBaseProvider;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />    }</SPAN></SPAN><SPAN style="COLOR: #000000"> <br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />    </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">sealed</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> DataFactory<br /><IMG id="Codehighlighter1_1409_3378_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_1409_3378_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />    </SPAN><SPAN id="Codehighlighter1_1409_3378_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_1409_3378_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG id="Codehighlighter1_1434_1435_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_1434_1435_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> DataFactory()</SPAN><SPAN id="Codehighlighter1_1434_1435_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_1434_1435_Open_Text"><SPAN style="COLOR: #000000">{}</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> IDbConnection CreateEmptyConnection()<br /><IMG id="Codehighlighter1_1495_1798_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_1495_1798_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_1495_1798_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_1495_1798_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            IDbConnection conn </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(DataBaseProviderFactory.getDataBaseProvider() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.OLEDB)<br /><IMG id="Codehighlighter1_1609_1648_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_1609_1648_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_1609_1648_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_1609_1648_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                conn </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> OleDbConnection();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(DataBaseProviderFactory.getDataBaseProvider() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.SQLServer)<br /><IMG id="Codehighlighter1_1741_1778_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_1741_1778_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_1741_1778_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_1741_1778_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                conn </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> SqlConnection();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> conn;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">        internal static IDbConnection CreateConnection()<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">        {<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">            IDbConnection conn = DataFactory.CreateEmptyConnection();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">            conn.ConnectionString = ConnectionString.getConnectionString();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">            return conn;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">        }</SPAN><SPAN style="COLOR: #008000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /></SPAN><SPAN style="COLOR: #000000">        </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> IDbCommand CreateEmptyCommand()<br /><IMG id="Codehighlighter1_2124_2418_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_2124_2418_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_2124_2418_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_2124_2418_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            IDbCommand comm </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(DataBaseProviderFactory.getDataBaseProvider() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.OLEDB)<br /><IMG id="Codehighlighter1_2235_2271_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_2235_2271_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_2235_2271_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_2235_2271_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                comm </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> OleDbCommand();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(DataBaseProviderFactory.getDataBaseProvider() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.SQLServer)<br /><IMG id="Codehighlighter1_2364_2398_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_2364_2398_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_2364_2398_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_2364_2398_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                comm </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> SqlCommand();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> comm;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">        internal static IDCommand CreateCommand()<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">        {<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">            IDbCommand comm = DataFactory.CreateEmptyCommand();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">            comm.Connection = DataFactory.CreateConnection();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">            return comm;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">        }</SPAN><SPAN style="COLOR: #008000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /></SPAN><SPAN style="COLOR: #000000">        </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> IDataAdapter CreateDataAdapter()<br /><IMG id="Codehighlighter1_2718_3018_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_2718_3018_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_2718_3018_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_2718_3018_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            IDataAdapter adp </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(DataBaseProviderFactory.getDataBaseProvider() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.OLEDB)<br /><IMG id="Codehighlighter1_2830_2869_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_2830_2869_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_2830_2869_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_2830_2869_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                adp </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> OleDbDataAdapter();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(DataBaseProviderFactory.getDataBaseProvider() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.SQLServer)<br /><IMG id="Codehighlighter1_2962_2999_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_2962_2999_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_2962_2999_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_2962_2999_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                adp </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> SqlDataAdapter();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> adp;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #0000ff">internal</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> IDataParameter CreateParameter()<br /><IMG id="Codehighlighter1_3073_3375_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_3073_3375_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />        </SPAN><SPAN id="Codehighlighter1_3073_3375_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_3073_3375_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            IDataParameter para </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(DataBaseProviderFactory.getDataBaseProvider() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.OLEDB)<br /><IMG id="Codehighlighter1_3188_3226_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_3188_3226_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_3188_3226_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_3188_3226_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                para </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> OleDbParameter();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(DataBaseProviderFactory.getDataBaseProvider() </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> DataBaseProvider.SQLServer)<br /><IMG id="Codehighlighter1_3319_3355_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_3319_3355_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />            </SPAN><SPAN id="Codehighlighter1_3319_3355_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_3319_3355_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />                para </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> SqlParameter();<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />            }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> para;<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />        }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" />    }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" /><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">sealed</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> DataHelper<br /><IMG id="Codehighlighter1_3414_3423_Open_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" width="11" align="top" /><IMG id="Codehighlighter1_3414_3423_Closed_Image" height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" width="11" align="top" style="DISPLAY: none" />    </SPAN><SPAN id="Codehighlighter1_3414_3423_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG height="20" src="http://www.cnblogs.com/images/dot.gif" width="15" /></SPAN><SPAN id="Codehighlighter1_3414_3423_Open_Text"><SPAN style="COLOR: #000000">{<br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" width="11" align="top" />        </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">略</SPAN><SPAN style="COLOR: #008000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" width="11" align="top" /></SPAN><SPAN style="COLOR: #000000">    }</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" width="11" align="top" />}</SPAN></SPAN><SPAN style="COLOR: #000000"><br /><IMG height="16" src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" width="11" align="top" /></SPAN></DIV></DIV><br /><IMG height="19" src="http://www.cnblogs.com/Emoticons/emdgust.gif" width="19" align="absMiddle" border="0" />前一阵为我和同事做的blog写的，不知道怎样，有什么需要改进的地方大家帮我看看<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">烂瓶子</a> 2004-12-01 00:11 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/12/01/71066.html#71249#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71247</link><dc:creator>kwklover</dc:creator><author>kwklover</author><pubDate>Tue, 30 Nov 2004 15:49:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71247</guid><description><![CDATA[精彩！<br>我感觉以上讨论是关于多数据库支持的做法，如果一个项目同时有多个数据库，有时候需要从sqlserver获取数据，有时候需要从oracel获取数据，这个要求，设计数据层的时候应该如何设计比较好呢 ？<br><br>我刚开始是想做两个privider :SqlServerProvider和OracleProvider，但个人感觉这样做，在数据操作层的时候，要区分这种操作是调用哪个Provider，感觉不怎么好<br><br>的好好思考一下上面朋友的言论了！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">kwklover</a> 2004-11-30 23:49 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71247#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71211</link><dc:creator>wildfish</dc:creator><author>wildfish</author><pubDate>Tue, 30 Nov 2004 14:31:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71211</guid><description><![CDATA[我们现在的dataaccess层基本上可以适应多种数据库，目前可以支持db2 olddb，不过麻烦就在于sql语句要重新写。因为各种数据驱动会有一些语法差异。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">wildfish</a> 2004-11-30 22:31 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71211#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71164</link><dc:creator>小陆</dc:creator><author>小陆</author><pubDate>Tue, 30 Nov 2004 13:03:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71164</guid><description><![CDATA[我曾经遇到过一个这样的项目，一开始的时候就在SQL和Oracle之间晃来晃去，最后选择了PostSql（免费的）。还有一次是编码已经开始了，才告诉我，还有几个报表是在Oracle数据库里做的。<br><a target="_new" href="http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html">http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html</a><br>文章的最后举的例子是我在实际工作中应用的情景，希望能代给大家一些值得讨论的东西。<br>设计不能解决合同签不下来的问题，也不能解决工程款结不下来的问题，只能在传来坏消息的时候减少一点绝望。从某种角度上说，好的设计可以化解一些需求上的风险，增加一些讨价还价的砝码。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">小陆</a> 2004-11-30 21:03 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71164#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71146</link><dc:creator>有时狂欢</dc:creator><author>有时狂欢</author><pubDate>Tue, 30 Nov 2004 12:14:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71146</guid><description><![CDATA[看了你的文章,说了一点看法,在这里<a target="_new" href="http://www.cnblogs.com/anxing/archive/2004/11/30/71143.html">http://www.cnblogs.com/anxing/archive/2004/11/30/71143.html</a><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">有时狂欢</a> 2004-11-30 20:14 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71146#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71132</link><dc:creator>wayfarer</dc:creator><author>wayfarer</author><pubDate>Tue, 30 Nov 2004 11:36:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71132</guid><description><![CDATA[为了你能看得更方便一点，我还是直接把JGTM的评论贴出来吧。说实话，他写的这段代码很精彩，应该对你有帮助：<br><br>关于FACTORY METHODS的应用，在很多地方均有涉及（尤其是framework代码中），在类似于data provider的场合尤其多见。.NET中IDbConnection中的CreateCommmand()方法是我最常举的例子，它使得client代码的开发对具体类的依赖大幅度减少。 <br><br>正好现在有时间，随手举个例子给你吧，我用重构的方法根据你文中提到的要求来推导，okay！先看这个原始代码： <br><br>public DataSet ClientSample() <br>{ <br>　SqlCommand command = new SqlCommand(commandText); <br>　SqlDataAdapter adapter = new SqlDataAdapter(command); <br>　using (SqlConnection connection = new SqlConnection(connectionString)) <br>{ <br>　　DataSet result = new DataSet(); <br>　　connection.Open(); <br>　　adapter.Fill(result, &quot;tableName&quot;); <br>　　return result; <br>　} <br>} <br><br>注意看它依赖了多少个具体的数据源相关的类。为了让这段代码可以适应多种数据源，首先要把具体类换成抽象类或接口，如下： <br><br>public DataSet ClientSample2() <br>{ <br>　IDbCommand command = new SqlCommand(commandText); <br>　IDataAdapter adapter = new SqlDataAdapter(command); <br>　using (IDbConnection connection = new SqlConnection(connectionString)) <br>　{ <br>　　DataSet result = new DataSet(); <br>　　connection.Open(); <br>　　adapter.Fill(result, &quot;tableName&quot;); <br>　　return result; <br>　} <br>} <br><br>然后把构造具体类的逻辑封装成所谓provider： <br><br>public DataSet ClientSample2() <br>{ <br>　IMyProvider provider = new MySqlProvider(); <br>　IDbCommand command = provider.GetCommand(commandText); <br>　IDataAdapter adapter = provider.GetDataAdapter(command); <br>　using (IDbConnection connection = <br>provider.GetConnection(connectionString)) <br>　{ <br>　　DataSet result = new DataSet(); <br>　　connection.Open(); <br>　　adapter.Fill(result, &quot;tableName&quot;); <br>　　return result; <br>　} <br>} <br><br>现在你就只依赖一个具体类了，再把这个依赖性通过引入字符串来消除： <br><br>const providerTypeName = &quot;MyCompany.MyProject.MySqlProvider, SqlProvider&quot;; <br><br>public DataSet ClientSample2() <br>{ <br>　IMyProvider provider = <br>(IMyProvider)Activator.CreateInstance(providerTypeName); <br>　IDbCommand command = provider.GetCommand(commandText); <br>　IDataAdapter adapter = provider.GetDataAdapter(command); <br>　using (IDbConnection connection = <br>provider.GetConnection(connectionString)) <br>　{ <br>　　DataSet result = new DataSet(); <br>　　connection.Open(); <br>　　adapter.Fill(result, &quot;tableName&quot;); <br>　　return result; <br>　} <br>} <br><br>这个常量是个可配置的信息，如果放到配置文件中，这段代码就已经做到数据源无关了。这里面使用FACTORY METHODS模式利用GetCommand、GetDataAdpator和GetConnection三个方法把对IDbCommand、IDataAdapter和IDbConnection的构造延迟到子类中。如果把GetCommand合并入GetDataAdapter，就得到比较理想的client逻辑： <br><br>public DataSet ClientSample2() <br>{ <br>　IMyProvider provider = <br>(IMyProvider)Activator.CreateInstance(providerTypeName); <br>　using (IDbConnection connection = <br>provider.GetConnection(connectionString)) <br>　{ <br>　　IDbCommand command = connection.CreateCommand(); <br>　　IDataAdapter adapter = provider.GetDataAdapter(command); <br>　　DataSet result = new DataSet(); <br>　　connection.Open(); <br>　　adapter.Fill(result, &quot;tableName&quot;); <br>　　return result; <br>　} <br>} <br><br>这里你可以发现，我们利用了IDbConnection中的CreateCommand()这个FACTORY METHOD进一步减少了provider的责任，使得provider内部也只需要依赖于两个和数据源相关的具体类：XxxConnection和XxxDataAdaptor： <br><br>public class MySqlProvider: IMyProvider <br>{ <br>　public IDbConnection GetConnection(string connectionString) <br>　{ <br>　　return new SqlConnection(connectionString); <br>　} <br>　public IDataAdapter GetDataAdapter(IDbCommand command) <br>　{ <br>　　command.CommandType = CommandType.StoredProc; <br>　　command.CommandText = &quot;myStoredProc&quot;; <br>　　return new SqlDataAdapter(command); <br>　} <br>} <br><br>这里，IMyProvider应该是由你的框架代码来定义，所有的provider都要reference你的框架并依赖这个接口，这也是所谓IOC的具体应用——在没有任何具体的provider类之 <br>前client可以独立的编译，它并不依赖、引用任何具体的可扩展的provider类库。 <br><br>上面的例子希望能够对你理解FACTORY METHODS（其实是TEMPLATE METHODS的一种具体情形）有所帮助吧！另外，我写的例子千万不要拷贝粘贴到开发环境中，否则引起蓝屏 <br>甚至硬件故障本人一概不负责任。嘿嘿！：） <br><br>JGTM'2004 [MVP] <br>JGTM Studio .NET <br><br><br>btw：JGTM，我这样贴你的内容，不会怪我侵权吧，嘿嘿:)<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">wayfarer</a> 2004-11-30 19:36 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71132#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71116</link><dc:creator>dudu</dc:creator><author>dudu</author><pubDate>Tue, 30 Nov 2004 10:57:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71116</guid><description><![CDATA[这样的文章当然可以放在首页。希望大家发表更多的有关软件设计与编辑思想方面的文章。我们专注于.NET, 但我们更要超越.NET, 去领悟软件设计的真谛！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">dudu</a> 2004-11-30 18:57 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71116#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 设计</title><link>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71112</link><dc:creator>青水泛舟</dc:creator><author>青水泛舟</author><pubDate>Tue, 30 Nov 2004 10:49:00 GMT</pubDate><guid>http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71112</guid><description><![CDATA[<DIV>看看我在的组所做的设计，你也许会感到欣慰一点。<br /><br />public class myObject  //基类，所有的东西（除了控件）都要继承这里。<br />{<br />  public string ID;<br />  public string  Name;<br />  public object userobj1 =  new object(); // 附加的，做其它用。<br />  public object userobj2 =  new object();  
</DIV><P>  ////.....<br />} 
</P><DIV>public class DataBase  //负责与数据库打交道。<br />{<br />  public OracleConnection connection;  //<br />  protected OracleDataReader Reader;  //  protected, 供子类调用。<br />  public int ExecuteNonQuery(string sql); //执行sql语句。结果是在上面的Reader中。<br />   //其他<br />}<br />  
</DIV><DIV>public class SQL //负责获得sql语句。sql语句是放在xml文件中的。<br />{     <br /> public string GetSql(string sqlNmae)<br />     { 
</DIV><DIV>          return "";  //....<br />     } 
</DIV><DIV>  //其他<br />} 
</DIV><P> </P><DIV>然后开始写业务层。上面的算是数据库访问层吧。<br />public class UserInfo : myObject 
</DIV><DIV>{<br />    //public string <SPAN style="COLOR: red">UserID</SPAN>;  因为基类有ID,可以不定义了。<br />   //public  string <SPAN style="COLOR: red">UserName</SPAN>; 和ID一样，不定义。<br />     public int Age;<br /><br />     //如果使用到其他对象，比如所在科室,一般这样定义<br />    myObject Dept = new myObject();   //可以用Dept里的ID........<br />    <br /><br />} 
</DIV><DIV>下面是UserInfo的管理类：<br />public class UserManager : <SPAN style="COLOR: red">DataBase</SPAN> // 继承DataBase !!!!! 
</DIV><DIV>{<br />    public UserInfo SelectById(object id) {} 
</DIV><DIV>    public ArrayList  SelectAll()   //返回的是集合。！<br />   {<br />       ArrayList list = new ArrayList();  <br />       ...... 
</DIV><DIV>       while( Reader.Read() )<br />      { 
</DIV><DIV>           UserInfo info = new UserInfo();<br />          info.ID = Reader[0].ToString();<br />          info.Name = Reader[1].ToString();<br />          info.Age = (int)Reader[2];  <br />          <SPAN style="COLOR: red">info.Dept.ID = Reader[3].ToString();  <br /></SPAN>         //其他.....<br />         list.Add(info); 
</DIV><DIV>       }<br />      return list;<br />   }  
</DIV><DIV>    public int Update(UserInfo info) {}<br />    public int Insert(UserInfo info) {} 
</DIV><DIV>   //一般的功能就是Select , Update, Insert. 。<br />}<br />  
</DIV><DIV>业务层就这样子了。然后就写表现层。<br /><br />把ArrayList中的UserInfo的值付到DataTable等中，操作完后再从DataTable中生成UserInfo, 并调用UserManager进行添加、删除等工作。<br /><SPAN style="COLOR: red">^ ^</SPAN>包括数据验证一系列乱78糟的操作。<br /></DIV><DIV><br />到这里差不多完成了一个从后台到前台的过程。呵呵。<br /><br />还有：这个系统大概有6、700张表。晕......<br /><br />羡慕别人那。
</DIV><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/dotnet2004/" target="_blank">青水泛舟</a> 2004-11-30 18:49 <a href="http://www.cnblogs.com/dotnet2004/archive/2004/11/30/71066.html#71112#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>
