Enterprise Library 3.0 体验(3):使用配置文件的Validation Application Block

论坛 期权论坛     
选择匿名的用户   2021-5-23 01:55   38   0
<div class="blogpost-body" id="cnblogs_post_body">
<p class="MsoNormal" style="line-height:200%;"><span style="font-size:10pt;line-height:200%;font-family:&#39;宋体&#39;;">摘要:<span lang="en-us">Enterprise Library 3.0 January 2007 CTP</span>版发布了,这次发布的版对于<span lang="en-us">Validation Application Block</span>有了很大的改进,包括对配置工具的支持,与<span lang="en-us">ASP.NET</span>以及<span lang="en-us">WinForm</span>的集成等新的特性。在上一篇文章中我介绍了如何使用<span lang="en-us">Attribute</span>来实现验证,文本看一下如何利用配置文件来使用<span lang="en-us">Validation Application Block</span>。<span lang="en-us"></span></span></p>
<p></p>
<p class="MsoNormal" style="line-height:200%;"><span lang="en-us" style="font-size:10pt;line-height:200%;font-family:&#39;宋体&#39;;"></span></p>
<p> </p>
<p class="MsoNormal" style="line-height:200%;"><span lang="en-us" style="font-size:10pt;line-height:200%;font-family:&#39;宋体&#39;;">1</span><span style="font-size:10pt;line-height:200%;font-family:&#39;宋体&#39;;">.新建一个控制台应用程序,仍然使用我在<span lang="en-us"><a href="http://www.cnblogs.com/Terrylee/archive/2006/12/25/Enterprise_Library_3_Validation_Application_Block.html"><span lang="en-us"><span lang="en-us">前一篇文章</span></span></a></span>中用过的<span lang="en-us">User</span>实体类,这跟我们编写的普通业务对象并没有任何区别:<span lang="en-us"></span></span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;color:#0000FF;font-family:&#39;新宋体&#39;;">public</span><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;"> <span style="color:#0000FF;">class</span> <span style="color:#008080;">User</span></span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">{<!-- --></span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">    <span style="color:#0000FF;">private</span> <span style="color:#008080;">String</span> _name;</span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;"></span></p>
<p> </p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">    <span style="color:#0000FF;">private</span> <span style="color:#0000FF;">int</span> _age;</span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;"></span></p>
<p> </p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">    <span style="color:#0000FF;">public</span> <span style="color:#008080;">String</span> Name</span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">    {<!-- --></span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">        <span style="color:#0000FF;">get</span> { <span style="color:#0000FF;">return</span> _name; }</span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">        <span style="color:#0000FF;">set</span> { _name &#61; <span style="color:#0000FF;">value</span>; }</span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">    }</span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;"></span></p>
<p> </p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">    <span style="color:#0000FF;">public</span> <span style="color:#0000FF;">int</span> Age</span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">    {<!-- --></span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">        <span style="color:#0000FF;">get</span> { <span style="color:#0000FF;">return</span> _age; }</span></p>
<p></p>
<p align="left" class="MsoNormal" style="background:#f3f3f3;text-align:left;"><span lang="en-us" style="font-size:10pt;font-family:&#39;新宋体&#39;;">        <span style="color:#0000FF;">set</span> { _age &#61; <span style="color:#0000FF;">value
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP