<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[TUPUNCO 's BLOG]]></title>
<link>http://zhq.ahau.edu.cn/blog/</link>
<description><![CDATA[小强]]></description>
<language>zh-cn</language>
<copyright><![CDATA[Copyright 2005 PBlog3 v2.8]]></copyright>
<webMaster><![CDATA[tupunco@163.com(tupunco)]]></webMaster>
<generator>PBlog2 v2.4</generator> 
<image>
	<title>TUPUNCO &#39;s BLOG</title>
	<url>http://zhq.ahau.edu.cn/blog/images/logos.gif</url>
	<link>http://zhq.ahau.edu.cn/blog/</link>
	<description>TUPUNCO &#39;s BLOG</description>
</image>

			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/482.htm</link>
			<title><![CDATA[验证码上的高效正弦扭曲函数]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[原创]]></category>
			<pubDate>Sat,30 Jan 2010 17:58:13 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=482</guid>
		<description><![CDATA[<p>c#上, 但凡需要给验证码添加扭曲的地方感觉都是一个函数:</p>  <div id="codeSnippetWrapper" class="csharpcode-wrapper">   <div id="codeSnippet" class="csharpcode">     <pre class="alt"><span class="preproc">#region</span> 产生波形滤镜效果</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt"> <span class="kwrd">private</span> <span class="kwrd">const</span> <span class="kwrd">double</span> PI = 3.1415926535897932384626433832795;</pre>
<!--CRLF-->

    <pre class="alteven"> <span class="kwrd">private</span> <span class="kwrd">const</span> <span class="kwrd">double</span> PI2 = 6.283185307179586476925286766559;</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven"> <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"> <span class="rem">/// 正弦曲线Wave扭曲图片</span></pre>
<!--CRLF-->

    <pre class="alteven"> <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"> <span class="rem">/// &lt;param name=&quot;srcBmp&quot;&gt;图片路径&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"> <span class="rem">/// &lt;param name=&quot;bXDir&quot;&gt;如果扭曲则选择为True&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"> <span class="rem">/// &lt;param name=&quot;nMultValue&quot;&gt;波形的幅度倍数，越大扭曲的程度越高，一般为3&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"> <span class="rem">/// &lt;param name=&quot;dPhase&quot;&gt;波形的起始相位，取值区间[0-2*PI)&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"> <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"> <span class="kwrd">public</span> System.Drawing.Bitmap TwistImage(Bitmap srcBmp, <span class="kwrd">bool</span> bXDir, <span class="kwrd">double</span> dMultValue, <span class="kwrd">double</span> dPhase)</pre>
<!--CRLF-->

    <pre class="alt"> {</pre>
<!--CRLF-->

    <pre class="alteven">     System.Drawing.Bitmap destBmp = <span class="kwrd">new</span> Bitmap(srcBmp.Width, srcBmp.Height);</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">     <span class="rem">// 将位图背景填充为白色</span></pre>
<!--CRLF-->

    <pre class="alt">     System.Drawing.Graphics graph = System.Drawing.Graphics.FromImage(destBmp);</pre>
<!--CRLF-->

    <pre class="alteven">     graph.FillRectangle(<span class="kwrd">new</span> SolidBrush(System.Drawing.Color.White), 0, 0, destBmp.Width, destBmp.Height);</pre>
<!--CRLF-->

    <pre class="alt">     graph.Dispose();</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">     <span class="kwrd">double</span> dBaseAxisLen = bXDir ? (<span class="kwrd">double</span>)destBmp.Height : (<span class="kwrd">double</span>)destBmp.Width;</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">     <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; destBmp.Width; i++)</pre>
<!--CRLF-->

    <pre class="alteven">     {</pre>
<!--CRLF-->

    <pre class="alt">         <span class="kwrd">for</span> (<span class="kwrd">int</span> j = 0; j &lt; destBmp.Height; j++)</pre>
<!--CRLF-->

    <pre class="alteven">         {</pre>
<!--CRLF-->

    <pre class="alt">             <span class="kwrd">double</span> dx = 0;</pre>
<!--CRLF-->

    <pre class="alteven">             dx = bXDir ? (PI2 * (<span class="kwrd">double</span>)j) / dBaseAxisLen : (PI2 * (<span class="kwrd">double</span>)i) / dBaseAxisLen;</pre>
<!--CRLF-->

    <pre class="alt">             dx += dPhase;</pre>
<!--CRLF-->

    <pre class="alteven">             <span class="kwrd">double</span> dy = Math.Sin(dx);</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">             <span class="rem">// 取得当前点的颜色</span></pre>
<!--CRLF-->

    <pre class="alt">             <span class="kwrd">int</span> nOldX = 0, nOldY = 0;</pre>
<!--CRLF-->

    <pre class="alteven">             nOldX = bXDir ? i + (<span class="kwrd">int</span>)(dy * dMultValue) : i;</pre>
<!--CRLF-->

    <pre class="alt">             nOldY = bXDir ? j : j + (<span class="kwrd">int</span>)(dy * dMultValue);</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">             System.Drawing.Color color = srcBmp.GetPixel(i, j);</pre>
<!--CRLF-->

    <pre class="alteven">             <span class="kwrd">if</span> (nOldX &gt;= 0 &amp;&amp; nOldX &lt; destBmp.Width</pre>
<!--CRLF-->

    <pre class="alt">              &amp;&amp; nOldY &gt;= 0 &amp;&amp; nOldY &lt; destBmp.Height)</pre>
<!--CRLF-->

    <pre class="alteven">             {</pre>
<!--CRLF-->

    <pre class="alt">                 destBmp.SetPixel(nOldX, nOldY, color);</pre>
<!--CRLF-->

    <pre class="alteven">             }</pre>
<!--CRLF-->

    <pre class="alt">         }</pre>
<!--CRLF-->

    <pre class="alteven">     }</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">     <span class="kwrd">return</span> destBmp;</pre>
<!--CRLF-->

    <pre class="alt"> }</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt"> <span class="preproc">#endregion</span></pre>
<!--CRLF--></div>
</div>

<p>这个函数实在效率不高, 但还是很多人用. 可以从下面的地址得到结果:</p>

<p><a title="http://www.google.cn/search?hl=zh-CN&amp;newwindow=1&amp;q=Bitmap+TwistImage%28Bitmap+srcBmp&amp;btnG=Google+%E6%90%9C%E7%B4%A2&amp;aq=f&amp;oq=" href="http://www.google.cn/search?hl=zh-CN&amp;newwindow=1&amp;q=Bitmap+TwistImage%28Bitmap+srcBmp&amp;btnG=Google+%E6%90%9C%E7%B4%A2&amp;aq=f&amp;oq=">http://www.google.cn/search?hl=zh-CN&amp;newwindow=1&amp;q=Bitmap+TwistImage%28Bitmap+srcBmp&amp;btnG=Google+%E6%90%9C%E7%B4%A2&amp;aq=f&amp;oq=</a></p>

<p>下面是改进的这个函数:</p>

<p>&#160;</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt"><span class="preproc">#region</span> 波浪函数</pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">//正弦起始点</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="kwrd">private</span> <span class="kwrd">const</span> <span class="kwrd">double</span> PI = 3.141592;</pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">//正弦扭曲率</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="kwrd">private</span> <span class="kwrd">const</span> <span class="kwrd">double</span> PI2 = 6.28318;</pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// 正弦曲线Wave扭曲图片</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;srcBmp&quot;&gt;图片路径&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;bXDir&quot;&gt;沿Y轴扭曲则选择为True&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;dMultValue&quot;&gt;波形的幅度倍数，越大扭曲的程度越高，一般为3&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;dPhase&quot;&gt;波形的起始相位，取值区间[0-2*PI)&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="kwrd">private</span> <span class="kwrd">static</span> Bitmap TwistImage(Bitmap srcBmp, <span class="kwrd">bool</span> bXDir, <span class="kwrd">double</span> dMultValue, <span class="kwrd">double</span> dPhase)</pre>
<!--CRLF-->

    <pre class="alt">{</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">return</span> TwistImage(srcBmp, bXDir, dMultValue, dPhase, 1f);</pre>
<!--CRLF-->

    <pre class="alt">}</pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// 正弦曲线Wave扭曲图片</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;srcBmp&quot;&gt;图片路径&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;bXDir&quot;&gt;沿Y轴扭曲则选择为True&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;dMultValue&quot;&gt;波形的幅度倍数，越大扭曲的程度越高，一般为3&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;dPhase&quot;&gt;波形的起始相位，取值区间[0-2*PI)&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;times&quot;&gt;应用几个周期&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="kwrd">private</span> <span class="kwrd">static</span> Bitmap TwistImage(Bitmap srcBmp, <span class="kwrd">bool</span> bXDir, <span class="kwrd">double</span> dMultValue, <span class="kwrd">double</span> dPhase, <span class="kwrd">float</span> times)</pre>
<!--CRLF-->

    <pre class="alteven">{</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">int</span> w = srcBmp.Width;</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">int</span> h = srcBmp.Height;</pre>
<!--CRLF-->

    <pre class="alt">    System.Drawing.Bitmap destBmp = <span class="kwrd">new</span> Bitmap(w, h, PixelFormat.Format24bppRgb);</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">    <span class="rem">// 将位图背景填充为白色</span></pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">using</span> (System.Drawing.Graphics graph = System.Drawing.Graphics.FromImage(destBmp))</pre>
<!--CRLF-->

    <pre class="alt">    {</pre>
<!--CRLF-->

    <pre class="alteven">        graph.Clear(Color.White);</pre>
<!--CRLF-->

    <pre class="alt">    }</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">double</span> dBaseAxisLen = bXDir ? (<span class="kwrd">double</span>)h : (<span class="kwrd">double</span>)w;</pre>
<!--CRLF-->

    <pre class="alteven">    BitmapData destData = destBmp.LockBits(<span class="kwrd">new</span> Rectangle(0, 0, w, h), ImageLockMode.WriteOnly, destBmp.PixelFormat);</pre>
<!--CRLF-->

    <pre class="alt">    BitmapData srcData = srcBmp.LockBits(<span class="kwrd">new</span> Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, srcBmp.PixelFormat);</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">unsafe</span></pre>
<!--CRLF-->

    <pre class="alt">    {</pre>
<!--CRLF-->

    <pre class="alteven">        <span class="kwrd">byte</span>* p = (<span class="kwrd">byte</span>*)(<span class="kwrd">void</span>*)srcData.Scan0;</pre>
<!--CRLF-->

    <pre class="alt">        <span class="kwrd">byte</span>* p2 = (<span class="kwrd">byte</span>*)(<span class="kwrd">void</span>*)destData.Scan0;</pre>
<!--CRLF-->

    <pre class="alteven">        <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; w; i++)</pre>
<!--CRLF-->

    <pre class="alt">        {</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">for</span> (<span class="kwrd">int</span> j = 0; j &lt; h; j++)</pre>
<!--CRLF-->

    <pre class="alt">            {</pre>
<!--CRLF-->

    <pre class="alteven">                <span class="kwrd">double</span> dx = 0;</pre>
<!--CRLF-->

    <pre class="alt">                dx = bXDir ? (PI2 * (<span class="kwrd">double</span>)j * times) / dBaseAxisLen : (PI2 * (<span class="kwrd">double</span>)i * times) / dBaseAxisLen;</pre>
<!--CRLF-->

    <pre class="alteven">                dx += dPhase;</pre>
<!--CRLF-->

    <pre class="alt">                <span class="kwrd">double</span> dy = Math.Sin(dx);</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">                <span class="rem">// 取得当前点的颜色</span></pre>
<!--CRLF-->

    <pre class="alteven">                <span class="kwrd">int</span> nOldX = 0, nOldY = 0;</pre>
<!--CRLF-->

    <pre class="alt">                nOldX = bXDir ? i + (<span class="kwrd">int</span>)(dy * dMultValue) : i;</pre>
<!--CRLF-->

    <pre class="alteven">                nOldY = bXDir ? j : j + (<span class="kwrd">int</span>)(dy * dMultValue);</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">                <span class="kwrd">if</span> (nOldX &gt;= 0 &amp;&amp; nOldX &lt; w</pre>
<!--CRLF-->

    <pre class="alt">                 &amp;&amp; nOldY &gt;= 0 &amp;&amp; nOldY &lt; h)</pre>
<!--CRLF-->

    <pre class="alteven">                {</pre>
<!--CRLF-->

    <pre class="alt">                    p2[(nOldY * destData.Stride) + (nOldX * 3)] = p[(j * srcData.Stride) + (i * 3)];</pre>
<!--CRLF-->

    <pre class="alteven">                    p2[(nOldY * destData.Stride) + (nOldX * 3) + 1] = p[(j * srcData.Stride) + (i * 3) + 1];</pre>
<!--CRLF-->

    <pre class="alt">                    p2[(nOldY * destData.Stride) + (nOldX * 3) + 2] = p[(j * srcData.Stride) + (i * 3) + 2];</pre>
<!--CRLF-->

    <pre class="alteven">                }</pre>
<!--CRLF-->

    <pre class="alt">            }</pre>
<!--CRLF-->

    <pre class="alteven">        }</pre>
<!--CRLF-->

    <pre class="alt">    }</pre>
<!--CRLF-->

    <pre class="alteven">    destBmp.UnlockBits(destData);</pre>
<!--CRLF-->

    <pre class="alt">    srcBmp.UnlockBits(srcData);</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">if</span> (srcBmp != <span class="kwrd">null</span>)</pre>
<!--CRLF-->

    <pre class="alt">        srcBmp.Dispose();</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">return</span> destBmp;</pre>
<!--CRLF-->

    <pre class="alt">}</pre>
<!--CRLF--></div>
</div>

<p>调整了PI值, 测试发现这个值小了效率有所提高. 另外使用unsafe代码绘制波纹, 这个效率基本可以提高10倍之上. 另外扩展了这个函数可以支持多个周期的正弦扭曲. 需要注意的地方是:</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt">System.Drawing.Bitmap destBmp = <span class="kwrd">new</span> Bitmap(w, h, PixelFormat.Format24bppRgb);</pre>
<!--CRLF--></div>
</div>

<p></p>

<p></p>

<p>强制使用24位, 原因可以参看以下解释:</p>

<ol>
  <li><a title="http://www.bobpowell.net/lockingbits.htm" href="http://www.bobpowell.net/lockingbits.htm">http://www.bobpowell.net/lockingbits.htm</a> </li>

  <li><a title="http://notebk.gofreeserve.com/?p=206" href="http://notebk.gofreeserve.com/?p=206">http://notebk.gofreeserve.com/?p=206</a>(上文翻译) </li>

  <li><a title="http://msdn.microsoft.com/zh-cn/library/5ey6h79d(VS.80).aspx" href="http://msdn.microsoft.com/zh-cn/library/5ey6h79d(VS.80).aspx">http://msdn.microsoft.com/zh-cn/library/5ey6h79d(VS.80).aspx</a> </li>

  <li><a title="http://msdn.microsoft.com/zh-cn/library/system.drawing.imaging.pixelformat.aspx" href="http://msdn.microsoft.com/zh-cn/library/system.drawing.imaging.pixelformat.aspx">http://msdn.microsoft.com/zh-cn/library/system.drawing.imaging.pixelformat.aspx</a> </li>
</ol>

<p>另外提供一个不用unsafe的实现版本:</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// 正弦曲线Wave扭曲图片</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;srcBmp&quot;&gt;图片路径&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;bXDir&quot;&gt;沿Y轴扭曲则选择为True&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;dMultValue&quot;&gt;波形的幅度倍数，越大扭曲的程度越高，一般为3&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;dPhase&quot;&gt;波形的起始相位，取值区间[0-2*PI)&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;times&quot;&gt;应用几个周期&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="kwrd">private</span> <span class="kwrd">static</span> Bitmap TwistImage2(Bitmap srcBmp, <span class="kwrd">bool</span> bXDir, <span class="kwrd">double</span> dMultValue, <span class="kwrd">double</span> dPhase, <span class="kwrd">float</span> times)</pre>
<!--CRLF-->

    <pre class="alt">{</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">int</span> w = srcBmp.Width;</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">int</span> h = srcBmp.Height;</pre>
<!--CRLF-->

    <pre class="alteven">    System.Drawing.Bitmap destBmp = <span class="kwrd">new</span> Bitmap(w, h, PixelFormat.Format24bppRgb);</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="rem">// 将位图背景填充为白色</span></pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">using</span> (System.Drawing.Graphics graph = System.Drawing.Graphics.FromImage(destBmp))</pre>
<!--CRLF-->

    <pre class="alteven">    {</pre>
<!--CRLF-->

    <pre class="alt">        graph.Clear(Color.White);</pre>
<!--CRLF-->

    <pre class="alteven">    }</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">double</span> dBaseAxisLen = bXDir ? (<span class="kwrd">double</span>)h : (<span class="kwrd">double</span>)w;</pre>
<!--CRLF-->

    <pre class="alt">    BitmapData destData = destBmp.LockBits(<span class="kwrd">new</span> Rectangle(0, 0, w, h), ImageLockMode.WriteOnly, destBmp.PixelFormat);</pre>
<!--CRLF-->

    <pre class="alteven">    BitmapData srcData = srcBmp.LockBits(<span class="kwrd">new</span> Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, srcBmp.PixelFormat);</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">byte</span>[] rgbValues = <span class="kwrd">new</span> <span class="kwrd">byte</span>[3];</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; w; i++)</pre>
<!--CRLF-->

    <pre class="alt">    {</pre>
<!--CRLF-->

    <pre class="alteven">        <span class="kwrd">for</span> (<span class="kwrd">int</span> j = 0; j &lt; h; j++)</pre>
<!--CRLF-->

    <pre class="alt">        {</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">double</span> dx = 0;</pre>
<!--CRLF-->

    <pre class="alt">            dx = bXDir ? (PI2 * (<span class="kwrd">double</span>)j * times) / dBaseAxisLen : (PI2 * (<span class="kwrd">double</span>)i * times) / dBaseAxisLen;</pre>
<!--CRLF-->

    <pre class="alteven">            dx += dPhase;</pre>
<!--CRLF-->

    <pre class="alt">            <span class="kwrd">double</span> dy = Math.Sin(dx);</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">            <span class="rem">// 取得当前点的颜色</span></pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">int</span> nOldX = 0, nOldY = 0;</pre>
<!--CRLF-->

    <pre class="alt">            nOldX = bXDir ? i + (<span class="kwrd">int</span>)(dy * dMultValue) : i;</pre>
<!--CRLF-->

    <pre class="alteven">            nOldY = bXDir ? j : j + (<span class="kwrd">int</span>)(dy * dMultValue);</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">if</span> (nOldX &gt;= 0 &amp;&amp; nOldX &lt; w</pre>
<!--CRLF-->

    <pre class="alt">             &amp;&amp; nOldY &gt;= 0 &amp;&amp; nOldY &lt; h)</pre>
<!--CRLF-->

    <pre class="alteven">            {</pre>
<!--CRLF-->

    <pre class="alt">                Marshal.Copy((IntPtr)((<span class="kwrd">int</span>)srcData.Scan0 + ((j * srcData.Stride) + (i * 3))), rgbValues, 0, 3);</pre>
<!--CRLF-->

    <pre class="alteven">                Marshal.Copy(rgbValues, 0, (IntPtr)((<span class="kwrd">int</span>)destData.Scan0 + ((nOldY * destData.Stride) + (nOldX * 3))), 3);</pre>
<!--CRLF-->

    <pre class="alt">            }</pre>
<!--CRLF-->

    <pre class="alteven">        }</pre>
<!--CRLF-->

    <pre class="alt">    }</pre>
<!--CRLF-->

    <pre class="alteven">    destBmp.UnlockBits(destData);</pre>
<!--CRLF-->

    <pre class="alt">    srcBmp.UnlockBits(srcData);</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">if</span> (srcBmp != <span class="kwrd">null</span>)</pre>
<!--CRLF-->

    <pre class="alt">        srcBmp.Dispose();</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">return</span> destBmp;</pre>
<!--CRLF-->

    <pre class="alt">}</pre>
<!--CRLF-->

    <pre class="alteven"><span class="preproc">#endregion</span></pre>
<!--CRLF--></div>
</div>

<p>这下&quot;<span class="preproc">#region</span> &quot;关闭了就.</p>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/483.htm</link>
			<title><![CDATA[KCAPTCHA 验证码波纹扭曲函数 C# 实现]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[原创]]></category>
			<pubDate>Sat,30 Jan 2010 17:56:57 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=483</guid>
		<description><![CDATA[<p><a href="http://www.captcha.ru/en/kcaptcha/" target="_blank">KCAPTCHA</a>&#160; 一个不错的验证码实现, 官方网站:<a title="http://www.captcha.ru/en/kcaptcha/" href="http://www.captcha.ru/en/kcaptcha/">http://www.captcha.ru/en/kcaptcha/</a>. 因为工作原因, 需要改进验证码所有有机会把波纹扭曲部分使用 C# 实现. </p>  <div id="codeSnippetWrapper" class="csharpcode-wrapper">   <div id="codeSnippet" class="csharpcode">     <pre class="alt"><span class="preproc">#region  KCAPTCHA 波纹扭曲</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// # <a href="http://www.captcha.ru/en/kcaptcha/" target="_blank">KCAPTCHA</a> PROJECT VERSION 1.2.6</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// www.captcha.ru, www.kruglov.ru</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// 波形扭曲 FROM KCAPTCHA</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;srcBmp&quot;&gt;待扭曲的图像 必须为 PixelFormat.Format24bppRgb 格式图像&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="kwrd">private</span> <span class="kwrd">static</span> Bitmap WaveDistortion(Bitmap srcBmp)</pre>
<!--CRLF-->

    <pre class="alteven">{</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">if</span> (srcBmp == <span class="kwrd">null</span>)</pre>
<!--CRLF-->

    <pre class="alteven">        <span class="kwrd">return</span> <span class="kwrd">null</span>;</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">if</span> (srcBmp.PixelFormat != PixelFormat.Format24bppRgb)</pre>
<!--CRLF-->

    <pre class="alteven">        <span class="kwrd">throw</span> <span class="kwrd">new</span> ArgumentException(<span class="str">&quot;srcBmp PixelFormat.Format24bppRgb 格式图像&quot;</span>, <span class="str">&quot;srcBmp&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">    var width = srcBmp.Width;</pre>
<!--CRLF-->

    <pre class="alt">    var height = srcBmp.Height;</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">    Bitmap destBmp = <span class="kwrd">new</span> Bitmap(width, height, PixelFormat.Format24bppRgb);</pre>
<!--CRLF-->

    <pre class="alteven">    {</pre>
<!--CRLF-->

    <pre class="alt">        <span class="rem">//前景色</span></pre>
<!--CRLF-->

    <pre class="alteven">        Color foreground_color = Color.FromArgb(randx.Next(10, 100), randx.Next(10, 100), randx.Next(10, 100));</pre>
<!--CRLF-->

    <pre class="alt">        <span class="rem">//背景色</span></pre>
<!--CRLF-->

    <pre class="alteven">        Color background_color = Color.FromArgb(randx.Next(200, 250), randx.Next(200, 250), randx.Next(200, 250));</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">        <span class="kwrd">using</span> (Graphics newG = Graphics.FromImage(destBmp))</pre>
<!--CRLF-->

    <pre class="alt">        {</pre>
<!--CRLF-->

    <pre class="alteven">            newG.Clear(background_color);</pre>
<!--CRLF-->

    <pre class="alt">            <span class="rem">// periods 时间</span></pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">double</span> rand1 = randx.Next(710000, 1200000) / 10000000.0;</pre>
<!--CRLF-->

    <pre class="alt">            <span class="kwrd">double</span> rand2 = randx.Next(710000, 1200000) / 10000000.0;</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">double</span> rand3 = randx.Next(710000, 1200000) / 10000000.0;</pre>
<!--CRLF-->

    <pre class="alt">            <span class="kwrd">double</span> rand4 = randx.Next(710000, 1200000) / 10000000.0;</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="rem">// phases  相位</span></pre>
<!--CRLF-->

    <pre class="alt">            <span class="kwrd">double</span> rand5 = randx.Next(0, 31415926) / 10000000.0;</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">double</span> rand6 = randx.Next(0, 31415926) / 10000000.0;</pre>
<!--CRLF-->

    <pre class="alt">            <span class="kwrd">double</span> rand7 = randx.Next(0, 31415926) / 10000000.0;</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">double</span> rand8 = randx.Next(0, 31415926) / 10000000.0;</pre>
<!--CRLF-->

    <pre class="alt">            <span class="rem">// amplitudes 振幅</span></pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">double</span> rand9 = randx.Next(330, 420) / 110.0;</pre>
<!--CRLF-->

    <pre class="alt">            <span class="kwrd">double</span> rand10 = randx.Next(330, 450) / 110.0;</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">double</span> amplitudesFactor = randx.Next(5, 6) / 10.0;<span class="rem">//振幅小点防止出界</span></pre>
<!--CRLF-->

    <pre class="alt">            <span class="kwrd">double</span> center = width / 2.0;</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">            <span class="rem">//wave distortion 波纹扭曲</span></pre>
<!--CRLF-->

    <pre class="alteven">            BitmapData destData = destBmp.LockBits(<span class="kwrd">new</span> Rectangle(0, 0, width, height), ImageLockMode.WriteOnly, destBmp.PixelFormat);</pre>
<!--CRLF-->

    <pre class="alt">            BitmapData srcData = srcBmp.LockBits(<span class="kwrd">new</span> Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, srcBmp.PixelFormat);</pre>
<!--CRLF-->

    <pre class="alteven">            <span class="kwrd">for</span> (var x = 0; x &lt; width; x++)</pre>
<!--CRLF-->

    <pre class="alt">            {</pre>
<!--CRLF-->

    <pre class="alteven">                <span class="kwrd">for</span> (var y = 0; y &lt; height; y++)</pre>
<!--CRLF-->

    <pre class="alt">                {</pre>
<!--CRLF-->

    <pre class="alteven">                    var sx = x + (Math.Sin(x * rand1 + rand5)</pre>
<!--CRLF-->

    <pre class="alt">                                + Math.Sin(y * rand3 + rand6)) * rand9 - width / 2 + center + 1;</pre>
<!--CRLF-->

    <pre class="alteven">                    var sy = y + (Math.Sin(x * rand2 + rand7)</pre>
<!--CRLF-->

    <pre class="alt">                                + Math.Sin(y * rand4 + rand8)) * rand10 * amplitudesFactor; <span class="rem">//振幅小点防止出界</span></pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">                    <span class="kwrd">int</span> color, color_x, color_y, color_xy;</pre>
<!--CRLF-->

    <pre class="alteven">                    Color overColor = Color.Empty;</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">                    <span class="kwrd">if</span> (sx &lt; 0 || sy &lt; 0 || sx &gt;= width - 1 || sy &gt;= height - 1)</pre>
<!--CRLF-->

    <pre class="alt">                    {</pre>
<!--CRLF-->

    <pre class="alteven">                        <span class="kwrd">continue</span>;</pre>
<!--CRLF-->

    <pre class="alt">                    }</pre>
<!--CRLF-->

    <pre class="alteven">                    <span class="kwrd">else</span></pre>
<!--CRLF-->

    <pre class="alt">                    {</pre>
<!--CRLF-->

    <pre class="alteven">                        color = BitmapDataColorAt(srcData, (<span class="kwrd">int</span>)sx, (<span class="kwrd">int</span>)sy).B;</pre>
<!--CRLF-->

    <pre class="alt">                        color_x = BitmapDataColorAt(srcData, (<span class="kwrd">int</span>)(sx + 1), (<span class="kwrd">int</span>)sy).B;</pre>
<!--CRLF-->

    <pre class="alteven">                        color_y = BitmapDataColorAt(srcData, (<span class="kwrd">int</span>)sx, (<span class="kwrd">int</span>)(sy + 1)).B;</pre>
<!--CRLF-->

    <pre class="alt">                        color_xy = BitmapDataColorAt(srcData, (<span class="kwrd">int</span>)(sx + 1), (<span class="kwrd">int</span>)(sy + 1)).B;</pre>
<!--CRLF-->

    <pre class="alteven">                    }</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">                    <span class="kwrd">if</span> (color == 255 &amp;&amp; color_x == 255 &amp;&amp; color_y == 255 &amp;&amp; color_xy == 255)</pre>
<!--CRLF-->

    <pre class="alt">                    {</pre>
<!--CRLF-->

    <pre class="alteven">                        <span class="kwrd">continue</span>;</pre>
<!--CRLF-->

    <pre class="alt">                    }</pre>
<!--CRLF-->

    <pre class="alteven">                    <span class="kwrd">else</span> <span class="kwrd">if</span> (color == 0 &amp;&amp; color_x == 0 &amp;&amp; color_y == 0 &amp;&amp; color_xy == 0)</pre>
<!--CRLF-->

    <pre class="alt">                    {</pre>
<!--CRLF-->

    <pre class="alteven">                        overColor = Color.FromArgb(foreground_color.R, foreground_color.G, foreground_color.B);</pre>
<!--CRLF-->

    <pre class="alt">                    }</pre>
<!--CRLF-->

    <pre class="alteven">                    <span class="kwrd">else</span></pre>
<!--CRLF-->

    <pre class="alt">                    {</pre>
<!--CRLF-->

    <pre class="alteven">                        <span class="kwrd">double</span> frsx = sx - Math.Floor(sx);</pre>
<!--CRLF-->

    <pre class="alt">                        <span class="kwrd">double</span> frsy = sy - Math.Floor(sy);</pre>
<!--CRLF-->

    <pre class="alteven">                        <span class="kwrd">double</span> frsx1 = 1 - frsx;</pre>
<!--CRLF-->

    <pre class="alt">                        <span class="kwrd">double</span> frsy1 = 1 - frsy;</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">                        <span class="kwrd">double</span> newColor =</pre>
<!--CRLF-->

    <pre class="alteven">                             color * frsx1 * frsy1 +</pre>
<!--CRLF-->

    <pre class="alt">                             color_x * frsx * frsy1 +</pre>
<!--CRLF-->

    <pre class="alteven">                             color_y * frsx1 * frsy +</pre>
<!--CRLF-->

    <pre class="alt">                             color_xy * frsx * frsy;</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">                        <span class="kwrd">if</span> (newColor &gt; 255) newColor = 255;</pre>
<!--CRLF-->

    <pre class="alteven">                        newColor = newColor / 255;</pre>
<!--CRLF-->

    <pre class="alt">                        <span class="kwrd">double</span> newcolor0 = 1 - newColor;</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">                        <span class="kwrd">int</span> newred = Math.Min((<span class="kwrd">int</span>)(newcolor0 * foreground_color.R + newColor * background_color.R), 255);</pre>
<!--CRLF-->

    <pre class="alteven">                        <span class="kwrd">int</span> newgreen = Math.Min((<span class="kwrd">int</span>)(newcolor0 * foreground_color.G + newColor * background_color.G), 255);</pre>
<!--CRLF-->

    <pre class="alt">                        <span class="kwrd">int</span> newblue = Math.Min((<span class="kwrd">int</span>)(newcolor0 * foreground_color.B + newColor * background_color.B), 255);</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">                        overColor = Color.FromArgb(newred, newgreen, newblue);</pre>
<!--CRLF-->

    <pre class="alteven">                    }</pre>
<!--CRLF-->

    <pre class="alt">                    BitmapDataColorSet(destData, x, y, overColor);</pre>
<!--CRLF-->

    <pre class="alteven">                }</pre>
<!--CRLF-->

    <pre class="alt">            }</pre>
<!--CRLF-->

    <pre class="alteven">            destBmp.UnlockBits(destData);</pre>
<!--CRLF-->

    <pre class="alt">            srcBmp.UnlockBits(srcData);</pre>
<!--CRLF-->

    <pre class="alteven">        }</pre>
<!--CRLF-->

    <pre class="alt">        <span class="kwrd">if</span> (srcBmp != <span class="kwrd">null</span>)</pre>
<!--CRLF-->

    <pre class="alteven">            srcBmp.Dispose();</pre>
<!--CRLF-->

    <pre class="alt">    }</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">return</span> destBmp;</pre>
<!--CRLF-->

    <pre class="alt">}</pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// 获得 BitmapData 指定坐标的颜色信息</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// 实现 PHP imagecolorat</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;srcData&quot;&gt;从图像数据获得颜色 必须为 PixelFormat.Format24bppRgb 格式图像数据&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;x&quot;&gt;&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;y&quot;&gt;&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;returns&gt;x,y 坐标的颜色数据&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;remarks&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// Format24BppRgb 已知X，Y坐标，像素第一个元素的位置为Scan0+(Y*Stride)+(X*3)。</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// 这是blue字节的位置，接下来的2个字节分别含有green、red数据。</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;/remarks&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="kwrd">static</span> Color BitmapDataColorAt(BitmapData srcData, <span class="kwrd">int</span> x, <span class="kwrd">int</span> y)</pre>
<!--CRLF-->

    <pre class="alt">{</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">if</span> (srcData.PixelFormat != PixelFormat.Format24bppRgb)</pre>
<!--CRLF-->

    <pre class="alt">        <span class="kwrd">throw</span> <span class="kwrd">new</span> ArgumentException(<span class="str">&quot;srcData PixelFormat.Format24bppRgb 格式图像数据&quot;</span>, <span class="str">&quot;srcData&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alteven">&#160;</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">byte</span>[] rgbValues = <span class="kwrd">new</span> <span class="kwrd">byte</span>[3];</pre>
<!--CRLF-->

    <pre class="alteven">    Marshal.Copy((IntPtr)((<span class="kwrd">int</span>)srcData.Scan0 + ((y * srcData.Stride) + (x * 3))), rgbValues, 0, 3);</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">return</span> Color.FromArgb(rgbValues[2], rgbValues[1], rgbValues[0]);</pre>
<!--CRLF-->

    <pre class="alteven">}</pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// 设置 BitmapData 指定坐标的颜色信息</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// 实现 PHP ImageColorSet</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;destData&quot;&gt;设置图像数据的颜色 必须为 PixelFormat.Format24bppRgb 格式图像数据&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;x&quot;&gt;&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;param name=&quot;y&quot;&gt;&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;param name=&quot;color&quot;&gt;待设置颜色&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// &lt;remarks&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// Format24BppRgb 已知X，Y坐标，像素第一个元素的位置为Scan0+(Y*Stride)+(X*3)。</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="rem">/// 这是blue字节的位置，接下来的2个字节分别含有green、red数据。</span></pre>
<!--CRLF-->

    <pre class="alteven"><span class="rem">/// &lt;/remarks&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span class="kwrd">static</span> <span class="kwrd">void</span> BitmapDataColorSet(BitmapData destData, <span class="kwrd">int</span> x, <span class="kwrd">int</span> y, Color color)</pre>
<!--CRLF-->

    <pre class="alteven">{</pre>
<!--CRLF-->

    <pre class="alt">    <span class="kwrd">if</span> (destData.PixelFormat != PixelFormat.Format24bppRgb)</pre>
<!--CRLF-->

    <pre class="alteven">        <span class="kwrd">throw</span> <span class="kwrd">new</span> ArgumentException(<span class="str">&quot;destData PixelFormat.Format24bppRgb 格式图像数据&quot;</span>, <span class="str">&quot;destData&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alt">&#160;</pre>
<!--CRLF-->

    <pre class="alteven">    <span class="kwrd">byte</span>[] rgbValues = <span class="kwrd">new</span> <span class="kwrd">byte</span>[3] { color.B, color.G, color.R };</pre>
<!--CRLF-->

    <pre class="alt">    Marshal.Copy(rgbValues, 0, (IntPtr)((<span class="kwrd">int</span>)destData.Scan0 + ((y * destData.Stride) + (x * 3))), 3);</pre>
<!--CRLF-->

    <pre class="alteven">}</pre>
<!--CRLF-->

    <pre class="alt"><span class="preproc">#endregion</span></pre>
<!--CRLF--></div>
</div>

<p>另外一些验证码游优化有关的链接:</p>

<ol>
  <li><a title="http://www.captcha.ru/en/kcaptcha/" href="http://www.captcha.ru/en/kcaptcha/">http://www.captcha.ru/en/kcaptcha/</a>&#160;&#160; (KCAPTCHA 官方) </li>

  <li><a title="http://zh.wikipedia.org/wiki/CAPTCHA" href="http://zh.wikipedia.org/wiki/CAPTCHA">http://zh.wikipedia.org/wiki/CAPTCHA</a> </li>

  <li><a title="http://en.wikipedia.org/wiki/CAPTCHA" href="http://en.wikipedia.org/wiki/CAPTCHA">http://en.wikipedia.org/wiki/CAPTCHA</a> </li>

  <li><a title="http://caca.zoy.org/wiki/PWNtcha" href="http://caca.zoy.org/wiki/PWNtcha">http://caca.zoy.org/wiki/PWNtcha</a> </li>

  <li><a title="http://www.brains-n-brawn.com/default.aspx?vDir=aicaptcha" href="http://www.brains-n-brawn.com/default.aspx?vDir=aicaptcha">http://www.brains-n-brawn.com/default.aspx?vDir=aicaptcha</a> </li>

  <li><a title="http://www.captcha.net/" href="http://www.captcha.net/">http://www.captcha.net/</a> </li>
</ol>

<p>还有一些验证码识别的链接:</p>

<ol>
  <li><a title="http://www.cnblogs.com/xiaotie/archive/2009/01/15/1376677.html" href="http://www.cnblogs.com/xiaotie/archive/2009/01/15/1376677.html">http://www.cnblogs.com/xiaotie/archive/2009/01/15/1376677.html</a> </li>

  <li><a title="http://www.codeproject.com/KB/recipes/Shape_context_matching.aspx" href="http://www.codeproject.com/KB/recipes/Shape_context_matching.aspx">http://www.codeproject.com/KB/recipes/Shape_context_matching.aspx</a> </li>

  <li><a title="http://en.wikipedia.org/wiki/Shape_context" href="http://en.wikipedia.org/wiki/Shape_context">http://en.wikipedia.org/wiki/Shape_context</a> </li>

  <li><a title="http://www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html" href="http://www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html">http://www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/sc_digits.html</a> </li>
</ol>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/480.htm</link>
			<title><![CDATA[编程中使用的数学(2):权重随机]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[原创]]></category>
			<pubDate>Tue,19 Jan 2010 22:49:31 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=480</guid>
		<description><![CDATA[<p>博客也停了半年多了, 半年内好多事情, 时间和机会可能都不适合写下点东西, 2010年了, 开个好头. <a title="编程中使用的数学" href="http://zhq.ahau.edu.cn/blog/article/444.htm" target="_blank">之前的一篇</a>写在2008年6月份, 这篇写在一年半以后, 真是个笑话.</p>  <p>步入正题. '权重随机'是去年九十月份工作中一个抽奖问题引出的. 需求需要达到不同奖品需要有不同的获得几率, 在查找资料中找到了以下几篇文章:</p>  <ol>   <li><a href="http://zzk.cnblogs.com/s?w=%e6%9d%83%e9%87%8d+%e9%9a%8f%e6%9c%ba&amp;p=1">http://zzk.cnblogs.com/s?w=%e6%9d%83%e9%87%8d+%e9%9a%8f%e6%9c%ba&amp;p=1</a> </li>    <li>生成安全的随机数&#160;&#160;&#160; <a href="http://www.cnblogs.com/rainy/archive/2006/08/05/468670.html">http://www.cnblogs.com/rainy/archive/2006/08/05/468670.html</a> </li>    <li><a title="http://www.cnblogs.com/wdfrog/archive/2007/12/14/994963.html" href="http://www.cnblogs.com/wdfrog/archive/2007/12/14/994963.html">http://www.cnblogs.com/wdfrog/archive/2007/12/14/994963.html</a> </li> </ol>  <p>按'权重随机'过程假设编程平台上的提供的随机发生器产生的每个结果都是等概率的(实际上.NET平台和其他编程平台上提供了很好的满足本条件的随机发生器), 另外一个条件是'权重'以非负整形数的形式提供. 假如'待随机项'集合为 {I,…,I<sub>n</sub>}, 其对应的权重结合为 {W,…,W<sub>n</sub>}, 在产生随机数的时候随机的范围为(0, ∑W<sub>i</sub>), 其中∑W<sub>i</sub>表示为'所有待随机项权重的和', 使用随机器产生的随机结果假如在 (w<sub>i</sub>, w<sub>i+1</sub>] 范围了(注意开闭区间), 则当前的随机结果项为I<sub>i</sub>. 可以简单理解为以下的文字描述: 把所有'待随机项'的权重和作为要随机的上限, '随机项'前后排好序, 生成的随机结果如果在某两个个随机项(A,B)权重区间范围内, 那么随机的结果项就取A. </p>  <p>经过上面几篇的文章的研读和抄袭后就出了今天文章中的代码, 下面是'权重随机'核心代码部分:</p>  <div id="codeSnippetWrapper" class="csharpcode-wrapper">   <div id="codeSnippet" class="csharpcode">     <pre class="alt"><span id="lnum1" class="lnum">   1:</span> <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum2" class="lnum">   2:</span> <span class="rem">/// 根据随机器和权重和得到随机结果项</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum3" class="lnum">   3:</span> <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum4" class="lnum">   4:</span> <span class="rem">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum5" class="lnum">   5:</span> <span class="rem">/// &lt;param name=&quot;items&quot;&gt;权重项&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum6" class="lnum">   6:</span> <span class="rem">/// &lt;param name=&quot;rng&quot;&gt;随机化器&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum7" class="lnum">   7:</span> <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum8" class="lnum">   8:</span> <span class="kwrd">static</span> WeightItem&lt;T&gt; GetRandowmItem&lt;T&gt;(IEnumerable&lt;WeightItem&lt;T&gt;&gt; items, IRNG rng)</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum9" class="lnum">   9:</span> {</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum10" class="lnum">  10:</span>     <span class="kwrd">int</span> sum = GetSum(items);</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum11" class="lnum">  11:</span>     <span class="kwrd">int</span> rand = rng.Next(0, sum);</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum12" class="lnum">  12:</span>     <span class="kwrd">int</span> cSum = 0;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum13" class="lnum">  13:</span>     <span class="kwrd">foreach</span> (var item <span class="kwrd">in</span> items)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum14" class="lnum">  14:</span>     {</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum15" class="lnum">  15:</span>         cSum += item.Weight;</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum16" class="lnum">  16:</span>         <span class="kwrd">if</span> (cSum &gt; rand)</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum17" class="lnum">  17:</span>             <span class="kwrd">return</span> item;</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum18" class="lnum">  18:</span>     }</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum19" class="lnum">  19:</span>     <span class="kwrd">return</span> <span class="kwrd">new</span> WeightItem&lt;T&gt;();    </pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum20" class="lnum">  20:</span> }</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum21" class="lnum">  21:</span> <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum22" class="lnum">  22:</span> <span class="rem">/// 得到当前随机项权重和</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum23" class="lnum">  23:</span> <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum24" class="lnum">  24:</span> <span class="rem">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum25" class="lnum">  25:</span> <span class="rem">/// &lt;param name=&quot;items&quot;&gt;&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum26" class="lnum">  26:</span> <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum27" class="lnum">  27:</span> <span class="kwrd">static</span> <span class="kwrd">int</span> GetSum&lt;T&gt;(IEnumerable&lt;WeightItem&lt;T&gt;&gt; items)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum28" class="lnum">  28:</span> {</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum29" class="lnum">  29:</span>     <span class="kwrd">int</span> sum = 0;</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum30" class="lnum">  30:</span>     <span class="kwrd">foreach</span> (var item <span class="kwrd">in</span> items)</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum31" class="lnum">  31:</span>     {</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum32" class="lnum">  32:</span>         sum += item.Weight;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum33" class="lnum">  33:</span>     }</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum34" class="lnum">  34:</span>     <span class="kwrd">return</span> sum;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum35" class="lnum">  35:</span> }</pre>
<!--CRLF--></div>
</div>

<p>10-18行是完成整个权重随机过程, 代码与之前某篇文章&lt;<a title="http://www.cnblogs.com/wdfrog/archive/2007/12/14/994963.html" href="http://www.cnblogs.com/wdfrog/archive/2007/12/14/994963.html">http://www.cnblogs.com/wdfrog/archive/2007/12/14/994963.html</a>&gt;的实现一致, 只是这个&quot;IRNG rng&quot;有点不一样, IRNG是一个随机发生器的封装接口:</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt"><span id="lnum1" class="lnum">   1:</span> <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum2" class="lnum">   2:</span> <span class="rem">/// 随机化器 接口类</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum3" class="lnum">   3:</span> <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum4" class="lnum">   4:</span> <span class="kwrd">public</span> <span class="kwrd">interface</span> IRNG</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum5" class="lnum">   5:</span> {</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum6" class="lnum">   6:</span>     <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum7" class="lnum">   7:</span>     <span class="rem">/// 返回一个指定范围内的随机数</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum8" class="lnum">   8:</span>     <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum9" class="lnum">   9:</span>     <span class="rem">/// &lt;param name=&quot;minValue&quot;&gt;返回的随机数的下界(随机数可取该下界值)&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum10" class="lnum">  10:</span>     <span class="rem">/// &lt;param name=&quot;maxValue&quot;&gt; 返回的随机数的上界(随机数不能取该上界值), maxValue 必须大于或等于 minValue&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum11" class="lnum">  11:</span>     <span class="rem">/// &lt;returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum12" class="lnum">  12:</span>     <span class="rem">/// 一个大于或等于 minValue 且小于 maxValue 的 32 位带符号整数, 即: 返回的值范围包括 minValue 但不包括 maxValue. 如果</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum13" class="lnum">  13:</span>     <span class="rem">/// minValue 等于 maxValue, 则返回 minValue</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum14" class="lnum">  14:</span>     <span class="rem">/// &lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum15" class="lnum">  15:</span>     <span class="kwrd">int</span> Next(<span class="kwrd">int</span> minValue, <span class="kwrd">int</span> maxValue);</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum16" class="lnum">  16:</span> }</pre>
<!--CRLF--></div>
</div>

<p>封装的目的是 .NET 中默认的 <a href="http://msdn.microsoft.com/zh-cn/library/system.random(VS.80).aspx" target="_blank">System.Random</a> 随机可能不够完美, 或不够安全, 所以封装了使用 <a href="http://msdn.microsoft.com/zh-cn/library/system.security.cryptography.rngcryptoserviceprovider(VS.80).aspx" target="_blank">System.Security.Cryptography.RNGCryptoServiceProvider</a> 来随机的随机器. int Next(int minValue, int maxValue) 实现如下:</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt"><span id="lnum1" class="lnum">   1:</span> <span class="kwrd">public</span> <span class="kwrd">int</span> Next(<span class="kwrd">int</span> minValue, <span class="kwrd">int</span> maxValue)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum2" class="lnum">   2:</span> {</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum3" class="lnum">   3:</span>     <span class="kwrd">if</span> (minValue &gt; maxValue)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum4" class="lnum">   4:</span>         <span class="kwrd">throw</span> <span class="kwrd">new</span> ArgumentOutOfRangeException(<span class="str">&quot;minValue&quot;</span>, <span class="str">&quot;&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum5" class="lnum">   5:</span>&#160; </pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum6" class="lnum">   6:</span>     <span class="kwrd">int</span> numSides = maxValue - minValue;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum7" class="lnum">   7:</span>     <span class="kwrd">byte</span>[] bn = <span class="kwrd">new</span> <span class="kwrd">byte</span>[4];</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum8" class="lnum">   8:</span>     <span class="kwrd">int</span> num = 0;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum9" class="lnum">   9:</span>&#160; </pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum10" class="lnum">  10:</span>     rand.GetBytes(bn);</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum11" class="lnum">  11:</span>     num = BitConverter.ToInt32(bn, 0);</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum12" class="lnum">  12:</span>     num = num % numSides;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum13" class="lnum">  13:</span>     <span class="kwrd">if</span> (num &lt; 0)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum14" class="lnum">  14:</span>         num = -num;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum15" class="lnum">  15:</span>&#160; </pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum16" class="lnum">  16:</span>     <span class="kwrd">return</span> num + minValue;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum17" class="lnum">  17:</span> }</pre>
<!--CRLF--></div>
</div>

<p>上面的实现实际上来自于这里:&lt;<a title="http://www.cnblogs.com/rainy/archive/2006/08/05/468670.html" href="http://www.cnblogs.com/rainy/archive/2006/08/05/468670.html">http://www.cnblogs.com/rainy/archive/2006/08/05/468670.html</a>&gt;. 由于使用 <a href="http://msdn.microsoft.com/zh-cn/library/system.security.cryptography.rngcryptoserviceprovider(VS.80).aspx" target="_blank">RNGCryptoServiceProvider</a> 来随机, 可能计算有点慢, 不过没有详细测试.</p>

<p>为了增加本文中实现的权重随机的通用性, 还实现了一个泛型'随机项'类,&#160; 如下:</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt"><span id="lnum1" class="lnum">   1:</span> <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum2" class="lnum">   2:</span> <span class="rem">/// 权重项</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum3" class="lnum">   3:</span> <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum4" class="lnum">   4:</span> <span class="rem">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum5" class="lnum">   5:</span> <span class="kwrd">public</span> <span class="kwrd">class</span> WeightItem&lt;T&gt;</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum6" class="lnum">   6:</span> {</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum7" class="lnum">   7:</span>     <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum8" class="lnum">   8:</span>     <span class="rem">/// 权重</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum9" class="lnum">   9:</span>     <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum10" class="lnum">  10:</span>     <span class="kwrd">public</span> <span class="kwrd">int</span> Weight { get; set; }</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum11" class="lnum">  11:</span>     <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum12" class="lnum">  12:</span>     <span class="rem">/// 项值</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum13" class="lnum">  13:</span>     <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum14" class="lnum">  14:</span>     <span class="kwrd">public</span> T ItemValue { get; set; }</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum15" class="lnum">  15:</span>     <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum16" class="lnum">  16:</span>     <span class="rem">/// </span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum17" class="lnum">  17:</span>     <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum18" class="lnum">  18:</span>     <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum19" class="lnum">  19:</span>     <span class="kwrd">public</span> <span class="kwrd">override</span> <span class="kwrd">string</span> ToString()</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum20" class="lnum">  20:</span>     {</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum21" class="lnum">  21:</span>         <span class="kwrd">return</span> <span class="kwrd">string</span>.Format(<span class="str">&quot;[ItemValue:{0}, Weight:{1}]&quot;</span>, ItemValue, Weight);</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum22" class="lnum">  22:</span>     }</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum23" class="lnum">  23:</span> }</pre>
<!--CRLF--></div>
</div>

<p>测试代码如下:</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt"><span id="lnum1" class="lnum">   1:</span> <span class="rem">//权重随机项-1</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum2" class="lnum">   2:</span> List&lt;WeightItem&lt;<span class="kwrd">char</span>&gt;&gt; wItems = <span class="kwrd">new</span> List&lt;WeightItem&lt;<span class="kwrd">char</span>&gt;&gt;() { </pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum3" class="lnum">   3:</span>     <span class="kwrd">new</span> WeightItem&lt;<span class="kwrd">char</span>&gt;(){ ItemValue=<span class="str">'A'</span>, Weight=60},</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum4" class="lnum">   4:</span>     <span class="kwrd">new</span> WeightItem&lt;<span class="kwrd">char</span>&gt;(){ ItemValue=<span class="str">'B'</span>, Weight=30},</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum5" class="lnum">   5:</span>     <span class="kwrd">new</span> WeightItem&lt;<span class="kwrd">char</span>&gt;(){ ItemValue=<span class="str">'C'</span>, Weight=5},</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum6" class="lnum">   6:</span>     <span class="kwrd">new</span> WeightItem&lt;<span class="kwrd">char</span>&gt;(){ ItemValue=<span class="str">'D'</span>, Weight=5},</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum7" class="lnum">   7:</span> };</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum8" class="lnum">   8:</span> <span class="rem">//随机器</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum9" class="lnum">   9:</span> IRNG rng = <span class="kwrd">new</span> RNG.SysCspRNG();</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum10" class="lnum">  10:</span> <span class="rem">//结果保存字典</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum11" class="lnum">  11:</span> Dictionary&lt;<span class="kwrd">char</span>, <span class="kwrd">int</span>&gt; dicResult = <span class="kwrd">new</span> Dictionary&lt;<span class="kwrd">char</span>, <span class="kwrd">int</span>&gt;();</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum12" class="lnum">  12:</span> <span class="rem">//根据随机项取得1000000次随机结果</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum13" class="lnum">  13:</span> List&lt;WeightItem&lt;<span class="kwrd">char</span>&gt;&gt; resultList = RandomHelper.GetRandomItemsFromWeightItems(wItems, rng, 1000000);</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum14" class="lnum">  14:</span> <span class="kwrd">foreach</span> (var item <span class="kwrd">in</span> resultList)</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum15" class="lnum">  15:</span> {</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum16" class="lnum">  16:</span>     <span class="kwrd">if</span> (dicResult.ContainsKey(item.ItemValue))</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum17" class="lnum">  17:</span>         dicResult[item.ItemValue]++;</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum18" class="lnum">  18:</span>     <span class="kwrd">else</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum19" class="lnum">  19:</span>         dicResult.Add(item.ItemValue, 0);</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum20" class="lnum">  20:</span> }</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum21" class="lnum">  21:</span> <span class="rem">//打印结果</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum22" class="lnum">  22:</span> <span class="kwrd">foreach</span> (var item <span class="kwrd">in</span> dicResult)</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum23" class="lnum">  23:</span> {</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum24" class="lnum">  24:</span>     Console.WriteLine(<span class="str">&quot;{0}:{1}&quot;</span>, item.Key, item.Value);</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum25" class="lnum">  25:</span> }</pre>
<!--CRLF--></div>
</div>

<p>测试代码中随机项为 {A, B, C, D}, 权重分别为 {60, 30, 5, 5}, 为了计算方面随机 100 的倍数.次 代码中 'IRNG rng = new RNG.SysCspRNG();' 即为实现了IRNG接口使用 <a href="http://msdn.microsoft.com/zh-cn/library/system.security.cryptography.rngcryptoserviceprovider(VS.80).aspx" target="_blank">RNGCryptoServiceProvider</a> 来随机的随机器. RandomHelper.GetRandomItemsFromWeightItems 是封装了之前的'权重随机'函数的一个支持批量随机的静态方法, 如下:</p>

<div id="codeSnippetWrapper" class="csharpcode-wrapper">
  <div id="codeSnippet" class="csharpcode">
    <pre class="alt"><span id="lnum1" class="lnum">   1:</span> <span class="rem">/// &lt;summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum2" class="lnum">   2:</span> <span class="rem">/// 根据'权重项列表'和'随机次数'得到'随机项结果列表'</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum3" class="lnum">   3:</span> <span class="rem">/// &lt;/summary&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum4" class="lnum">   4:</span> <span class="rem">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum5" class="lnum">   5:</span> <span class="rem">/// &lt;param name=&quot;items&quot;&gt;权重项&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum6" class="lnum">   6:</span> <span class="rem">/// &lt;param name=&quot;rng&quot;&gt;随机化器&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum7" class="lnum">   7:</span> <span class="rem">/// &lt;param name=&quot;times&quot;&gt;随机次数&lt;/param&gt;</span></pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum8" class="lnum">   8:</span> <span class="rem">/// &lt;returns&gt;随机结果项列表&lt;/returns&gt;</span></pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum9" class="lnum">   9:</span> <span class="kwrd">public</span> <span class="kwrd">static</span> List&lt;WeightItem&lt;T&gt;&gt; GetRandomItemsFromWeightItems&lt;T&gt;(IEnumerable&lt;WeightItem&lt;T&gt;&gt; items, IRNG rng, <span class="kwrd">int</span> times)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum10" class="lnum">  10:</span> {</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum11" class="lnum">  11:</span>     <span class="kwrd">if</span> (items == <span class="kwrd">null</span>)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum12" class="lnum">  12:</span>         <span class="kwrd">throw</span> <span class="kwrd">new</span> System.ArgumentNullException(<span class="str">&quot;items&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum13" class="lnum">  13:</span>     <span class="kwrd">if</span> (rng == <span class="kwrd">null</span>)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum14" class="lnum">  14:</span>         <span class="kwrd">throw</span> <span class="kwrd">new</span> System.ArgumentNullException(<span class="str">&quot;rng&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum15" class="lnum">  15:</span>     <span class="kwrd">if</span> (times &lt;0)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum16" class="lnum">  16:</span>         <span class="kwrd">throw</span> <span class="kwrd">new</span> System.ArgumentException(<span class="str">&quot;'随机次数'必须大于0&quot;</span>,<span class="str">&quot;times&quot;</span>);</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum17" class="lnum">  17:</span>&#160; </pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum18" class="lnum">  18:</span>     <span class="kwrd">int</span> sum = GetSum(items);</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum19" class="lnum">  19:</span>     List&lt;WeightItem&lt;T&gt;&gt; list = <span class="kwrd">new</span> List&lt;WeightItem&lt;T&gt;&gt;(times);</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum20" class="lnum">  20:</span>&#160; </pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum21" class="lnum">  21:</span>     <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; times; i++)</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum22" class="lnum">  22:</span>     {</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum23" class="lnum">  23:</span>         list.Add(GetRandowmItem(items,rng, sum));</pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum24" class="lnum">  24:</span>     }</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum25" class="lnum">  25:</span>&#160; </pre>
<!--CRLF-->

    <pre class="alteven"><span id="lnum26" class="lnum">  26:</span>     <span class="kwrd">return</span> list;</pre>
<!--CRLF-->

    <pre class="alt"><span id="lnum27" class="lnum">  27:</span> }</pre>
<!--CRLF--></div>
</div>

<p>随机结果如下:</p>

<blockquote>
  <p>B:299348 
    <br />A:600648 

    <br />D:49713 

    <br />C:50287 </p>
</blockquote>

<p>基本是按&quot;A:60, B:30, C:5, D5&quot; 的权重比例来的.</p>

<p>就这么多内容, 另外推荐以下文章作为扩展阅读:</p>

<ol>
  <li><a title="http://security.ctocio.com.cn/securitycomment/385/8082385.shtml" href="http://security.ctocio.com.cn/securitycomment/385/8082385.shtml">http://security.ctocio.com.cn/securitycomment/385/8082385.shtml</a> </li>

  <li><a title="http://zh.linuxvirtualserver.org/node/35" href="http://zh.linuxvirtualserver.org/node/35">http://zh.linuxvirtualserver.org/node/35</a> </li>

  <li><a title="http://zh.linuxvirtualserver.org/node/36" href="http://zh.linuxvirtualserver.org/node/36">http://zh.linuxvirtualserver.org/node/36</a> </li>

  <li><a title="http://zh.linuxvirtualserver.org/node/37" href="http://zh.linuxvirtualserver.org/node/37">http://zh.linuxvirtualserver.org/node/37</a> </li>

  <li><a title="http://mindhacks.cn/2008/09/21/the-magical-bayesian-method/" href="http://mindhacks.cn/2008/09/21/the-magical-bayesian-method/">http://mindhacks.cn/2008/09/21/the-magical-bayesian-method/</a> </li>

  <li><a title="http://jun.wu.googlepages.com/beautyofmathematics" href="http://jun.wu.googlepages.com/beautyofmathematics">http://jun.wu.googlepages.com/beautyofmathematics</a> </li>
</ol>

<p>&#160;</p>

<p>演示代码下载如下:</p>
<iframe style="padding-bottom: 0px; background-color: #fcfcfc; padding-left: 0px; width: 98px; padding-right: 0px; height: 115px; padding-top: 0px" title="Preview" marginheight="0" src="http://cid-e63ac91b5bfc8e30.skydrive.live.com/embedicon.aspx/Public/TUP.WeightRandom.zip" frameborder="0" marginwidth="0" scrolling="no"></iframe>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/475.htm</link>
			<title><![CDATA[软件开发经典书籍的魅力]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[原创]]></category>
			<pubDate>Mon,06 Apr 2009 10:07:26 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=475</guid>
		<description><![CDATA[<p>读软件开发方面书籍自己似乎有偏好，不喜欢看国内作者写的（不过有好书也是看的，比如<a href="http://www.broadview.com.cn" target="_blank">博文视点</a>的好多原创经典书籍）大部分看的是国外书籍的译本（英语不好只能看译本），译本也是有选择的，如果是一堆人翻译的基本也不看，除非这本书讲的方面确实就这么一本书，并且翻译的也不赖。<a href="http://www.cnblogs.com" target="_blank">博客园</a>有一.NET方面的牛人名叫“<a href="http://zhq.ahau.edu.cn/blog/www.cnblogs.com/JeffreyZhao/" target="_blank">老赵</a>”，他的博客格言是“让老外看中国人写的计算机书籍”，甚是敬仰。</p>  <p>过年前后接手的项目是一个“客户端数据录入”的软件，之前开发的都是B/S软件，对WinForm开发中的某些要求也不甚了解，所以按着WEB软件的模式来建立“数据连接层”、“业务逻辑层”。其实自己使用了一个“<a href="http://www.socansoft.com/" target="_blank">SocanCode</a>”的代码生成器来生成了“数据连接层”和“业务逻辑层”，由于客户要求的这个客户端软件除了要有一个“中心版”还要一个“部门版”的（软件为什么没有直接设计成B/S版的呢？因为客户的理由是“部门版”的用户可能没有网络，并且点名要搞两个版本），考虑到性能方面的要求所以“部门版”数据库用Access，“中心版”使用SQL Server 2000 个人版，所以这个“代码生成器”生成了两套“数据连接层”代码，真是不错的东西。</p>  <p>“<a href="http://www.socansoft.com/" target="_blank">SocanCode</a>”生成的代码类似于“PetShop 4”，模式的代码，“数据实体模型”部分直接就是实体类，软件在实现的时候碰到一个问题：数据库的某些字段的值与其他字段有隐藏的“关联”关系，比如一个XX号=某些字典字段+某些字典字段+自编号。数据库在设计的时候实际上已经违背了某些“数据库设计范式”，因为为了最后呈现的时候方便，也为了客户在导出数据的时候方便。为了实现这个“关联”最后每个“数据实体模型”实现了“<a href="http://msdn.microsoft.com/zh-cn/library/system.componentmodel.inotifypropertychanged(VS.80).aspx" target="_blank">System.ComponentModel.INotifyPropertyChanged</a>”接口，来“通知”某些列的更改，通过“PropertyChanged”事件来捕捉“通知”，再“Remove”事件，更改某些“关联”关系的字段值，再“Add”事件来完成整一个“关联”关系字段的控制。虽然实现起来麻烦了点，但客户再提“关联”关系字段更改的需求改的就很方便了。</p>  <p>软件交付之后，经过几次的BUG修改，客户数据录入接近尾声之后，客户要求“中心版”软件“数据横表（起始就是一个GridView）”部分要有可编辑功能，因为“部门”录入的数据太乱了，需要快速编辑修改功能。问题出来了“得到数据横表更改，保存数据横表更改的数据”怎么解决？记得学习.NET的时候使用DataSet+DataAdapter来完成数据绑定到表格，批量更改后“DataTable.GetChanges()”更改，保存数据，再“DataTable.AcceptChanges()”更改，就可以了。事情到了这个步骤更改成DataSet来实现肯定软件动的地方不少。最后解决的办法是“数据横表”绑定的“数据实体列表”转换成“DataTable”，修改完成后再转换成“List&lt;&gt;”类型的数据列表，再保存数据。在更改这个“横表”编辑功能的时候又发现一个问题“用户录入表单编辑的数据撤销操作后无法回复原来数据”，记得一本好像是“<a href="http://www.douban.com/subject/2127497/" target="_blank">Expert C# 2005 Business Objects</a>”书籍上讲到“多层撤销”的问题，解决的方法是“数据实体模型”实现了“<a href="http://msdn.microsoft.com/zh-cn/library/system.componentmodel.ieditableobject(VS.80).aspx" target="_blank">System.ComponentModel.IEditableObject</a>”结构，使得实体模型对象具有了“BeginEdit、CancelEdit、EndEdit”功能，为了期间的一个数据拷贝功能“数据实体模型”又实现了“<a href="http://msdn.microsoft.com/zh-cn/library/system.icloneable.aspx" target="_blank">System.ICloneable</a>”接口。最后总算所有的问题都解决来了，好像很累人，还好在处理数据“关联”问题时没有去实现“<a href="http://msdn.microsoft.com/zh-cn/library/system.componentmodel.ibindinglist(VS.80).aspx" target="_blank">System.ComponentModel.IBindingList</a>”接口。</p>  <p>似乎自己在开发WinForm软件的时候犯了很大错误——把WinForm当成了WEB程序来开发，结构一开始就错了。如果一开始使用“强类型数据集”也没有多少错误（没有用的原因是自己在原先的WEB开发中因为使用“强类型数据集”，在后期给自己维护造成了很大的麻烦），最后为了实现某些功能自己实现了一个超级简化版的“DataTable”，自己在为了实现“数据实体模型”可以“GetChanges()”的时候差一点把“数据实体模型”进行了一个大规模的代码重构（因为在CodeProject上一篇文章讲到了可以使得得到“实体模型类表”具有“GetChanges()”功能的方法）。</p>  <p>清明节到图书城看到了《<a href="http://www.douban.com/subject/2054931/" target="_blank">Effective C#</a>》这本书，其实自己从前看过这本书，只是没有认真的看，其中的的第41条：《<a href="http://www.cnblogs.com/WuCountry/archive/2007/03/31/695300.html" target="_blank">选择DataSet而不是自定义的数据结构</a>（Prefer DataSets to Custom Structures）》，看了之后真是羞愧万千，怪自己没有认真的领悟书中的东西，下面是内容摘要：</p>  <blockquote>   <p>因为两个原则，把DataSet的名声搞的不好。首先就是使用XML序列化的DataSet与其它的非.Net代码进行交互时不方便。如果在Web服务的API中使用DataSet时，在与其它没有使用.Net框架的系统进行交互时会相当困难。其次，它是一个很一般的容器。你可以通过欺骗.Net框架里的一些安全类型来错误DataSet。但在现代软件系统中，DataSet还可以解决很多常规的问题。如果你明白它的优势，避免它的缺点，你就可以扩展这个类型了。 </p>    <p>DataSet类设计出来是为了离线使用一些存储在相关数据库里的数据。你已经知道它是用来存储DataTable的，而DataTable就是一个与数据库里的结构在行和列上进行匹配的内存表。或许你已经看到过一些关于DataSet支持在内部的表中建立关系的例子。甚至还有可能，你已经见过在DataSet里验证它所包含的数据，进行数据约束的例子。 </p>    <p>但不仅仅是这些，DataSet还支持AcceptChanges 和RejectChanges 方法来进行事务处理，而且它们可以做为DiffGrams存储，也就是包含曾经修改过的数据。多个DataSet还可以通过合并成为一个常规的存储库。DataSet还支持视图，这就是说你可以通过标准的查询来检测数据里的部份内容。而且视图是可以建立在多个表上的。 </p>    <p>然而，有些人想开发自己的存储结构，而不用DataSet。因DataSet是一个太一般的容器，这会在性能上有所损失。一个DataSet并不是一个强类型的存储容器，其实存储在里面的对象是一个字典。而且在里的表中的列也是字典。存储在里的元素都是以System.Object的引用形式存在。这使得我们要这样写代码： </p>    <p>…省略中间部分…      <br /></p>    <p>花了几页的代码来支持一些已经在DataSet里实现的了的功能。实际上，这还不能像DataSet那样恰当的工作。例如，交互式的添加一个新记录到集合中，以及支持事务所要求的BeginEdit, CancelEdit, 和EndEdit等。 你要在CancelEdit 调用时检测一个新的对象而不是一个已经修改了的对象。CancelEdit 必须从集合上移除这个新的对象，该对象应该是上次调用BeginEdit时创建的。对于AddressRecord 来说，还有很多修改要完成，而且一对事件还要添加到AddressList 类上。 </p>    <p>最后，就是这个IBindingList接口。这个接口至少包含了20个方法和属性，用于控件查询列表上的功能描述。你必须为只读列表实现IBindingList 或者交互排序，或者支持搜索。在你取得内容之前就陷于层次关系和导航关系中了。我也不准备为上面所有的代码添加任何例子了。      <br />几页过后，再问问你自己，还准备创建你自己的特殊集合吗？或者你想使用一个DataSet吗？除非你的集合是一个基于某些算法，对性能要求严格的集合，或者必须有轻便的格式，就要使用自己的DataSet，特别是类型化的DataSet。这将花去你大量的时间，是的，你可以争辩说DataSet并不是一个基于面向对象设计的最好的例子。类型化的DataSet甚至会破坏更多的规则。但，使用它所产生的代码开发效率，比起自己手写更优美的代码所花的时间，</p>    <p>这只是其中一小部分。</p> </blockquote>  <p>经典的书籍往往就是经典，C++方面经典的书籍一版一版的发布，一次一次的印刷，看得人津津乐道，JAVA方面的书籍也是这样。C#方面因为也就八九年的时间，经典的书籍似乎少了点，大概是翻译成中文的不多（国人写的似乎流行不起来），但一本《Effective C#》虽然讲解的是“C# 1.0”方面的内容，但毕竟是.NET方面的，内容很经典。这些天闲了在看一本《<a href="http://www.douban.com/subject/1230559/" target="_blank">企业应用架构模式</a>》的书籍，书籍至少是03年之前的写的，到现在.NET软件开发设计方面的内容也有很多进步，但这本书讲的确实很不错，用现在的眼光来看作者讲的确实很有前瞻性，应该是自己并不了解企业软件开发方面的内容，这么多年自己只能从七七八八的书籍上来自己体会企业软件开发，看到这本书真是眼前一亮。</p>  <p>&#160;</p>  <blockquote>   <p>万物变化的季节</p>    <p>TUPUNCO</p>    <p>2009.04.05</p>    <p>好运每一天</p></blockquote>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/474.htm</link>
			<title><![CDATA[ASP.NET MVC CRUD 实例]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[原创]]></category>
			<pubDate>Tue,24 Mar 2009 10:01:20 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=474</guid>
		<description><![CDATA[<p><a href="http://www.asp.net/mvc" rel="tag" target="_blank">ASP.NET MVC</a> 1.0 已经于上周发布了, RC1的时候写了两个例子, 一个是一个CRUD的例子, 一个是仿<a href="http://www.blueidea.com" rel="tag" target="_blank">蓝色梦想</a><a href="http://Case.Blueidea.Com" rel="tag" target="_blank">作品集</a>URL路径的例子. CRUD例子是一个拥有完整的从&quot;数据源&quot;查询数据列表/单条详细/删除/更新添加的功能的列子, 仿蓝色梦想作品集URL路径的例子是模仿作品集的URL切换方式, 展示了ASP.NET MVC 功能强大的路由功能, 自定义控件的列子. 本文事CRUD例子的说明和技术细节.</p>  <p>ASP.NET MVC安装/创建项目的方法可以参看<a href="http://www.asp.net/mvc">http://www.asp.net/mvc</a>的说明教程. </p>  <p>创建项目完毕后, 创建一个数据模型(实际为一数据实体)和数据服务(Fake的数据仓库)部分代码:</p>  <div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">   <div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">     <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">namespace</span> MvcApplicationCRUD.Models</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> People</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Id { get; set; }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> <span style="color: #0000ff">int</span> Age { get; set; }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> <span style="color: #0000ff">string</span> Name { get; set; }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">}</pre>
  </div>
</div>

<p>&#160;</p>

<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
  <div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">using</span> System.Collections.Generic;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">namespace</span> MvcApplicationCRUD.Models</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> PeopleDataService</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> List&lt;People&gt; PeopleList = <span style="color: #0000ff">null</span>;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">static</span> PeopleDataService()</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            PeopleList = <span style="color: #0000ff">new</span> List&lt;People&gt;();</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 20; i++)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                PeopleList.Add(<span style="color: #0000ff">new</span> People() { Id = i + 1, Name = <span style="color: #006080">&quot;name&quot;</span> + i * i, Age = i + 10 });</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">}</pre>
  </div>
</div>

<p>实现Controller内各个Action:</p>

<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; height: 285px; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
  <div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">using</span> System;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">using</span> System.Linq;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">using</span> System.Web.Mvc;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">namespace</span> MvcApplicationCRUD.Controllers</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">using</span> MvcPaging;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">using</span> Models;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> PeopleController : Controller</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">private</span> <span style="color: #0000ff">const</span> <span style="color: #0000ff">int</span> defaultPageSize = 10;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">//</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">// GET: /People/</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// 列表分页显示</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;param name=&quot;page&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> ActionResult Index(<span style="color: #0000ff">int</span>? page)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            var peopleList = PeopleDataService.PeopleList;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">int</span> currentPageIndex = page.HasValue ? page.Value - 1 : 0;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">return</span> View(peopleList.ToPagedList(currentPageIndex, defaultPageSize));</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">//</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">// GET: /People/Details/5</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// 单条详细显示</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;param name=&quot;id&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> ActionResult Details(<span style="color: #0000ff">int</span> id)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            var people = PeopleDataService.PeopleList.First(p =&gt; p.Id == id);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">return</span> View(people);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">//</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">// GET: /People/Create</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// 创建</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> ActionResult Create()</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            var people = <span style="color: #0000ff">new</span> People();</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">return</span> View(people);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">//</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">// POST: /People/Create</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// 保存创建内容</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;param name=&quot;people&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        [AcceptVerbs(HttpVerbs.Post)]</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> ActionResult Create([Bind(Include = <span style="color: #006080">&quot;Age,Name&quot;</span>)] People people)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">try</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #008000">//得到当前数据服务内ID最大值并生成当前记录的ID</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                people.Id = PeopleDataService.PeopleList.Max(p =&gt; p.Id) + 1;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #008000">//Valid</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                GetValidation(people);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">if</span> (!ModelState.IsValid)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> Exception();</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">else</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    PeopleDataService.PeopleList.Add(people);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #0000ff">return</span> RedirectToAction(<span style="color: #006080">&quot;Index&quot;</span>);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">catch</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">return</span> View(people);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">//</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">// GET: /People/Edit/5</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// 编辑某条记录</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;param name=&quot;id&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> ActionResult Edit(<span style="color: #0000ff">int</span> id)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            var people = PeopleDataService.PeopleList.First(p =&gt; p.Id == id);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">return</span> View(people);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">//</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">// POST: /People/Edit/5</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// 保存内容</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;param name=&quot;id&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;param name=&quot;people&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        [AcceptVerbs(HttpVerbs.Post)]</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">public</span> ActionResult Edit(<span style="color: #0000ff">int</span> id, [Bind(Include = <span style="color: #006080">&quot;Age,Name&quot;</span>)] People people)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            var oPeople = PeopleDataService.PeopleList.First(p =&gt; p.Id == id);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">try</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">if</span> (oPeople != <span style="color: #0000ff">null</span>)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    oPeople.Age = people.Age;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    oPeople.Name = people.Name;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #008000">//Valid</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                GetValidation(oPeople);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">if</span> (!ModelState.IsValid)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #0000ff">throw</span> <span style="color: #0000ff">new</span> Exception();</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">else</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #0000ff">return</span> RedirectToAction(<span style="color: #006080">&quot;Index&quot;</span>);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">catch</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">return</span> View(oPeople);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// 数据验证之用</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #008000">/// &lt;param name=&quot;oPeople&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">private</span> <span style="color: #0000ff">void</span> GetValidation(People oPeople)</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">//if (oPeople.Age &lt; 10)</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">//    ModelState.AddModelError(&quot;Age&quot;, &quot;Age 必须大于等于10...&quot;);</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">if</span> (<span style="color: #0000ff">string</span>.IsNullOrEmpty(oPeople.Name))</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                ModelState.AddModelError(<span style="color: #006080">&quot;Name&quot;</span>, <span style="color: #006080">&quot;Name 不能为空...&quot;</span>);</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    }</pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">}</pre>
  </div>
</div>

<p>控制器代码中使用了一个叫&quot;MvcPaging&quot;的分页类库, 这个可能是现在碰到的最优美的ASP.NET MVC上分页类库. ASP.NET MVC 中错误处理使用ModelState.AddModelError方法来设置, 调用ModelState.IsValid来验证验证通过与否. 通过设置某一个Action的AcceptVerbs属性来使得其可以接受特定Verbs的外部数据, 这个功能比CTP版中的实现不知道好了多少倍(CTP版中搞得莫名其妙), 这个功能也是实现REST风格URL的完备解决. 通过设置Action参数为一自定义的类来接受前台视图内的复杂数据, 并设置[Bind]属性来设置那些数据可以接受. </p>

<p>控制器代码写好后, VS IDE内使用右键&quot;Add View&quot;方式来快速生成视图部分, 期间注意设置强类型视图就可以了. Index内添加分页部分功能:</p>

<div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px">
  <div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">
    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">&lt;</span><span style="color: #800000">div</span> <span style="color: #ff0000">class</span><span style="color: #0000ff">=&quot;pager&quot;</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="background-color: #ffff00">&lt;%</span><pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060">   1:</span> = Html.Pager(ViewData.Model.PageSize, ViewData.Model.PageNumber, ViewData.Model.TotalItemCount) </pre><span style="background-color: #ffff00">%&gt;</span></pre>

    <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">div</span><span style="color: #0000ff">&gt;</span></pre>
  </div>
</div>

<p>&#160;</p>

<p>代码下载:<iframe style="border-bottom: #dde5e9 1px solid; border-left: #dde5e9 1px solid; padding-bottom: 0px; background-color: #ffffff; margin: 3px; padding-left: 0px; width: 240px; padding-right: 0px; height: 66px; border-top: #dde5e9 1px solid; border-right: #dde5e9 1px solid; padding-top: 0px" marginheight="0" src="http://cid-e63ac91b5bfc8e30.skydrive.live.com/embedrowdetail.aspx/Public/MvcApplicationCRUD.zip" frameborder="0" marginwidth="0" scrolling="no"></iframe></p>

<p>&#160;</p>

<blockquote>
  <p>春暖花开的季节.</p>

  <p>TUPUNCO</p>

  <p>2009.03.23</p>

  <p>好运每一天.</p></blockquote>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/473.htm</link>
			<title><![CDATA[[原创]C#中使用反射]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[随笔]]></category>
			<pubDate>Mon,09 Mar 2009 09:02:28 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=473</guid>
		<description><![CDATA[<p>过了年到现在忙了起来, 不像年前, 可以整月的闲着, 不过闲着也有好处, 学习了好多东西. 过了年的项目中多次用到了 .Net 反射机制, 使得其间巧妙地解决了很多问题. 总结一下使用到的地方.</p>  <h4>1.使用工厂模式来抽象数据连接层之用(PetShop模式的三层结构内的使用方式).</h4>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> System.Reflection.Assembly assembly = Assembly.LoadFile(<span style="color: #006080">&quot;Assembly Path&quot;</span>);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> IXXXXXDAL dal = (IXXXXXDAL)assembly.CreateInstance(<span style="color: #006080">&quot;Namespace.DAL.XXXXXDAL&quot;</span>);</pre>
  </div>
</div>

<p></p>

<h4>2.使用 &quot;System.Activator.CreateInstance()&quot; 方式来创建对象.</h4>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px">
  <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #008000">//</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> <span style="color: #008000">// 摘要:</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> <span style="color: #008000">//     创建类型的一个实例，该类型由指定的泛型类型参数指定。</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span> <span style="color: #008000">//</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span> <span style="color: #008000">// 类型参数:</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span> <span style="color: #008000">//   T:</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span> <span style="color: #008000">//     要创建的类型。</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span> <span style="color: #008000">//</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span> <span style="color: #008000">// 返回结果:</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span> <span style="color: #008000">//     对新创建对象的引用。</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> T CreateInstance&lt;T&gt;();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> <span style="color: #008000">//</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span> <span style="color: #008000">// 摘要:</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> <span style="color: #008000">//     使用指定类型的默认构造函数来创建该类型的实例。</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span> <span style="color: #008000">//</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span> <span style="color: #008000">// 参数:</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span> <span style="color: #008000">//   type:</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span> <span style="color: #008000">//     要创建的对象的类型。</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span> <span style="color: #008000">//</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span> <span style="color: #008000">// 返回结果:</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span> <span style="color: #008000">//     对新创建对象的引用。</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">object</span> CreateInstance(Type type);</pre>
  </div>
</div>

<h4>3.显示某对象的子级属性值.</h4>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px">
  <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">string</span> DisplayPropertyInfo(<span style="color: #0000ff">object</span> obj)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     StringBuilder sb = <span style="color: #0000ff">new</span> StringBuilder();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     Type type = obj.GetType();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     sb.AppendFormat(<span style="color: #006080">&quot;[{0}]\r\n&quot;</span>,obj);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     <span style="color: #0000ff">foreach</span> (var item <span style="color: #0000ff">in</span> type.GetProperties())</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>         sb.AppendFormat(<span style="color: #006080">&quot;\t[{0}:{1}]\r\n&quot;</span>, item.Name,</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>             item.GetValue(obj, <span style="color: #0000ff">null</span>));</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>     <span style="color: #0000ff">return</span> sb.ToString();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span> }</pre>
  </div>
</div>

<h4>4.转换一个DataTable类型的对象成为一个实体集合(Table的列与实体类的属性是一一对应的).</h4>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px">
  <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #008000">/// 数据服务基类对象</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">abstract</span> <span style="color: #0000ff">class</span> DataServiceBase</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">{</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #cc6633">#region</span> DB 处理</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 执行SQL字符串返回一个DataTable</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;sql&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">protected</span> DataTable ExecuteSQL(<span style="color: #0000ff">string</span> sql)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #008000">//*****返回一个DataTable****</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">       <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #cc6633">#endregion</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #cc6633">#region</span> Tabel 类型转换相关</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 转化Table成一个相对应的实体类集合</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;table&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">protected</span> List&lt;T&gt; ConvertDataTableToEntityCollections&lt;T&gt;(DataTable table)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">where</span> T : <span style="color: #0000ff">class</span>, <span style="color: #0000ff">new</span>()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">if</span> (table != <span style="color: #0000ff">null</span>)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            PropertyInfo[] pInfos = GetTypePropertyInfo(<span style="color: #0000ff">typeof</span>(T));</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            List&lt;T&gt; list = <span style="color: #0000ff">new</span> List&lt;T&gt;(table.Rows.Count);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">foreach</span> (DataRow row <span style="color: #0000ff">in</span> table.Rows)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                T t = <span style="color: #0000ff">new</span> T();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                <span style="color: #0000ff">foreach</span> (var pInfo <span style="color: #0000ff">in</span> pInfos)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                    <span style="color: #0000ff">if</span> (table.Columns.Contains(pInfo.Name))</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                        <span style="color: #008000">//HACK: 对象转换成指定的类型使用 Convert.ChangeType</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                        <span style="color: #008000">// Convert.ChangeType(row[pInfo.Name], pInfo.PropertyType);</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                        <span style="color: #0000ff">try</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                        {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                            pInfo.SetValue(t, ChangeType(row[pInfo.Name], pInfo.PropertyType), <span style="color: #0000ff">null</span>);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                        }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                        <span style="color: #0000ff">catch</span>(Exception ex){</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                            <span style="color: #0000ff">throw</span> ex;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                        }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                list.Add(t);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">return</span> list;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 得到指定SQL执行的结果并返回结果的实体类集合对象</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 本方法综合了 ConvertDataTableToEntityCollections/ExecuteSQL 方法</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;sql&quot;&gt;待执行的SQL&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">protected</span> List&lt;T&gt; GetEntityConllectionsFromSQL&lt;T&gt;(<span style="color: #0000ff">string</span> sql)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">where</span> T : <span style="color: #0000ff">class</span>, <span style="color: #0000ff">new</span>()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">if</span> (<span style="color: #0000ff">string</span>.IsNullOrEmpty(sql))</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">else</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">return</span> ConvertDataTableToEntityCollections&lt;T&gt;(ExecuteSQL(sql));</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 得到指定类型公开的属性</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;type&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">private</span> PropertyInfo[] GetTypePropertyInfo(Type type)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        PropertyInfo[] infos = <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #008000">//锁定防止 多次 ADD 进缓存</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">lock</span> (_PROPERTYINFO_READ_LOCK)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            _PropertyInfoCache.TryGetValue(type, <span style="color: #0000ff">out</span> infos);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">if</span> (infos == <span style="color: #0000ff">null</span>)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                infos = type.GetProperties();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                _PropertyInfoCache.Add(type, infos);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">return</span> infos;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 类型转换</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// FROM: http://www.cnblogs.com/cnee5/archive/2006/05/21/405403.html</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;value&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;conversionType&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">public</span> <span style="color: #0000ff">object</span> ChangeType(<span style="color: #0000ff">object</span> <span style="color: #0000ff">value</span>, Type conversionType)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #008000">//INFO 对DBNull类型特殊处理</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">if</span> (Convert.IsDBNull(<span style="color: #0000ff">value</span>))</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #008000">//非可空类型的值类型处理</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">if</span> (!(conversionType.IsGenericType &amp;&amp;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                conversionType.GetGenericTypeDefinition().Equals(<span style="color: #0000ff">typeof</span>(Nullable&lt;&gt;))))</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                <span style="color: #0000ff">return</span> Activator.CreateInstance(conversionType);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">else</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #008000">//可空类型类型处理</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">if</span> (conversionType.IsGenericType &amp;&amp;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                conversionType.GetGenericTypeDefinition().Equals(<span style="color: #0000ff">typeof</span>(Nullable&lt;&gt;)))</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">if</span> (<span style="color: #0000ff">value</span> == <span style="color: #0000ff">null</span>)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            System.ComponentModel.NullableConverter nullableConverter</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                = <span style="color: #0000ff">new</span> System.ComponentModel.NullableConverter(conversionType);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">&#160;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            conversionType = nullableConverter.UnderlyingType;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">&#160;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">return</span> Convert.ChangeType(<span style="color: #0000ff">value</span>, conversionType);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">private</span> <span style="color: #0000ff">object</span> _PROPERTYINFO_READ_LOCK = <span style="color: #0000ff">new</span> <span style="color: #0000ff">object</span>();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 实体类属性缓存</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> Dictionary&lt;Type, PropertyInfo[]&gt; _PropertyInfoCache = <span style="color: #0000ff">new</span> Dictionary&lt;Type, PropertyInfo[]&gt;();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #cc6633">#endregion</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
  </div>
</div>

<p>使用GetEntityConllectionsFromSQL&lt;T&gt;(string sql)方法直接执行一个返回DataTable的ExecuteSQL(sql)方法来快捷完成转换. 在不用ORM框架的情况下就是简单的取得数据变成实体对象集合时很方便, 当然前提是不使用强类型数据集.</p>

<p></p>

<p></p>

<h4>5.转换WebServices生成的实体数据到三层结构已经定义好的实体数据.</h4>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; max-height: 200px">
  <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> DataServiceBase</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">{</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #cc6633">#region</span> 类型转换之用</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 转换一个WebServices Entity</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 此类实体的特点 对于目标实体&quot;属性字段&quot;和现在的实体&quot;属性字段&quot;名称一致,</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 但对于列表实体会是数组保存</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;typeparam name=&quot;TTarget&quot;&gt;&lt;/typeparam&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;typeparam name=&quot;TSource&quot;&gt;&lt;/typeparam&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;entity&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">protected</span> TTarget ConvertWebServiceEntity&lt;TTarget, TSource&gt;(TSource entity)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">where</span> TTarget : <span style="color: #0000ff">class</span>, <span style="color: #0000ff">new</span>()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">where</span> TSource : <span style="color: #0000ff">class</span>, <span style="color: #0000ff">new</span>()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">return</span> (TTarget)ConvertWebServiceEntity(<span style="color: #0000ff">typeof</span>(TTarget), <span style="color: #0000ff">typeof</span>(TSource), (<span style="color: #0000ff">object</span>)entity);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 转换一个WebServices Entity</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 此类实体的特点 对于目标实体&quot;属性字段&quot;和现在的实体&quot;属性字段&quot;名称一致,</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 但对于列表实体会是数组保存</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;tType&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;sType&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;sEntity&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">object</span> ConvertWebServiceEntity(Type tType, Type sType, <span style="color: #0000ff">object</span> sEntity)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">if</span> (sEntity != <span style="color: #0000ff">null</span>)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">object</span> t = Activator.CreateInstance(tType);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            PropertyInfo[] pTInfos = GetTypePropertyInfo(tType);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            PropertyInfo[] pSInfos = GetTypePropertyInfo(sType);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">int</span> i = 0;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">foreach</span> (var item <span style="color: #0000ff">in</span> pSInfos)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                <span style="color: #0000ff">if</span> (!item.PropertyType.IsArray)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                    pTInfos[i].SetValue(t, item.GetValue(sEntity, <span style="color: #0000ff">null</span>), <span style="color: #0000ff">null</span>);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                <span style="color: #0000ff">else</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                    <span style="color: #008000">//tgType 肯定为泛型</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                    <span style="color: #008000">//taType 肯定为 数组类型</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                    Type tgType = pTInfos[i].PropertyType.GetGenericArguments()[0];</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                    Type taType = item.PropertyType.GetElementType();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                    <span style="color: #0000ff">object</span> tList = ConverWebServiceEntityCollections(tgType, taType, (<span style="color: #0000ff">object</span>[])item.GetValue(sEntity, <span style="color: #0000ff">null</span>));</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                    pTInfos[i].SetValue(t, tList, <span style="color: #0000ff">null</span>);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                i++;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            <span style="color: #0000ff">return</span> t;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 转换一个WebServices Entity</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 此类实体的特点 对于目标实体&quot;属性字段&quot;和现在的实体&quot;属性字段&quot;名称一致,</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 但对于列表实体会是数组保存</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;tTarget&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;tSource&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;sCollections&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">protected</span> <span style="color: #0000ff">object</span> ConverWebServiceEntityCollections(</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        Type tTarget, Type tSource,</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">object</span>[] sCollections)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #008000">//HACK 创建一个目标类型的泛型列表</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        Type gListType = <span style="color: #0000ff">typeof</span>(List&lt;&gt;).MakeGenericType(<span style="color: #0000ff">new</span> Type[] { tTarget });</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">object</span> tgListObj = Activator.CreateInstance(gListType);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        MethodInfo tgAddMi = gListType.GetMethod(<span style="color: #006080">&quot;Add&quot;</span>);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">foreach</span> (var item <span style="color: #0000ff">in</span> sCollections)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            tgAddMi.Invoke(tgListObj, <span style="color: #0000ff">new</span> <span style="color: #0000ff">object</span>[] { ConvertWebServiceEntity(tTarget, tSource, item) });</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">return</span> tgListObj;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 从列表到列表</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;typeparam name=&quot;TTarget&quot;&gt;&lt;/typeparam&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;typeparam name=&quot;TSource&quot;&gt;&lt;/typeparam&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;collections&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">protected</span> List&lt;TTarget&gt; ConverWebServiceEntityCollections&lt;TTarget, TSource&gt;(IEnumerable&lt;TSource&gt; collections)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">where</span> TTarget : <span style="color: #0000ff">class</span>, <span style="color: #0000ff">new</span>()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">where</span> TSource : <span style="color: #0000ff">class</span>, <span style="color: #0000ff">new</span>()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        List&lt;TTarget&gt; tList = <span style="color: #0000ff">new</span> List&lt;TTarget&gt;();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">foreach</span> (var item <span style="color: #0000ff">in</span> collections)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            tList.Add(ConvertWebServiceEntity&lt;TTarget, TSource&gt;(item));</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">return</span> tList;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// 得到指定类型公开的属性</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;param name=&quot;type&quot;&gt;&lt;/param&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// &lt;returns&gt;&lt;/returns&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #0000ff">private</span> PropertyInfo[] GetTypePropertyInfo(Type type)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        PropertyInfo[] infos = <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #008000">//锁定防止 多次 ADD 进缓存</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        <span style="color: #0000ff">lock</span> (_PROPERTYINFO_READ_LOCK)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            _PropertyInfoCache.TryGetValue(type, <span style="color: #0000ff">out</span> infos);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            <span style="color: #0000ff">if</span> (infos == <span style="color: #0000ff">null</span>)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">            {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">                infos = type.GetProperties();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">                _PropertyInfoCache.Add(type, infos);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">            }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">        }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">        <span style="color: #0000ff">return</span> infos;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">private</span> <span style="color: #0000ff">object</span> _PROPERTYINFO_READ_LOCK = <span style="color: #0000ff">new</span> <span style="color: #0000ff">object</span>();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #008000">/// 实体类属性缓存</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #008000">/// &lt;/summary&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">    <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> Dictionary&lt;Type, PropertyInfo[]&gt; _PropertyInfoCache = <span style="color: #0000ff">new</span> Dictionary&lt;Type, PropertyInfo[]&gt;();</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">    <span style="color: #cc6633">#endregion</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">}</pre>
  </div>
</div>

<p>Web Services 生成实体数据会把List类型的数据转换成数组, 也不知道自己写这个东西是不是正确, 反正是可以使用. 另外NBear4中提供一个ObjectConvertor的东西, 很好用可以支持不同类型之间的转换, 并且还可以自定义转换映射关系.</p>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/472.htm</link>
			<title><![CDATA[[原创]小型新闻门户网站建设经验说法]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[原创]]></category>
			<pubDate>Mon,09 Mar 2009 08:59:52 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=472</guid>
		<description><![CDATA[<p>去年十一前后, 公司接到一个事业单位网站的单子, 规划编码工作由我来完成, 单子完成后写了本文的提纲, 但由于气候天冷的缘故没有写完, 今天正好天气回暖了, 一个多月的阴雨天也结束了, 来把提纲的内容整理一下.</p>  <p>网站的需求是客户提供的, 其实就是列了一个网站的大致导航栏目划分, 根据客户要求, 站点需要 <a href="http://www.php.net/" target="_blank">PHP</a> 来实现, 因为客户的主机用的是其管理部门的公共服务器, 服务器使用 Apache + <a href="http://www.mysql.com/" target="_blank">MySQL</a> 作为Web平台. 为了快速的构建站点, 使用了国内开源免费的 CMS 系统来完成, 名称为&lt;<a title="DreamArticle" href="http://www.idreamsoft.cn" target="_blank">DreamArticle</a>&gt;, 此 CMS 系统授权并不像&quot;织梦CMS&quot;或&quot;帝国CMS&quot;一样对政府事业单位需要收费, 而是在保留版权声明的前提下对所有用户都免费, 一个不错的选择, 功能也基本满足客户需要, 但还是开发了一部分新的功能, 并且修改了一部分系统的 BUG. 作为对此 CMS 系统的支持, 向作者提供了BUG 列表和大部分的二次开发代码, 之后作者在新得版本内对 BUG 做了修改. 选择 CMS 系统的时候对国外多个开源 CMS 系统做了测试, 但可以快速达到客户要求, 并且在使用简便性上占优势的几乎为零, 可能也是自己使用理解上的欠缺, 要不就是对 CMS 系统理解有限, 国内多个大型成熟的 CMS 系统的调查发现, 大部分使用都不错, 符合国情, 但授权方面是一个问题, 毕竟大家都要吃饭. </p>  <p>站点美工设计完成的稿经过客户评价后, 转成了 WEB 页面, 页面全部使用了DIV+CSS方式来布局, 期间遇到了好多问题, 下面有路罗列, 但还是从需求方面来说.</p>  <p>&lt;小型新闻门户网站&gt;定义: </p>  <p>需求罗列:</p>  <ol>   <li>首页      <br />这个肯定是不可或缺的, 在 2000 年左右, 有些站点喜欢搞一个 Flash 引导页, 之后再由用户点击转到此页, 对于一个新闻类的站点不适合. 首页一般存在的东西为站点某些栏目, 站点内的最新文章, 某些公告通知(实际就是某篇文章直接内容显示), 可能还有些调查问卷之类的东西. </li>    <li>栏目(支持大小类, 大小类文章列表, 支持图片栏目, 分页)      <br />实际上栏目划分支持&quot;无限级分类&quot;才是正确的说法, 有子级栏目的为大类, 没有子级栏目的为小类或叫终极类. 分类可以定义为&quot;文章栏目&quot;或&quot;图片栏目&quot;, 甚至&quot;文章图片&quot;混合在一个栏目. 对于每个栏目支持自定义其模版页, 保持不同页面, 栏目的变化. 对于大多数的CMS系统设计来说一篇文章只属于一个栏目, 但国外的多数CMS系统, 文章可以属于多个栏目, 系统对栏目的定义已经模糊. </li>    <li>专题(支持专题子组, 文章来自于本站点的所有可能文章)      <br />专题栏目是一个特别的东西. 专题内并不添加文章, 只是站点内的某些文章属于某些专题, 一篇文章可以属于多个专题, 有点像一稿多投. 专题页应该有专题首页, 专题列表页, 而专题内容页实际都是文章的内容页. </li>    <li>单独页面(有别于内容显示页面, 不过两项可以合并)      <br />对于一个站点肯定有这样的需求:&quot;关于&quot;,&quot;帮助&quot;之类的文章, 而这些文章又不属于某一栏目, 所以提供这个功能, 实际把某一个栏目来作为这些内容的栏目也可以, 只是设计页面的时候固定的连接成本页. </li>    <li>文章内容显示页面(支持图片显示, 分页)      <br />不管是普通的文章还是图片都需要显示其内容, 对于长篇内容, 分页是一个不错的用户体验. 图片支持分张播放也是不错的体验. </li>    <li>留言簿部分      <br />中国人的小站点, 尤其是&quot;企业/政府/事业/教育&quot;单位的站点都喜欢搞一个留言簿, 不管这个留言簿是否有人维护, 但都会放着这个东西的, 好像很喜欢大家给自己留点东西, 实际上这个地方常常是垃圾广告的出没地. &quot;政府/事业&quot;单位这些年对于这个留言簿是有点重视, 虽然留言不是留了就可以看到, 需要管理员审核, 但还是有专门人员定期审核回复. </li>    <li>投票系统      <br />不管有用没有用, 投票/问卷功能有些人很喜欢看到他出现在自己的站点上. 可能这个投票内容一两年内容都没有换过, 也没有人管到底投了多少票. 问卷似乎是定期开发, 政府/事业单位用到比较多, 到底这个问卷能起到多大的作用另当别论. 投票或问卷直接嵌入到某篇文章内也是一个不错的功能, 对于大型新闻门户站点, 这个功能经常用到, 并且问卷或调查的结果也很有用处. </li>    <li>全站搜索功能(至此对指定栏目搜索)      <br />站内的文章, 图片都可以搜索到, 一般是直接使用模糊查询从数据库内搜索标题或内容. 对于查询可能是一个用户常用到功能的站点, 直接模糊查询数据库, 站点的访问量也不低(高低就说成持续有人访问站点)最后的结果是数据库服务器不堪重负, 成为整一个站点性能的瓶颈. 例如一个房屋出租的站点或一个商品交易的网站, 用户喜欢用查询的方式来找到自己的目标数据, 往往需要使用专门&quot;搜索引擎&quot;来完成此功能. 这里说到的&quot;搜索引擎&quot;并不是平时说的谷歌或百度, 当然站点的搜索功能托管给谷歌来完成也不错, 但对于前面提到的房屋出租网站来说, 托管给谷歌来完成搜索, 用户体验会很低. 使用例如lucene之类的搜索引擎, 通过对需要搜索的字段建立索引, 来做这个搜索功能, 可以解决搜索的数据库瓶颈. 对于一个使用 SQL Server 数据库来说, 据说使用全文搜索功能来完成也是可选项. </li>    <li>在线投稿      <br />事业单位各个部门规定定期需要向站点提交文章是有可能的, 不用登陆后台直接跟留言簿方式一样来发布文章, 管理员在某个固定时间审核文章. </li>    <li>后台管理员分级      <br />一个站点多个角色管理, 各个角色包含不同的用户, 权限对于各个角色不同, 一个很常规的&quot;基于角色的访问控制BRAC&quot;功能, 但要把这个功能设计好了不容易. </li> </ol>  <p>辅助功能罗列:</p>  <ol>   <li>RSS 提供      <br />新闻订阅功能, 在HTML页面内增加application/rss+xml类型的LINK来标记站点包含的RSS连接. </li>    <li>XML-RPC 提供      <br />可以通过流行的BLOG客户端来发布文章, 方便图文混排的文章的发布, 可以在Word内编辑好的文章, 直接拷贝到客户端软件内发布.&#160; 对于一个高级一点的新闻站点大概会提供一个类似于WebService的借口, 通过专门的客户端来发布, 但不确定自己的推测是否正确. </li>    <li>SEO 优化      <br />搜索引擎优化也不是太懂, 自己的理解大概就是REST风格的URL. 一个友好的URL对用户是一个不错的体验, 可以知道当前页面的元信息. 例如文章的分类, 发布时间, 文章标题等信息. </li> </ol>  <p>前台注意问题:</p>  <ol>   <li>DIV+CSS布局.&#160; 增加下载速度, 解析速度, 浏览器兼容. </li>    <li>字体大小问题 . 之前一直使用的是 12px或者9pt 的字体, 但 14px视乎才合适, 因为现在的宽屏/小尺寸/大分辨率的显示器增多. </li>    <li>CSS使用注意      <ol>       <li>不要设置对某一元素的全局CSS. 容易造成内容显示页面内的内容从后台的HTML编辑器设置的内容变形.&#160; 建议通过对元素通过class或id来设置CSS. </li>        <li>行高. 150%或者160%行高, 段前段后也需要设置. </li>        <li>内间距, 外间距问题. 要知道对于HTML或者XTML不同浏览器解析有很大差异. IE6和IE7内还有莫名其妙的解析BUG. </li>        <li>滚动条问题. 在XTML内在设置了OverFlow样式后, 只有设置了高度才会只显示Y滚动条, X滚动条不显示. </li>        <li>表单样式          <ol>           <li>文本框 在不同浏览器内对其HOVER的解析不一样, 所以鼠标经过效果还需要通过Javascript来设置. </li>            <li>下拉列表框 箭头无法通过CSS来设置, 所以建议不要对其设置边框背景色之类的样式, 最多设置字体大小. </li>            <li>复选框/单选框 与文本框一样这个域是以INPUT开始的标签, 所以样式设置需要通过CLASS或者ID来. </li>            <li>文本域 也存在与&quot;下拉列表框&quot;类似的问题, 滚动条外观没有标准的CSS来控制. IE下有不兼容的设置方法. </li>            <li>对于表单元素使用P来布局还是使用Table来布局. </li>         </ol>       </li>        <li>浮动元素与背景图片设置在IE6内的BUG. 浮动之后需要 Clear, 在IE6内存在一个浮动与背景图片之间的BUG. </li>        <li>IE6内的双倍间距BUG </li>     </ol>   </li>    <li>页面打印.&#160; 打印的外观应该通过CSS来控制打印的样式. 通过设置LINK 的 media 属性为 print, 并且在CSS内设置页面上需要隐藏的元素, 那些元素显示, 哪些元素的边框间距颜色等问题. 之前自己总是弱智的用Javascript来控制. </li>    <li>JS框架的应用. JQuery为首选, 插件丰富, 应用灵活, 效率高, 绝对轻量级. 浏览器兼容的事件操作DOM操作/UI插件/表单验证插件/表格排序插件. </li>    <li>段落样式. 行间距, 首行缩进, 段前段后设置. </li>    <li>TAB 的使用. 重复内容分标签显示使用TAB来显示可以在不增加页面长度的情况下, 显示更多的内容. </li>    <li>Table 元素的使用. 页面布局是不建议使用表格的, 因为表格只有全部加载完毕后才渲染出来. 对于多层嵌套表格是最大的忌讳, 在IE浏览器上会把人给耗死. 表格善用theader/th/tbody/tfooter, 可以很方便CSS来控制样式. </li>    <li>图形验证码的使用. 为了减少垃圾信息, 用户登录口的安全, 使用验证码是一个安全划算的设计, 但容易造成滥用(不该有验证码的地方使用), 并且不正确的使用验证码(伪图片验证码[DVBBS老版本使用一个好像类似于C语言写的验证码]/机器机器容易识别的验证码), 除了不能增加安全性, 还会使用户体验降低. </li> </ol>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/471.htm</link>
			<title><![CDATA[[转载翻译]ASP.NET MVC RC1学习向导]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[网摘]]></category>
			<pubDate>Tue,17 Feb 2009 09:46:33 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=471</guid>
		<description><![CDATA[<p>ASP.NET RC1 在春节期间发布(一月末), 按 Scott Guthrie 博客的说法ASP.NET MVC 只有一个RC版, 正式版的将在二月份发布, 通常RC版的软件已经相当的接近正式版, 所以可以使用在项目开发上, 也可以说 ASP.NET MVC 已经定型了, 正式版只可能有某些Bug修复和细微的改进. 我从J2EE上的Struts, 到国人的EasyJf, 从 ROR 到 CakePHP , 看过好多的 MVC 框架的使用方法, 看到了很多, 但没有真正明白这些东西为啥要这么开发, 这么使用, 为什么非要 Controller 加很多Action. 直到后来看到 Castle.MonoRail, 发现使用方法好眼熟, 才想起ROR中的一个类一个Controller, 一个方法是一个Action的规律, 也是自己对Ruby语言不熟悉, 也没有好好的看看MVC模式的说明, 也没有搞明白MVC各部分的关系, 才造成自己长时间在MVC方面没有具体的进步. 现在才明白规律就是ROR是基本结构的模式, 才有的EasyJf/CakePHP/MonoRail..., 还有国内的几个PHP MVC 框架, 设计大同小异, 虽然内部设计大有不同, 但使用方法, 基本类似.</p>  <p>后来有微软发布自己MVC框架的消息, 在经过一天的&quot;放鸽子&quot;之后, 第二天总算见到了技术预览版(CTP)的ASP.NET MVC, 看介绍发现就是ROR的开发结构方式, 一个类一个Controller, 一个控制器可以包含多个Action, Controller/Action拦截器, 路由器一个都没有少, 只是模型部分没有单独实现, 不过 .NET 上纷繁的第三方ORM框架和微软的LINQ to SQL/ADO.NET 实体框架功能已经相当强大. 经过五个预览版本的测试, 期间经过了多次的大的代码重构, ASP.NET MVC不断的优化, 后来更是直接集成JQuery框架, 再到Beta版, ASP.NET MVC 设计已经相当完美. 元旦前后就有消息说是一月份发布RC版, 但直到一月三十号才发布, 还真是一月份发布, 不过自己看到已经到春节后了. </p>  <p>下面是一篇文章的翻译, 文章给出了一个学习ASP.NET MVC的渐进文章列表, 这里试着翻译一下. 此作者的博客有一个&lt;ASP.NET MVC 技巧集锦&gt;的系列文章, 自己也在博客推荐过. 这篇文章过年上班的时候就看到了,一致在Live Writer内放着也没有翻译完,今天晚上翻译绝大部分,正确与否也没有办法,毕竟英语本来就菜.</p>  <p>---------------------------</p>  <p>原文名称: <a href="http://stephenwalther.com/blog/archive/2009/01/27/a-guide-to-learning-asp.net-mvc-release-candidate-1.aspx">A Guide to Learning ASP.NET MVC Release Candidate 1</a></p>  <p>原文地址: <a title="http://stephenwalther.com/blog/archive/2009/01/27/a-guide-to-learning-asp.net-mvc-release-candidate-1.aspx" href="http://stephenwalther.com/blog/archive/2009/01/27/a-guide-to-learning-asp.net-mvc-release-candidate-1.aspx">http://stephenwalther.com/blog/archive/2009/01/27/a-guide-to-learning-asp.net-mvc-release-candidate-1.aspx</a></p> ASP.NET RC版已经发布可以下载了, 怎样去学习使用它开发应用程序呢? 这里有一个关于学习ASP.NET MVC RC1的资源向导.   <p>首先, 读一读 Scott Guthrie 和 Phil Haack 博客上关于这个版本 ASP.NET MVC 框架新特征的帖子:</p>  <p>· <a href="http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx">http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx</a></p>  <p>· <a href="http://haacked.com/archive/2009/01/27/aspnetmvc-release-candidate.aspx">http://haacked.com/archive/2009/01/27/aspnetmvc-release-candidate.aspx</a></p>  <p>接下来, 到 <a href="http://www.asp.net/mvc">http://www.asp.net/mvc</a> 网站(ASP.NET MVC 官网), 读一读 14 篇新的教程:</p>  <p><a href="http://www.asp.net/learn/mvc/tutorial-01-vb.aspx">Creating a Movie Database Application</a> 创建电影数据库应用程序</p>  <p>Stephen Walther builds an entire ASP.NET MVC application from start to finish. This tutorial is a great introduction for people who are new to the ASP.NET MVC Framework and who want to get a sense of the process of building an ASP.NET MVC application. Stephen Walther从开始到结束构建一个完整的ASP.NET MVC应用程序.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-02-vb.aspx">Understanding Models, Views, and Controllers</a> 理解模型,视图,控制器</p>  <p>Stephen Walther介绍ASP.NET MVC应用程序中模型,视图,控制器之间的不同,防止混淆.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-21-vb.aspx">ASP.NET MVC Overview</a> ASP.NET MVC 概述</p>  <p>学习ASP.NET MVC 应用程序与ASP.NET Web 表单应用程序的不同.学习当构建一个ASP.NET MVC应用时怎样决定(怎样在MVC和WebForm两者之间取舍?).</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-22-vb.aspx">Understanding the ASP.NET MVC Execution Process</a> 理解ASP.NET MVC 执行处理</p>  <p>学习ASP.NET是怎样一步步的处理一个浏览器请求.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-08-vb.aspx">Using ASP.NET MVC with Different Versions of IIS</a> 不同版本IIS上使用ASP.NET MVC</p>  <p>教程中学习怎样在不同版本的IIS中使用ASP.NET MVC, URL路由器. 学习IIS7.0(经典模式)/IIS 6.0/以及更低版本中使用ASP.NET MVC的不同策略方法.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-12-vb.aspx">Creating Page Layouts with View Master Pages</a> 使用视图母版页创建页面布局</p>  <p>通过便捷的视图母版页,可以在ASP.NETMVC应用程序中创建一个通用的布局页. 教程中Stephen Walther讲解了视图母版页,以及怎样创建一个两列的模板布局页面.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-13-vb.aspx">Passing Data to View Master Pages</a> 向视图母版页传输数据</p>  <p>教程中, Stephen Walther 讲解怎样传送数据库数据到视图母版页. 举例说明在ASP.NET MVC 应用程序中怎样创建一个ApplicationController控制器, 其可以修改每一个控制器动作的视图返回值(View Data Returned).</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-14-vb.aspx">Understanding Action Filters</a> 理解动作过滤器</p>  <p>本篇教程带你进入动作过滤器的世界. 学习动作过滤器是怎样工作的,怎样实现一个自定义的动作过滤器. 教程中实现一个可以记录控制器动作和动作结果处理步骤日志,并将日志信息输出到Visual Stadio输出窗口的自定义过滤器.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-15-vb.aspx">Improving Performance with Output Caching</a> 使用输出缓存改善性能</p>  <p>In this tutorial, you learn how you can dramatically improve the performance of your ASP.NET MVC web applications by taking advantage of output caching. You learn how to cache the result returned from a controller action so that the same content does not need to be created each and every time a new user invokes the action.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-16-vb.aspx">Creating Model Classes with the Entity Framework</a> 使用实体框架创建模型类</p>  <p>在这篇教程中,将要学习微软实体框架(Microsoft Entity Framework)配合ASP.NET MVC使用,学习怎样使用实体向导(Entity Wizard)创建一个ADO.NET实体数据模型(ADO.NET Entity Data Model). 教程中,构建了一个使用实体框架怎样查询/添加/更新/删除数据库数据的Web应用程序.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-17-vb.aspx">Authenticating Users with Forms Authentication</a> 使用表单验证验证用户</p>  <p>学习在MVC程序中怎样使用[Authorize]属性来保护部分页面.学习使用站点管理工具(Web Site Administration Tool)创建和管理用户和角色(ASP.NET 2.0集成).还要学习怎样配置存储用户帐户和角色信息.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-18-vb.aspx">Authenticating Users with Windows Authentication</a> 使用Windows验证验证用户</p>  <p>学习在MVC应用程序上下文中(Context)使用Windows验证.学习怎样在你的应用程序中配置文件中启用Windows验证,以及在IIS中怎样配置验证.末了,学习怎样使用[Authorize]属性限制某些Windows用户和用户组对控制器(Controller)动作(Action)的访问.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-19-vb.aspx">Adding Dynamic Content to a Cached Page</a> 向缓存页面添加动态内容</p>  <p>Learn how to mix dynamic and cached content in the same page. Post-cache substitution enables you to display dynamic content, such as banner advertisements or news items, within a page that has been output cached.学习怎样在同一个页面上混合使用动态和缓存的内容.</p>  <p>· <a href="http://www.asp.net/learn/mvc/tutorial-20-vb.aspx">Providing Website Navigation with SiteMaps</a> 使用站点地图(SiteMaps)提供站点导航</p>  <p>学习怎样使用便利的站点地图(SiteMaps)描述站点导航结构.在这篇教程中,将要学习怎样自定义一个可以从站点地图(SiteMap)自动生成菜单链接的HTML助手.</p>  <p>第一篇教程应该特别的有用,因为它包含了一个怎样一步步构建一个基于数据库的ASP.NET MVC Web应用程序. 个别教程还描述了Visual Studio中所提供的新的容易使用的控制器和视图添加工具.</p>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/470.htm</link>
			<title><![CDATA[[编译] ASP.NET 安全教程]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[网摘]]></category>
			<pubDate>Thu,12 Feb 2009 10:27:00 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=470</guid>
		<description><![CDATA[<p>记得 ASP.NET 官方网站有一系列文章&lt;Data Access Tutorials&gt;, 成了自己的ASP.NET数据库开发的入门教程, 此博客也做过推荐. 其不仅仅讲述了ASP.NET上数据访问方面技术, 还有部分内容介绍&quot;三层结构/站点地图/控件使用&quot;, 使自己受益匪浅. 内容现在已经更新了60多篇, 这几天发现一个中文翻译更全面的网站, 本文的末尾提供链接.</p>  <p>现在ASP.NET官方网站又发布了一个系列教程&lt;ASP.NET Security Tutorials&gt;, 粗略的看了一下, 内容讲解的很全面, 不单单讲解, ASP.NET 中&quot;安全控件/Membership/Roles&quot;的使用, 还讲解了ASP.NET的安全机理, 由浅到深, 让 ASP.NET 开发人员更好的明白 ASP.NET 中的安全设计.&#160; </p>  <p>文章的简介翻译: 欢迎能看本 ASP.NET 安全系列教程, 本教程探讨ASP.NET 应用程序上的&quot;表单验证/页面或功能的授权访问/用户帐户管理&quot;方面的技术.</p>  <p>(Welcome to a series of tutorials about ASP.NET Security, which explores techniques for authenticating visitors through a web form, authorizing access to particular pages and functionality, and managing user accounts in an ASP.NET application. )</p>  <p>下面是 Heker2007 博客上的对本教程的介绍:</p>  <ul>   <li>甄别用户 </li>    <li>通过ASP.NET的Membership framework来管理用户帐户 </li>    <li>创建、更新、删除用户帐户 </li>    <li>对登陆用户访问某个页面、目录或相关功能进行限制. </li>    <li>通过ASP.NET的Roles framework将用户帐户和角色关联起来. </li>    <li>管理用户角色. </li>    <li>对角色访问某个页面、目录或相关功能进行限制. </li>    <li>对ASP.NET的security Web controls进行定制以及扩展. </li> </ul>  <p>原文地址: <a href="http://www.asp.net/learn/security/">http://www.asp.net/learn/security/</a></p>  <p>中文翻译: <a title="http://blog.csdn.net/heker2007/category/368351.aspx" href="http://blog.csdn.net/heker2007/category/368351.aspx">http://blog.csdn.net/heker2007/category/368351.aspx</a></p>  <h4>&#160;</h4>  <h4>&lt;Data Access Tutorials&gt; (ASP.NET 数据访问教程)<a href="http://www.asp.net/rss.ashx"></a></h4>  <p>原文地址: <a title="http://www.asp.net/learn/data-access/" href="http://www.asp.net/learn/data-access/">http://www.asp.net/learn/data-access/</a></p>  <p>新的中文翻译地址: <a title="http://blog.csdn.net/heker2007/category/284875.aspx" href="http://blog.csdn.net/heker2007/category/284875.aspx">http://blog.csdn.net/heker2007/category/284875.aspx</a></p>  <li><a href="http://www.asp.net/#intro">Introduction</a> 介绍 </li>  <li><a href="http://www.asp.net/#basic">Basic Reporting</a> 基本表 </li>  <li><a href="http://www.asp.net/#master">Master/Detail</a> 主/详细 表 </li>  <li><a href="http://www.asp.net/#formatting">Custom Formatting</a> 自定义格式 </li>  <li><a href="http://www.asp.net/#editinsertdelete">Editing, Inserting, and Deleting Data</a> &quot;编辑/插入/删除&quot;数据 </li>  <li><a href="http://www.asp.net/#pagingsorting">Paging and Sorting</a> 分页/排序 </li>  <li><a href="http://www.asp.net/#buttonactions">Custom Button Actions</a> 自定义按钮动作 </li>  <li><a href="http://www.asp.net/#datalist">Displaying Data with the DataList and Repeater</a> DataList/Repeater控件显示数据 </li>  <li><a href="http://www.asp.net/#filtering">Filtering Scenarios with the DataList and Repeater</a> DataList/Repeater过滤数据系列 </li>  <li><a href="http://www.asp.net/#editingdatalist">Editing and Deleting Data Through the DataList</a> DataList编辑/删除数据 </li>  <li><a href="http://www.asp.net/#pagingdatalist">Paging and Sorting with the DataList and Repeater</a> 使用DaList/Repeater对数据进行分页/排序 </li>  <li><a href="http://www.asp.net/#buttonsdatalist">Custom Button Actions with the DataList and Repeater</a> DataList/Repeater 自定义按钮动作 </li>  <li><a href="http://www.asp.net/#sqldata">Accessing the Database Directly from an ASP.NET Page</a> ASP.NET页面上直接访问数据库 </li>  <li><a href="http://www.asp.net/#enhancing">Enhancing the GridView</a> 加强GridView控件功能 </li>  <li><a href="http://www.asp.net/#binary">Working with Binary Files</a> 二进制数据处理 </li>  <li><a href="http://www.asp.net/#caching">Caching Data</a> 数据缓存 </li>  <li><a href="http://www.asp.net/#sitemap">Database-Driven Site Maps</a> 数据库驱动的站点地图(保存站点地图到数据库?) </li>  <li><a href="http://www.asp.net/#batched">Working with Batched Data</a> 批量处理数据 </li>  <li><a href="http://www.asp.net/#advanced">Advanced Data Access Scenarios</a> 高级数据访问系列     <p></p>    <p></p> </li>]]></description>
		</item>
		
			<item>
			<link>http://zhq.ahau.edu.cn/blog/article/469.htm</link>
			<title><![CDATA[25大软件编程错误不可赦]]></title>
			<author>tupunco@163.com(tupunco)</author>
			<category><![CDATA[网摘]]></category>
			<pubDate>Tue,13 Jan 2009 10:46:34 +0800</pubDate>
			<guid>http://zhq.ahau.edu.cn/blog/default.asp?id=469</guid>
		<description><![CDATA[<p><strong>来源</strong>：<a title="http://www.cnbeta.com/articles/74680.htm" href="http://www.cnbeta.com/articles/74680.htm">http://www.cnbeta.com/articles/74680.htm</a></p>  <p>大多数IT安全事件(如补丁程序或网络攻击等)都与软件编程错误有关,在过去的三年中,非赢利调研机构MITRE和美国系统网络安全协会(SANSInstitute)发现了700多处常见的软件编程错误,经过安全专家的筛选,最终于周一公布了以下25大软件编程错误: </p>  <ol>   <li>错误的输入验证 </li>    <li>不正确的编码或转义输出 </li>    <li>维持SQL查询结构(SQL注入)错误 </li>    <li>维持网页结构(跨站点脚本)错误 </li>    <li>维持操作系统命令结果(操作系统命令注入)错误 </li>    <li>明文传送敏感信息 </li>    <li>跨站点请求伪造 </li>    <li>资源竞争(Race condition) </li>    <li>错误信息泄露 </li>    <li>限定缓冲区内操作失败 </li>    <li>外部控制重要状态数据 </li>    <li>外部控制文件名或路径 </li>    <li>不可信搜索路径 </li>    <li>控制代码生成错误(代码注入) </li>    <li>下载未经完整性检查的代码 </li>    <li>错误的资源关闭或发布 </li>    <li>不正确的初始化 </li>    <li>错误计算 </li>    <li>可渗透防护 </li>    <li>使用被破解的加密算法 </li>    <li>硬编码密码 </li>    <li>对核心资源的错误权限分配 </li>    <li>随机值的错误利用 </li>    <li>滥用特权操作 </li>    <li>客户端执行服务器端安全</li> </ol>]]></description>
		</item>
		
</channel>
</rss>
