<?xml version="1.0" encoding="utf-8" ?><rss version="2.0"> <channel><title><![CDATA[DongPad]]></title><link><![CDATA[http://www.dongpad.com]]></link> <link rel="Shortcut Icon" href="favicon.ico" /> <description>Every day is a new beginning!</description><copyright>2.0 beta 03</copyright> <language>zh-cn</language><item><title><![CDATA[Isolated Storage in SL4]]></title><description><![CDATA[This Article is Published by Live Writer。<p>在Silverlight4中，默认应用程序存储配额是1MB=1024KB=1048576Bytes，可以在SL程序的右键菜单点击查看，如下图1：</p>  <p><img src="http://www.dongpad.com/userfiles/image/Silverlight4IsolatedStorage.PNG" /> </p>  <p>如果要申请配额，可以在构造里检查存储配额然后执行一下代码，但要考虑到用户可能阻止该请求：</p>  <p>using (var store = IsolatedStorageFile.GetUserStoreForApplication())    <br />{     <br />&#160;&#160;&#160; Int64 IsoQuota = store.Quota; //<font color="#ff0000"><strong>单位为bytes</strong></font>     <br />&#160;&#160;&#160; Int64 requestIsoQuota = 1000;     <br />&#160;&#160;&#160; if (store.IncreaseQuotaTo(IsoQuota +requestIsoQuota )) //<font color="#ff0000">增加到指定大小</font>     <br />&#160;&#160;&#160; {     <br />&#160;&#160;&#160;&#160;&#160;&#160; //……     <br />&#160;&#160;&#160; }     <br />}</p>  <p>执行上述代码将自动提示用户"是否要增加可用存储"，结果如下图2：</p>  <p><img src="http://www.dongpad.com/userfiles/image/Silverlight4IsolatedStorageRequest.PNG" /> </p>  <p>为了保持默认的1MB默认存储，我们选择“否”以便于后面的测试，如果选择了“是”也没关系，我们可以在应用程序存储选项页中选择该程序删除网站对应的存储使其重新初始化到1MB。在上述代码中，我们请求增加的配额为1000bytes，但是提示请求的大小依然是默认的配额1MB，这里Silverlight是如何显示申请存储配额时请求的大小的呢？</p>  <p>经测试发现，Silverlight对请求的大小采用了<font color="#ff0000">小数点保留一位四舍五入</font>的策略，上图的请求的大小实际上就是上述代码中(IsoQuota +requestIsoQuota)除以(1MB*1024*1024)四舍五入保留一位小数的结果。在默认配额情况下，如果请求的配额requestIsoQuota 小于0.05MB=52428.8bytes=52429时，提示请求到的存储大小的小数位将被忽略，但这并不影响实际的存储配额，提示请求的大小依然是1.0MB，如果requestIsoQuota大于或等于0.05MB=52428.8bytes（requestIsoQuota类型为Int64，即requestIsoQuota最小为52429时提示请求大小为1.1MB）将提示请求大小为1.1MB。这里我们可以来验证一下，将requestIsoQuota的值更改为52428，提示请求的大小为1.0M，选择“是”对其进行增加可用存储，然后将requestIsoQuota的值更改为1，这时候的提示是请求的大小为1.1M，这也就从侧面反映了显示出来的请求的大小并不影响实际的存储配额，虽然他们可能是不一致的。</p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20100719-256.html]]></link><pubdate><![CDATA[2010-7-19 12:13:46]]></pubdate></item><item><title><![CDATA[Difference between DataContext and ItemsSource in ]]></title><description><![CDATA[<p><font color="#ff0000">DataContext is a general (dependency) property of all descendants of FrameworkElement. Is is inherited through the logical tree from parent to children and can be used as an implicit source for DataBinding. It does not do anything by itself, you must basically databind to it.</font></p>]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20100626-255.html]]></link><pubdate><![CDATA[2010-6-26 15:04:17]]></pubdate></item><item><title><![CDATA[Sequence Diagram RE, LINQ, and Lambdas]]></title><description><![CDATA[<a href="http://blogs.msdn.com/camerons/archive/2010/05/08/sequence-diagram-re-linq-and-lambdas.aspx" target="_blank">from:Skinner's Blog</a></p>  <p><font color="#8000ff" size="1">本文主要介绍了VS2010特性之Sequence Diagram Reverse Engineering对LINQ和Lambdas的扩展</font></p>  <p>The Sequence Diagram Reverse Engineering feature available in Visual Studio 2010 allows you to create a UML 2.1 “like” diagram that represents your source code. I say “like” in the previous sentence because we use all the notation prescribed by the UML standard, but there are a few instances where we add some notation that is not found in the standard. Support for LINQ and Lambda expressions are examples of where we have extended the Combined Fragment notation to include what we have dubbed a “Deferred Call”.</p>  <p>Here’s a simple console application that I’ll use to show what I mean.</p> <font color="#ff8000">略……</font>]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20100509-251.html]]></link><pubdate><![CDATA[2010-5-9 23:47:39]]></pubdate></item><item><title><![CDATA[C#编译器(csc.exe)搜索Dll的顺序]]></title><description><![CDATA[This Article is Published by Live Writer。<table border="1" cellspacing="0" cellpadding="0" width="400"><tbody>     <tr>       <td valign="top" width="400">         <p><font color="#ff0000">@CLR via C#2.0 P32</font>            <br />1.工作目录</p>          <p>2.编译器本身目录(PS:根据全局CSC.rsp文件的配置)</p>          <p>3./lib开关指定的目录</p>          <p>4.Lib环境变量指向的工作目录</p>       </td>     </tr>   </tbody></table>  <p>现在，我们来做了一下尝试,在非编译器目录创建如下两个测试类，并对C1编译:</p>  <p>//C1.cs&#160; @cmd prompt: <font color="#ff0000">csc /t:library C1.cs</font></p>  <p>public class C1    <br />{     <br />public string Name{get;set;}     <br />public int Age{get;set;}     <br />}</p>  <p>//Program.cs&#160;&#160; @cmd prompt: <font color="#ff0000">csc /r:C1.dll&#160; Program.cs</font></p>  <p>using System;    <br />public class Program     <br />{     <br />static void Main()     <br />{     <br />C1 c1 = new C1{Name="Jack"};     <br />Console.WriteLine(string.Format("c1's name is {0}",c1.Name));     <br />Console.ReadKey();     <br />}     <br />}</p>  <p>1.编译Program时，由于我们指定的非绝对路径，所以搜索到Program的当前工作目录即结束，我们亦可尝试将C1.Dll剪切到其他工作目录，并指定完整路径进行编译。</p>  <p><strike>2.将C1.dll剪切到csc工作目录C:\Windows\Microsoft.NET\Framework\v3.5(视具体环境而定)，编译不通过，</strike><font color="#ff0000">what r u doing?</font></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20100506-250.html]]></link><pubdate><![CDATA[2010-5-6 23:22:44]]></pubdate></item><item><title><![CDATA[面向对象诠释图]]></title><description><![CDATA[This Article is Published by Live Writer。<p><img border="0" alt="" src="http://images.cnblogs.com/cnblogs_com/tyl2008/OOP.jpg" width="512" height="418" /></p>  <p><a href="http://www.cnblogs.com/tyl2008/archive/2010/05/06/1729027.html" target="_blank">from Tyl2008</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20100506-249.html]]></link><pubdate><![CDATA[2010-5-6 22:25:54]]></pubdate></item><item><title><![CDATA[无法将 匿名方法 转换为类型“System.Delegate”,因为它不是委托类型]]></title><description><![CDATA[The problem the user is seeing is that the Thread ctor accepts a specific delegate -- the ThreadStart delegate.  The C# compiler will check and make sure your anonymous method matches the signature of the ThreadStart delegate and, if so, produces the proper code under-the-covers to create the ThreadStart delegate for you.<br />
But Control.Invoke is typed as accepting a "Delegate".  This means it can accept any delegate-derived type.  The example above shows an anonymous method that has a void return type and takes no parameters.  It's possible to have a number of delegate-derived types that match that signature (such as MethodInvoker and ThreadStart -- just as an example).  Which specific delegate should the C# compiler use?  There's no way for it to infer the exact delegate type so the compiler complains with an error.<br />
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20100401-246.html]]></link><pubdate><![CDATA[2010-4-1 18:01:58]]></pubdate></item><item><title><![CDATA[推荐两个免费Visual Studio插件]]></title><description><![CDATA[This Article is Published by Live Writer。<p>文章原出处<a href="http://www.colobu.com">http://www.colobu.com</a>,更多插件参见<a href="http://www.cnblogs.com/smallnest/archive/2009/12/15/1625005.html" target="_blank">这里</a></p>  <h5>5. Copy As HTML</h5>  <p>http://www.lavernockenterprises.co.uk/downloads/copyashtml/copyashtml.aspx</p>  <p>Copy As HTML是一个轻量级的VS插件。你可以利用它在VS中以HTML格式复制你的代码。在复制时它可以保留语法加亮，缩进和背景色，行数等等，方便你复制你的代码到你的博客、文档中。</p>  <p><img src="http://docs.google.com/File?id=dckwjm6x_30d65pn5hm_b" border="0" /></p>  <p></p>  <p></p>  <h5>8. PowerCommands for Visual Studio 2008</h5>  <p>http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=PowerCommands&amp;ReleaseId=559</p>  <p>为VS提供了一堆的命令扩展。</p>  <p><img src="http://docs.google.com/File?id=dckwjm6x_29fwk7h3d6_b" border="0" /></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091222-242.html]]></link><pubdate><![CDATA[2009-12-22 13:46:08]]></pubdate></item><item><title><![CDATA[A Look Back&hellip;]]></title><description><![CDATA[This Article is Published by Live Writer。<p><img src="http://docs.google.com/File?id=dckwjm6x_24fbq9pfcb_b" /></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091215-240.html]]></link><pubdate><![CDATA[2009-12-15 16:54:19]]></pubdate></item><item><title><![CDATA[Code Contracts from MSDN]]></title><description><![CDATA[<p>Lots of fixes! Our new release, 1.2.21023.14, has been upgraded to work with Visual Studio 2010 Beta 2. (Of course, it also works with Visual Studio 2008, but this is a great time to download the new beta and get started with it.) There are lots of other improvements: be sure to check out the <a href="http://research.microsoft.com/en-us/projects/contracts/releasenotes.aspx">release notes</a>. And keep using the <a href="http://social.msdn.microsoft.com/Forums/en-US/codecontracts/threads/">forum</a> to tell us what you think: many of the fixes were in response to your comments.</p>  <p>Code Contracts provide a language-agnostic way to express coding assumptions in .NET programs. The contracts take the form of pre-conditions, post-conditions, and object invariants. Contracts act as checked documentation of your external and internal APIs. The contracts are used to improve testing via runtime checking, enable static contract verification, and documentation generation. Code Contracts bring the advantages of design-by-contract programming to all .NET programming languages. We currently provide three tools:</p>  <ul>   <li><strong>Runtime Checking.</strong> Our binary rewriter modifies a program by injecting the contracts, which are checked as part of program execution. Rewritten programs improve testability: each contract acts as an oracle, giving a test run a pass/fail indication. Automatic testing tools, such as Pex, take advantage of contracts to generate more meaningful unit tests by filtering out meaningless test arguments that don't satisfy the pre-conditions. </li>    <li><strong>Static Checking.</strong> Our static checker can decide if there are any contract violations without even running the program! It checks for implicit contracts, such as null dereferences and array bounds, as well as the explicit contracts. (<strong>VSTS Edition only.</strong>) </li>    <li><strong>Documentation Generation.</strong> Our documentation generator augments existing XML doc files with contract information. There are also new style sheets that can be used with <a href="http://www.codeplex.com/Sandcastle">Sandcastle</a> so that the generated documentation pages have contract sections.</li> </ul>  <p>Code Contracts comes in two editions:</p>  <ul>   <li><strong>Code Contracts Standard Edition:</strong> This version installs if you have any edition of Visual Studio other than the Express Edition. It includes the stand-alone contract library, the binary rewriter (for runtime checking), the reference assembly generator, and a set of reference assemblies for the .NET Framework. </li>    <li><strong>Code Contracts VSTS Edition:</strong> This version installs only if you have Visual Studio Team System. It includes the static checker in addition to all of the features in the Code Contracts Standard Edition.</li> </ul>  <p><img title="Download" alt="" src="http://i.msdn.microsoft.com/ee402630.Numeral1_sm(en-us,MSDN.10).png" align="left" />    <br />Download Code Contracts <a href="http://download.microsoft.com/download/B/2/A/B2AC27BD-B797-402D-A02D-1263FBA157FA/Contracts.devlab9std.msi">Standard Edition</a>or <a href="http://download.microsoft.com/download/B/2/A/B2AC27BD-B797-402D-A02D-1263FBA157FA/Contracts.devlab9ts.msi">VSTS Edition.</a></p>  <p><img title="Getting Started Guide" alt="" src="http://i.msdn.microsoft.com/ee402630.Numeral2_sm(en-us,MSDN.10).png" align="left" />    <br />Read the <a href="http://download.microsoft.com/download/C/2/7/C2715F76-F56C-4D37-9231-EF8076B7EC13/userdoc.pdf">Code Contracts documentation</a>.</p><br />
<br />
forgot to leave the oraginal address:http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx<br />
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091215-239.html]]></link><pubdate><![CDATA[2009-12-15 14:12:35]]></pubdate></item><item><title><![CDATA[WCF之消息队列问题]]></title><description><![CDATA[This Article is Published by Live Writer。<p>1.Q:<font color="#ff8000"><strong>此计算机上尚未安装消息队列</strong></font>。</p>  <p>A:控制面板 --> 添加或删除程序 --> 添加/删除Windows组件 --> 勾选消息队列 --> 点击详细信息,将包括MSMQ HTTP支持在内的子组件都勾选上 -->确定完成。</p>  <p>上述方法主要是针对XP操作系统,更多安装步骤参见:<a href="http://msdn.microsoft.com/zh-cn/library/aa967729.aspx" target="_blank">官方的安装“消息队列 (MSMQ)”</a></p>  <p>2.Q:<font color="#ff8000"><strong>消息队列服务不可用</strong></font>。</p>  <p>A:运行输入services.msc打开服务,找到Message Queuing服务,该服务主要用来为分布式异步消息应用程序提供通信基础结构,启动该服务即可解决消息队列服务不可用的问题。</p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091204-237.html]]></link><pubdate><![CDATA[2009-12-4 11:19:19]]></pubdate></item><item><title><![CDATA[WCF中的Binding模型简介]]></title><description><![CDATA[This Article is Published by Live Writer。<p><a href="http://images.cnblogs.com/cnblogs_com/artech/WindowsLiveWriter/WCF18Binding_14BED/image_2.png"><img title="image" height="264" alt="image" src="http://images.cnblogs.com/cnblogs_com/artech/WindowsLiveWriter/WCF18Binding_14BED/image_thumb.png" width="519" border="0" /></a></p>  <p><a href="http://images.cnblogs.com/cnblogs_com/artech/WindowsLiveWriter/WCF18Binding_14BED/image_4.png"><img title="image" height="281" alt="image" src="http://images.cnblogs.com/cnblogs_com/artech/WindowsLiveWriter/WCF18Binding_14BED/image_thumb_1.png" width="524" border="0" /></a></p>  <p><a href="http://images.cnblogs.com/cnblogs_com/artech/WindowsLiveWriter/WCF18Binding_14BED/image_6.png"><img title="image" height="259" alt="image" src="http://images.cnblogs.com/cnblogs_com/artech/WindowsLiveWriter/WCF18Binding_14BED/image_thumb_2.png" width="527" border="0" /></a></p>  <p>参见:<a href="http://dotnet.cnblogs.com/page/43947/">http://dotnet.cnblogs.com/page/43947/</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091129-236.html]]></link><pubdate><![CDATA[2009-11-29 16:35:37]]></pubdate></item><item><title><![CDATA[ZT-一行命令搞定没有Visual Studio2003(2005)时的手动编译命令]]></title><description><![CDATA[<strong>起因：</strong></p>  <p>有时可能会发生这样的情况，网站做好了，要在服务器上布署。布署中发现，有些地方代码需要小改，然而，在服务器或其他地方没有安装VS系列工具，但服务器上已安装有.net框架，此时仍然需要对已有项目的某些文件进行少量修改，并再次进行编译。此时，在服务器上安装VS系列开发工具并不可能，也不经济。那么下面的方法就可以派上用场了。</p>  <p><strong>（1）将下面一行保存到你项目所在的目录下一个名为：buid.bat文件中：</strong></p>  <p>%SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe YourSolutionName.sln /t:Rebuild /p:Configuration=Release /l:FileLogger,Microsoft.Build.Engine;logfile=Build.log</p>  <p>关于buid.bat：前面名字可以随便取，后面一定是.bat，带bat后缀的是批处理文件。</p>  <p><strong>（2）运行此buid.bat文件。</strong></p>  <p>此时发现所在目录下多了PrecompiledWeb\工程名称\bin目录，下面有你需要的.dll。</p>  <p><strong></strong></p>  <p><strong>（3）再COPY到你的相关网站目录下即可。</strong></p>  <p><strong></strong></p>  <p>关于更多的MSBuild.exe命令及参数解释，这里就不多说，查一下MSDN或百度一下即可。</p>  <p>&#160;</p>  <p>补充:有时候从网站上down的demo只有源码，但是又不想通过IDE打开，直接通过msbuild生成也是可以的。</p>  <table cellspacing="0" cellpadding="0" width="700" border="1"><tbody>     <tr>       <td valign="top" width="58">语法:</td>        <td valign="top" width="689">MSBuild.exe [options] [project file]</td>     </tr>      <tr>       <td valign="top" width="58">说明:</td>        <td valign="top" width="689">在项目文件中生成指定的目标。如果未指定项目文件，则 MSBuild 在当前工作目录中搜索扩展名以“proj”结尾的文件，并使用该文件。</td>     </tr>      <tr>       <td valign="top" width="58">开关:</td>        <td valign="top" width="689">&#160;</td>     </tr>      <tr>       <td valign="top" width="58">         <p>/help&#160; </p>       </td>        <td valign="top" width="689">显示此用法信息。(缩写为: /? 或 /h)</td>     </tr>      <tr>       <td valign="top" width="58">         <p>/nologo&#160;&#160; </p>       </td>        <td valign="top" width="689">不显示启动版权标志和版权信息。</td>     </tr>      <tr>       <td valign="top" width="58">         <p>/version&#160;&#160; </p>       </td>        <td valign="top" width="689">仅显示版本信息。(缩写为: /ver)</td>     </tr>      <tr>       <td valign="top" width="58">         <p>@<file>&#160;&#160; </p>       </td>        <td valign="top" width="689">         <p>在文本文件中插入命令行设置。若要指定多个响应文件，请分别指定每个响应文件。</p>       </td>     </tr>      <tr>       <td valign="top" width="58">         <p>/noautoresponse&#160;&#160; </p>       </td>        <td valign="top" width="689">不要自动包括 MSBuild.rsp 文件。(缩写为:/noautorsp)</td>     </tr>      <tr>       <td valign="top" width="58">         <p>/target:<targets> </p>       </td>        <td valign="top" width="689">         <p>在此项目中生成这些目标。请使用分号或逗号分隔多个目标，或者分别指定每个目标。(缩写为: /t)&#160; <br />示例:/target:Resources;Compile</p>       </td>     </tr>      <tr>       <td valign="top" width="58">         <p>/property:<n>=<v></p>       </td>        <td valign="top" width="689">         <p>设置或重写这些项目级属性。<n> 为属性名，<v> 为属性值。请使用分号或逗号分隔多个属性，或者分别指定每个属性。(缩写为: /p)            <br />示例:/property:WarningLevel=2;OutDir=bin\Debug\</p>       </td>     </tr>      <tr>       <td valign="top" width="58">         <p>/logger:<logger>&#160; </p>       </td>        <td valign="top" width="689">         <p>使用此记录器记录 MSBuild 中的事件。若要指定多个记录器，请分别指定每个记录器。            <br /><logger> 语法为:[<logger class>,]<logger assembly>[;<logger parameters>]             <br /><logger class> 语法为:[<partial or full namespace>.]<logger class name>             <br /><logger assembly> 语法为:{<assembly name>[,<strong name>] | <assembly file>}             <br /><logger parameters> 是可选的，并按键入的形式原样传递给记录器。(缩写为: /l)             <br />示例:/logger:XMLLogger,MyLogger,Version=1.0.2,Culture=neutral             <br />&#160;&#160;&#160;&#160; /logger:XMLLogger,C:\Loggers\MyLogger.dll;OutputAsHTML</p>       </td>     </tr>      <tr>       <td valign="top" width="58">         <p>/verbosity:<level> </p>       </td>        <td valign="top" width="689">         <p>在事件日志中显示此级别的信息量。可用的详细级别有: q[uiet]、m[inimal]、n[ormal]、d[etailed] 和 diag[nostic]。(缩写为: /v)            <br />示例:/verbosity:quiet</p>       </td>     </tr>      <tr>       <td valign="top" width="58">         <p>/console</p>          <p>logger</p>          <p>parameters:<parameters></p>       </td>        <td valign="top" width="689">控制台记录器的参数。(缩写为: /clp)          <p>可用的参数有:            <br />&#160;&#160;&#160;&#160; PerformanceSummary - 显示任务、目标和项目中花费的时间。             <br />&#160;&#160;&#160;&#160; NoSummary - 不在末尾显示错误和警告摘要。             <br />&#160;&#160;&#160;&#160; NoItemAndPropertyList - 不在每个项目生成的开始显示项和属性的列表。             <br />&#160; 示例:/consoleloggerparameters:PerformanceSummary;NoSummary</p>       </td>     </tr>      <tr>       <td valign="top" width="58">         <p>/noconsolelogger&#160; </p>       </td>        <td valign="top" width="689">         <p>禁用默认的控制台记录器并且不将事件记录到控制台。(缩写为: /noconlog) </p>       </td>     </tr>      <tr>       <td valign="top" width="58">         <p>/validate&#160; </p>       </td>        <td valign="top" width="689">         <p>&#160; 根据默认架构验证项目。(缩写为: /val) </p>       </td>     </tr>      <tr>       <td valign="top" width="58">         <p>/validate:<schema> </p>       </td>        <td valign="top" width="689">         <p>&#160; 根据指定架构验证项目。(缩写为: /val)            <br />&#160; 示例:/validate:MyExtendedBuildSchema.xsd</p>       </td>     </tr>   </tbody></table>  <p>示例: MSBuild MyApp.sln /t:Rebuild /p:Configuration=Release   <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; MSBuild MyApp.csproj /t:Clean /p:Configuration=Debug</p><br />
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091125-235.html]]></link><pubdate><![CDATA[2009-11-25 15:04:28]]></pubdate></item><item><title><![CDATA[IIS无法启动之发生意外错误0x8ffe2740]]></title><description><![CDATA[This Article is Published by Live Writer。<p><strong>解决方法     <br /></strong>要解决这个问题,您可以进行以下任一项操作:    <br />• 在IIS管理器中更改网站绑定端口为除80端口外的其它端口.&#160; <br />• 停止正在使用80端口的应用程序,然后从IIS管理器中启动网站. </p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091125-234.html]]></link><pubdate><![CDATA[2009-11-25 13:25:44]]></pubdate></item><item><title><![CDATA[SketchPath - The XPath Tool]]></title><description><![CDATA[This Article is Published by Live Writer。<p>I added another tool to my <a href="http://blogs.msdn.com/jjameson/archive/2007/03/22/backedup-and-notbackedup.aspx">Toolbox</a> yesterday: SketchPath.</p>  <p>The <a href="http://www.sketchpath.com/">SketchPath site</a> labels it as "The XPath Tool" but I'd say it more like "<em>The</em> XPath Tool."</p>  <p>I've seen a few other tools for quickly building and testing XPath expressions against an XML document, but they pale in comparison to SketchPath. There are a number of online tools that unquestionably require less effort to get started with, but you'll likely find them very limiting as well.</p>  <p>I know I'm not the only one who thinks SketchPath rocks. Scott Hanselman included it in his <a href="http://www.hanselman.com/blog/ScottHanselmans2009UltimateDeveloperAndPowerUsersToolListForWindows.aspx">2009 Ultimate Developer and Power Users Tool List for Windows</a>.</p>  <p>If you do any significant amount of work with XML, I recommend you download SketchPath today.</p>  <p>&#160;</p>  <p>Published Wednesday, November 18, 2009 4:40 AM by <a href="http://blogs.msdn.com/user/Profile.aspx?UserID=6212">Jeremy Jameson</a></p>  <p>Filed under: <a href="http://blogs.msdn.com/jjameson/archive/tags/Core+Development/default.aspx">Core Development</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091118-233.html]]></link><pubdate><![CDATA[2009-11-18 22:03:46]]></pubdate></item><item><title><![CDATA[What&rsquo;s new in VS2010?]]></title><description><![CDATA[This Article is Published by Live Writer。<p>To see the highlights and what’s new in vs2010 please visit the follwing links: <a href="http://msdn.microsoft.com/en-us/library/dd547188(VS.100).aspx" target="_blank">Visual Studio 2010 Product Highlights</a> and <a href="http://msdn.microsoft.com/en-us/library/bb386063(VS.100).aspx" target="_blank">What's New in Visual Studio 2010</a>,<strong> </strong>especially <a href="http://msdn.microsoft.com/en-us/library/bb383815(VS.100).aspx" target="_blank">What's New in Visual C# 2010</a> and <a href="http://msdn.microsoft.com/en-us/library/dd409230(VS.100).aspx" target="_blank">What's New in the .NET Framework 4</a> !</p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091104-232.html]]></link><pubdate><![CDATA[2009-11-4 0:25:45]]></pubdate></item><item><title><![CDATA[VS2010 Beta1升级到Beta2?]]></title><description><![CDATA[This Article is Published by Live Writer。<p>先卸载Beta1吧，是不是很痛苦，更痛苦的是还需要ISO安装文件，Orz。</p>  <p>参见“<a href="http://samgentile.com/Web/vs2010-and-net-framework-4-0/vs2010-beta-2-installed-on-a-previous-beta-1-system/">VS2010 Beta 2 Installed on a Previous Beta 1 System</a>”</p>  <p>I had VS2010 Beta 1 installed. When<a href="http://samgentile.com/Web/vs2010-and-net-framework-4-0/vs-2010-beta-2-is-on-msdn-and-related-announcements/">Beta 2 came out today</a>, I found I needed to uninstall Beta 1.Here are some things you have to watch out for:</p>  <ol>   <li>You have to, of course, uninstall any extras installed after the Beta 1 install. This includes MVC, which is now in the boix. </li>    <li>The main uninstall of Beta 1 will ask you for a Beta 1 ISO, which is a real pain. The way to get around this is to do a manual install of the VS2010 TFS Object Model first and then it will be fine </li>    <li>The main uninstall of VS2010 Beta 1 will NOT uninstall all associated stuff </li>    <li>You must uninstall the VS2010 Beta 1 SDK by itself </li>    <li>Myself, and at least two other Tweeters got a complete Beta 2 install but it failed Silverlight 3 install, *even* though the SDK and the developer runtime *were* installed. It seems to notice it but instead of skipping over it, fails that install. I manually uninstalled the two, re-booted, and then did a re-install of Beta 2 but it did not pick up that it now needed the Silverlight 3 install. I went do dir\WCU\silverlight and manually installed the two files after the fact and it was fine. Someone else was able to just do a Repair after, re-boot and be fine.</li> </ol>  <p>All in all, pretty smooth given how large Beta 1 and 2 are and how many complicated pieces there are. I never seem to do fresh installs :)</p>  <p>BTW, lots of things have changed in Windows Workflow from Beta 1 to 2. I could not even open the project files. The project types have changed and<a href="http://blogs.msdn.com/mwinkle/">Matt Winkle</a>r has promised me a post on that.</p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091101-230.html]]></link><pubdate><![CDATA[2009-11-1 9:21:24]]></pubdate></item><item><title><![CDATA[Difference between StaticResource and DynamicResource in WPF]]></title><description><![CDATA[This Article is Published by Live Writer。<p>A <a href="http://msdn.microsoft.com/en-us/library/ms750950.aspx">StaticResource</a> will be resolved and assigned to the property during the loading of the XAML which occurs before the application is actually run. It will only be assigned once and any changes to resource dictionary ignored.</p>  <p>A <a href="http://msdn.microsoft.com/en-us/library/ms748942.aspx">DynamicResource</a> assigns an Expression object to the property during loading but does not actually lookup the resource until runtime when the Expression object is asked for the value. This defers looking up the resource until it is needed at runtime. A good example would be a forward reference to a resource defined later on in the XAML. Another example is a resource that will not even exist until runtime. It will update the target if the source resource dictionary is changed.</p>  <p>from <a href="http://stackoverflow.com/questions/200839/whats-the-difference-between-staticresource-and-dynamicresource-in-wpf" target="_blank">stackoverflow.com</a> by <a href="http://stackoverflow.com/users/6276/phil-wright">Phil Wright</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091010-225.html]]></link><pubdate><![CDATA[2009-10-10 23:53:57]]></pubdate></item><item><title><![CDATA[ZT-Silverlight Documentation Refresh]]></title><description><![CDATA[This Article is Published by Live Writer。<p>The documentation for a published product periodically receives corrections and bug fixes in a refresh update that publishes many of the changes at once. On occasion there may even be new content added that was produced since the last release.</p>  <p>Silverlight 3 recently had a documentation refresh to fix bugs, but what I noticed first was that an offline documentation collection was being kept in sync with the changes to the MSDN documentation. I like having an offline copy of the documentation because of the speed and responsiveness when browsing through the documentation locally.</p>  <p>Here's the <a href="http://go.microsoft.com/fwlink/?LinkID=153675">documentation collection for Silverlight 3</a> compiled into a help file if you also like having access to documentation offline.</p><p>from:<a href="http://blogs.msdn.com/drnick/archive/2009/10/09/silverlight-documentation-refresh.aspx" target="_blank">Nicholas Allen's Indigo Blog</a></p><br />
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20091009-223.html]]></link><pubdate><![CDATA[2009-10-9 22:07:56]]></pubdate></item><item><title><![CDATA[Net体系结构图]]></title><description><![CDATA[This Article is Published by Live Writer。<p><a href="/userfiles/image/net3_architecture.png"><img title="image" border="0" alt="image" src="/userfiles/image/net3_architecture.png" width="526" height="484" /></a></p>  <p><a href="http://blogs.msdn.com/xmduan/archive/2009/09/29/net.aspx" target="_blank">原文地址</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090929-222.html]]></link><pubdate><![CDATA[2009-9-29 23:32:34]]></pubdate></item><item><title><![CDATA[Applications = Code + Markup读书笔记(2)]]></title><description><![CDATA[This Article is Published by Live Writer。<p>1.由RGB三原色组成的颜色空间也叫sRGB颜色空间,sRGB空间将显示点阵图像的做法正式化   <br />The RGB color space implied by byte values of red, green, and blue primaries is sometimes </p>  <p>known as the sRGB color space, where s stands for standard. The sRGB space formalizes </p>  <p>common practices in displaying bitmapped images from scanners and digital cameras on </p>  <p>computer monitors. When used to display colors on the video display, the values of the sRGB </p>  <p>primaries are generally directly proportional to the voltages of the electrical signals </p>  <p>sent from the video display board to the monitor. </p>  <p>2.引入了scRGB的概念,也被称为sRGB64   <br />关于scRGB的Wikipedia: <a href="http://en.wikipedia.org/wiki/ScRGB">http://en.wikipedia.org/wiki/ScRGB</a></p>  <p>3.sRGB三原色存储类型为byte,scRGB三原色存储类型为float,由于scRGB可以大于1或小于0,所以scRGB颜 </p>  <p>色空间更大 </p>  <p>4.Brush体系结构   <br />Object    <br />└─DispatcherObject (abstract)    <br />&#160;&#160; └─DependencyObject    <br />&#160;&#160;&#160;&#160;&#160; └─Freezable (abstract)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─Animatable (abstract)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─Brush (abstract)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ├─GradientBrush (abstract)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; │ ├─LinearGradientBrush    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; │ └─RadialGradientBrush    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; │    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ├─SolidColorBrush    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; │    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─TileBrush (abstract)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ├─DrawingBrush    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ├─ImageBrush    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─VisualBrush </p>  <p>5.关于Brush的动态事件机制,如上结构图,Brush继承自Freezable,而Freezable实现了changed事件,所以 </p>  <p>只要Brush改变,都会通知事件的订阅者,该示例中就是通知Window来重绘窗体了,这一点需要和Winform进 </p>  <p>行区分,Winform中除非人为处理,否则更改颜色不会触发窗体绘制   <br />Obviously somebody is redrawing the client area every time the brush changes, but it's all </p>  <p>happening behind the scenes. This dynamic response is possible because Brush derives from </p>  <p>the Freezable class, which implements an event named Changed. This event is fired whenever </p>  <p>any changes are made to the Brush object, and this is how the background can be redrawn </p>  <p>whenever a change occurs in the brush. </p>  <p>This Changed event and similar mechanisms are used extensively behind the scenes in the </p>  <p>implementation of animation and other features in the Windows Presentation Foundation. </p>  <p>6.Brushes.PaleGoldenrod和new SolidColorBrush(Colors.PaleGoldenrod)虽然得到的是相同的brush, </p>  <p>但是在使用的时候要考虑到前者不允许被修改,因为前者是一个静态只读属性，还需要注意到Frozen的相关概念   <br />The SolidColorBrush objects returned from the Brushes class are in a frozen state, which </p>  <p>means they can no longer be altered </p>  <p>7.LinearGradientBrush及RadialGradientBrush的一些属性和示例应用 </p>  <p>活学活用，切勿读死书 @_@</p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090929-221.html]]></link><pubdate><![CDATA[2009-9-29 0:05:02]]></pubdate></item><item><title><![CDATA[CREATING A GLASS BUTTON: THE COMPLETE TUTORIAL]]></title><description><![CDATA[This Article is Published by Live Writer。<p>Well, it was a while back that I posted the first <a href="http://blogs.msdn.com/mgrayson/archive/2006/05/22/603939.aspx">Creating a Glass</a> button tutorial. Of course, that was based on the old look of Sparkle, and I have had some feedback recently that the project doesn't run anymore. Also, the completed tutorial never 'made it to press' leaving people with a rather lifeless button.</p>  <p>Well folks - GREAT NEWS - I have finished working on a all new glass button. And what better design to follow than some of the glass buttons in our shiny new OS.</p>  <p><img title="Windows Vista task bar" alt="Windows Vista task bar" src="http://blogs.msdn.com/photos/mgrayson/images/1689351/500x36.aspx" width="500" height="36" /></p>  <p>The Windows Vista taskbar has some real nice buttons - they are see through and have an internal glow. So, I though I would base my all new complete glass button tutorial on these babies. I also hope there is enough content in the tutorial to help you explore other designs and other controls.</p>  <p><img title="picture of the glass buttons app runing" alt="picture of the glass buttons app runing" src="http://blogs.msdn.com/photos/mgrayson/images/1689340/500x375.aspx" width="500" height="375" /></p>  <p>So, attached to this post are the full instructions for creating the buttons above. I have also attached the finished project if you want to explore what I have done. </p>  <p>This has been a while coming, so please enjoy!</p>  <p><b>Attachment(s): </b><a href="http://blogs.msdn.com/mgrayson/attachment/1689390.ashx">CreatingTheGlassButton.zip</a></p>  <p><strong>From:</strong><a href="http://blogs.msdn.com/mgrayson/archive/2007/02/16/creating-a-glass-button-the-complete-tutorial.aspx">Martin Grayson</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090925-220.html]]></link><pubdate><![CDATA[2009-9-25 23:14:36]]></pubdate></item><item><title><![CDATA[LINQ学习笔记及总结(1)]]></title><description><![CDATA[<p>完整下载：<a href="http://files.cnblogs.com/DongPad/LINQApp.7z">/Files/DongPad/LINQApp.7z</a></p><p>//【一个比较简单的需求,找出年龄大于25小于30的Person】   <br />List<Person> lpsTmp = new List<Person>{    <br />new Person{ID=1000,Name="A",Age=24},    <br />new Person{ID=1001,Name="B",Age=26},    <br />new Person{ID=1002,Name="C",Age=28},    <br />new Person{ID=1003,Name="D",Age=30},    <br />new Person{ID=1004,Name="E",Age=32}    <br />};    <br />//-------------------------------------------------------    <br />//【方式1】如果是在net1.1(1.1中还没有引入泛型概念)或2.0中,直接遍历    <br />Console.WriteLine("方式1");    <br />foreach (Person p in lpsTmp)    <br />{    <br />if (p.Age > 25 &amp;&amp; p.Age < 30)    <br />&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(string.Format("{0}'s ID is {1},{2} years old", p.Name, p.ID, p.Age));    <br />&#160;&#160;&#160; }    <br />}    <br />//-------------------------------------------------------    <br />//-------------------------------------------------------    <br />//【方式2】使用List的FindAll来实现,这里主要用到了2.0里的Predicate泛型委托    <br />// Predicate可以省略    <br />Console.WriteLine("\r\n方式2");    <br />lpsTmp.FindAll(new Predicate<Person>(FindMatchPerson2));    <br />//或    <br />lpsTmp.FindAll(FindMatchPerson2);    <br />//-------------------------------------------------------    <br />//-------------------------------------------------------    <br />//【方式3】方式2中我们需要额外的定义一个方法用来匹配集合中的对象    <br />//我们可以使用更简洁的语法,那就是匿名方法, Predicate可以省略    <br />Console.WriteLine("\r\n方式3");    <br />lpsTmp.FindAll(new Predicate<Person>(delegate(Person p)    <br />{    <br />if (p.Age > 25 &amp;&amp; p.Age < 30)    <br />&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(string.Format("{0}'s ID is {1},{2} years old", p.Name, p.ID, p.Age));    <br />return true;    <br />&#160;&#160;&#160; }    <br />return false;    <br />}));    <br />//或    <br />lpsTmp.FindAll(delegate(Person p) { return true; });    <br />//-------------------------------------------------------    <br />//-------------------------------------------------------    <br />//【方式4】方式3中我们通过匿名方法避免了去定义一个额外的判断方法    <br />//接下来我们来使用lambda表达式实现同样的效果    <br />//Lambda表达式实际上为书写匿名方法提供了一种更加简单、更加函数化的语法    <br />Console.WriteLine("\r\n方式4");    <br />var lsps4 = lpsTmp.FindAll(new Predicate<Person>(p => p.Age > 25 &amp;&amp; p.Age < 30));    <br />//或    <br />lsps4 = lpsTmp.FindAll(p => p.Age > 25 &amp;&amp; p.Age < 30);    <br />foreach (Person p in lsps4)    <br />&#160;&#160;&#160; Console.WriteLine(string.Format("{0}'s ID is {1},{2} years old", p.Name, p.ID, p.Age));    <br />//-------------------------------------------------------    <br />//-------------------------------------------------------    <br />//【方式5】接下来我们使用Linq的一些静态方法,实际上List的一些扩展方法,Func可以省略    <br />Console.WriteLine("\r\n方式5");    <br />var lsps5 = System.Linq.Enumerable.Where(lpsTmp, new Func<Person, bool>(FindMatchPerson2)).ToList();    <br />//或    <br />lsps5 = System.Linq.Enumerable.Where(lpsTmp, FindMatchPerson2).ToList();    <br />//上面的【方式5】与【方式2】比较类似,都是委托给FindMatchPerson2来执行    <br />//下同【方式3】,使用了匿名方法,可以省略Func    <br />lsps5 = System.Linq.Enumerable.Where(lpsTmp, new Func<Person, bool>(delegate(Person ppTmp)    <br />{    <br />if (ppTmp.Age > 25 &amp;&amp; ppTmp.Age < 30)    <br />&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(string.Format("{0}'s ID is {1},{2} years old", ppTmp.Name, ppTmp.ID, ppTmp.Age));    <br />return true;    <br />&#160;&#160;&#160; }    <br />return false;    <br />})).ToList();    <br />//下同【方式4】,使用lambda表达式,可以省略Func    <br />lsps5 = System.Linq.Enumerable.Where(lpsTmp, new Func<Person, bool>(p => p.Age > 25 &amp;&amp; p.Age < 30)).ToList();    <br />//-------------------------------------------------------    <br />//-------------------------------------------------------    <br />//【方式6】接下来我们使用List的一些扩展方法,这主要是为了接下来使用Linq做个铺垫    <br />//因为linq的本质就是使用扩展方法扩展了对集合类型的各种查询方法,Func可以省略    <br />Console.WriteLine("\r\n方式6");    <br />var lsps6 = lpsTmp.Where(new Func<Person, bool>(FindMatchPerson2)).ToList();    <br />//或    <br />lsps6 = lpsTmp.Where(FindMatchPerson2).ToList();    <br />//上面的【方式6】与【方式2】比较类似,都是委托给FindMatchPerson2来执行    <br />//下同【方式3】,使用了匿名方法,可以省略Func    <br />lsps6 = lpsTmp.Where(new Func<Person, bool>(delegate(Person ppTmp)    <br />{    <br />if (ppTmp.Age > 25 &amp;&amp; ppTmp.Age < 30)    <br />&#160;&#160;&#160; {    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(string.Format("{0}'s ID is {1},{2} years old", ppTmp.Name, ppTmp.ID, ppTmp.Age));    <br />return true;    <br />&#160;&#160;&#160; }    <br />return false;    <br />})).ToList();    <br />//下同【方式4】,使用lambda表达式,可以省略Func    <br />lsps6 = lpsTmp.Where(new Func<Person, bool>(p => p.Age > 25 &amp;&amp; p.Age < 30)).ToList();    <br />//-------------------------------------------------------    <br />//-------------------------------------------------------    <br />//【方式7】最后我们使用Linq语法来实现同样的效果    <br />Console.WriteLine("\r\n方式7");    <br />var lsps7 = from p in lpsTmp where p.Age > 25 &amp;&amp; p.Age < 30 select p;    <br />foreach (Person p in lsps7)    <br />&#160;&#160;&#160; Console.WriteLine(string.Format("{0}'s ID is {1},{2} years old", p.Name, p.ID, p.Age));    <br />//-------------------------------------------------------    <br />//-------------------------------------------------------    <br />//通过这里列出的几种实现方式,我们会发现用来实现的代码越来越简洁,随之提升将不仅仅是编码效率哦.吼吼!!!    <br />//这里除了Linq,成员方法,静态方法和扩展方法都可以分别使用命名委托、匿名委托或Lambda表达式作为参数!!!    <br />//这里代码演变到简洁的过程如下:    <br />//命名委托==>匿名委托==>Lambda表达式    <br />//成员方法(list.FindAll)==>静态方法==>扩展方法==>Linq    <br />//综上所述,Linq的本质无外乎委托,整一个活生生的"语法糖",他把许多东西都交给编译器来处理了    <br />//由此可见,在学习的过程中举一反三还是比较重要的,知其然更要知其所以然,通过了解本质,对于我们来说将更容易掌握知识,应用知识!!!    <br />//所涉及之处,难免会存在一些问题,诚恳希望大伙们能够提出并一起讨论!!!    <br />//参考资料：《LINQ-the future of data access in c# 3.0》    <br />//-------------------------------------------------------</p><br />
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090924-218.html]]></link><pubdate><![CDATA[2009-9-24 23:35:28]]></pubdate></item><item><title><![CDATA[44个Silverlight 视频讲座]]></title><description><![CDATA[This Article is Published by Live Writer。<p>01. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Hello-World/">Silverlight - Hello World</a>    <br />02. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Anatomy-of-an-Application/">Silverlight - Anatomy of an Application</a>    <br />03. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-The-VS-Environment/">Silverlight - The VS Environment</a>    <br />04. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Content-Controls/">Silverlight - Content Controls</a>    <br />05. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Built-In-Controls/">Silverlight - Built-In Controls</a>    <br />06. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Width-Height-Margins-Padding-Alignment/">Silverlight - Width, Height, Margins, Padding, Alignment</a>    <br />07. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Using-a-GridSplitter/">Silverlight - Using a GridSplitter</a>    <br />08. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Grid-Layout/">Silverlight - Grid Layout</a>    <br />09. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-StackPanel-Layout/">Silverlight - StackPanel Layout</a>    <br />10. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Canvas-Layout/">Silverlight - Canvas Layout</a>    <br />11. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Databinding-UI-to-NET-Classes/">Silverlight - Databinding UI to .NET Classes</a>    <br />12. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Simple-Styles/">Silverlight - Simple Styles</a>    <br />13. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Custom-Types-in-XAML/">Silverlight - Custom Types in XAML</a>    <br />14. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Binding-with-Conversion/">Silverlight - Binding with Conversion</a>    <br />15. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-List-Based-Data-Binding/">Silverlight - List Based Data Binding</a>    <br />16. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Simple-User-Control/">Silverlight - Simple User Control</a>    <br />17. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Templating-a-Button/">Silverlight - Templating a Button</a>    <br />18. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Resources-from-XAPDLLSite-Of-Origin/">Silverlight - Resources from XAP/DLL/Site Of Origin</a>    <br />19. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Animations--Storyboards/">Silverlight - Animations &amp; Storyboards</a>    <br />20. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Uploads-with-WebClient/">Silverlight - Uploads with WebClient</a>    <br />21. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Downloads-with-WebClient/">Silverlight - Downloads with WebClient</a>    <br />22. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Calling-HTTPS-Web-Services/">Silverlight - Calling HTTPS Web Services</a>    <br />23. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Calling-Web-Services/">Silverlight - Calling Web Services</a>    <br />24. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Making-Cross-Domain-Requests/">Silverlight - Making Cross Domain Requests</a>    <br />25. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Using-HttpWebRequest/">Silverlight - Using HttpWebRequest</a>    <br />26. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-File-Dialogs-and-User-Files/">Silverlight - File Dialogs and User Files</a>    <br />27. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Using-Sockets/">Silverlight - Using Sockets</a>    <br />28. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Using-Isolated-Storage/">Silverlight - Using Isolated Storage</a>    <br />29. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-NET-Code-Modifying-HTML/">Silverlight - .NET Code Modifying HTML</a>    <br />30. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Using-Isolated-Storage-Quotas/">Silverlight - Using Isolated Storage Quotas</a>    <br />31. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Calling-JavaScript-from-NET/">Silverlight - Calling JavaScript from .NET</a>    <br />32. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Evaluating-JavaScript-from-NET-Code/">Silverlight - Evaluating JavaScript from .NET Code</a>    <br />33. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Handling-HTML-Events-in-NET-Code/">Silverlight - Handling HTML Events in .NET Code</a>    <br />34. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Handling-NET-Events-in-JavaScript/">Silverlight - Handling .NET Events in JavaScript</a>    <br />35. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Calling-NET-from-JavaScript/">Silverlight - Calling .NET from JavaScript</a>    <br />36. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Displaying-a-Custom-Splash-Screen/">Silverlight - Displaying a Custom Splash Screen</a>    <br />37. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Passing-Parameters-from-your-Web-Page/">Silverlight - Passing Parameters from your Web Page</a>    <br />38. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Loading-Media-at-Runtime/">Silverlight - Loading Media at Runtime</a>    <br />39. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Dynamically-Loading-AssembliesCode/">Silverlight - Dynamically Loading Assemblies/Code</a>    <br />40. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-ReadingWriting-XML/">Silverlight - Reading/Writing XML</a>    <br />41. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Using-Silverlight-Streaming/">Silverlight - Multiple Threads with BackgroundWorker</a>    <br />42. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-InsertUpdateDelete-with-the-DataGrid/">Silverlight - Insert/Update/Delete with the DataGrid</a>    <br />43. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Getting-Started-with-the-DataGrid/">Silverlight - Getting Started with the DataGrid</a>    <br />44. <a href="http://channel9.msdn.com/posts/mtaulty/Silverlight-Embedding-Custom-Fonts/">Silverlight - Embedding Custom Fonts</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090920-217.html]]></link><pubdate><![CDATA[2009-9-20 20:09:43]]></pubdate></item><item><title><![CDATA[Applications = Code + Markup读书笔记(1)]]></title><description><![CDATA[This Article is Published by Live Writer。<p>1. 关于Application和Window的层次结构</p>  <p>Object   <br /> └─DispatcherObject (abstract)    <br />&#160;&#160;&#160; ├─<font color="#ff0000">Application     <br /></font>&#160;&#160;&#160; └─DependencyObject    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─Visual (abstract)    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─UIElement    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─FrameworkElement    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─Control    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─ContentControl    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; └─<font color="#ff0000">Window</font></p>  <p>2.如果没有显示的设置Window的宽或高,他们的值将始终是NaN</p>  <p>The Width and Height properties are initially undefined, and if your program never sets them, they remain undefined, which means they have values of NaN, the abbreviation immortalized by the IEEE (Institute of Electrical and Electronics Engineers, Inc.) floating-point standard for "not a number."</p>  <p>3.与设备无关单位(1/96inches),这一点需要与DPI进行区分</p>  <p>The units in which you specify all dimensions and locations in Windows Presentation Foundation are sometimes called device-independent pixels or logical pixels but it's probably best not to refer to pixels at all.</p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090920-216.html]]></link><pubdate><![CDATA[2009-9-20 15:43:23]]></pubdate></item><item><title><![CDATA[ZT-Windows Presentation Foundation 工具 - WPF 性能分析工具]]></title><description><![CDATA[This Article is Published by Live Writer。<p>WPF 提供了一套性能分析工具，来帮助您分析应用程序的运行时行为，并确定可以应用的性能优化的类型。下表列出了 Windows SDK 工具 WPFPerf 中包括的五个性能分析工具：</p>  <p><strong>Perforator（分析器）</strong>    <br /> 用于分析呈现行为。Perfortor（分析器）是一种用于分析呈现行为的性能分析工具。Perfortor（分析器）主窗口显示了一组选项，您可以利用这些选项来分析应用程序各部分中非常具体的呈现行为。    <br />使用 Perfortor（分析器）    <br />若要使用 Perfortor（分析器），请启动您想要分析其呈现行为的 WPF 应用程序。启动了应用程序后，在 Perfortor（分析器）中单击“Refresh”（刷新）按钮。应用程序现在应出现在 WPF 应用程序的“分析器”（Perforator）列表框中。选择想要分析的应用程序和呈现选项。Perfortor（分析器）数据值（比如帧速率）将立即反映应用程序的呈现行为。</p>  <p><strong>Visual Profiler（可视化探查器）</strong>    <br /> 用于按可视化树中的元素分析 WPF 服务（如布局和事件处理）的使用。可视化探查器是一种性能工具，用于按可视化树中的元素分析 WPF 服务（如布局和事件处理）的使用。通过分析此工具的分析输出，可以确定应用程序中的哪些可视元素可能引起性能瓶颈。可视化探查器主窗口显示一组选项，您可以利用这些选项来指定要如何分析应用程序：</p>  <p>Update Interval（更新间隔）。 要在分析过程中使用的时间间隔。</p>  <p>Display Overlay（显示覆盖）。 显示覆盖选项允许您显示 CPU 资源使用量 — 暗红色的覆盖指示较大的 CPU 资源使用量。</p>  <p>可视化分析的值</p>  <p>使用可视化探查器   <br />若要使用可视化探查器，请单击“Start Profiling”（开始分析）按钮，并选择“Launch”（启动）或“Attach”（附加）。为了使用“Attach”（附加）选项，WPFPerf 和所分析的应用程序都必须以管理访问权限运行。同样，覆盖功能处于禁用状态，因此可用于“Attach”（附加）选项的事件较少。“Launch”（启动）选项是推荐选项。</p>  <p><strong>Working Set Analyzer（工作集分析器）</strong>    <br /> 用于分析应用程序的工作集特征。    <br /> Working Set Analyzer（工作集分析器）是一种 WPF 性能分析工具，提供有关指定进程的内存使用量信息。利用此工具，您可以生成特定应用程序状态时的应用程序内存使用量信息的快照。</p>  <p><strong>Event Trace（事件跟踪）</strong>    <br /> 用于分析事件并生成事件日志文件。    <br /> Windows 事件跟踪 (ETW) 是一种高效的内核级别跟踪工具，它使您能够将内核或应用程序定义的事件记录到日志文件。您可以在实时或从日志文件中使用事件，并使用它们来调试应用程度或确定应用程序中何处发生了性能问题。WPF 事件跟踪分析工具使用 ETW 来记录事件。</p>  <p><strong>ETW Trace Viewer（ETW 跟踪查看器）</strong>    <br /> 以 WPF 用户界面的格式记录、显示和浏览 Windows 事件跟踪 (ETW) 日志文件。    <br /> Windows 事件跟踪 (ETW) 提供了一种机制，用于跟踪和记录用户模式应用程序引发的事件。ETW 在 Windows 操作系统中实现，为开发人员提供了一组快速、可靠而通用的事件跟踪功能。“Event Trace”（事件跟踪）工具允许您用特定于 WPF 的用户界面格式记录、显示和浏览 ETW 日志文件。</p><br />
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090910-214.html]]></link><pubdate><![CDATA[2009-9-10 23:57:47]]></pubdate></item><item><title><![CDATA[Configuring Visual Studio to Debug .NET Framework Source Code]]></title><description><![CDATA[This Article is Published by Live Writer。<p>It's finally here - the launch of the .NET Reference Source project.&#160; This post (hopefully!) contains everything you need to know.&#160; Over the past few weeks, we ran a pilot of this feature and collected lots of great data that helped us work through some issues and understand where people were likely to have problems. </p>  <p>First, though, if you have any problems, please make sure you've followed all of the steps exactly as described.&#160; If you're still having problems, please check the <a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx#faq">FAQ/Troubleshooting</a> section at the bottom.&#160; If that doesn't work, post a comment below and I'll look into it.</p>  <h6>BASIC SETUP</h6>  <p>Note this functionality is <strong>not</strong> available on the Express versions of the Visual Studio 2008 products.</p>  <p>1) Install the <a href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=10443&amp;wa=wsignin1.0">Visual Studio 2008 QFE</a>.&#160; This Hotfix just updates a DLL that's part of the Visual Studio debugger that fetches the source files, more details on the download page.</p>  <p><strong> UPDATE:</strong>&#160; If you get an error installing the Hotfix , try inserting your VS 2008 DVD and then running the Hotfix EXE again.&#160; We're looking into the root cause - it's related to having a prior version of VS 2008 (e.g. Beta 2) installed on the machine.&#160; But this workaround should allow the Hotfix to install properly.</p>  <p><strong>UPDATE (1/18):</strong> There were some problems with the QFE link above that have been addressed, sorry for the inconvenience, it's fixed now.</p>  <p>2) Start Visual Studio 2008 and bring up Tools > Options > Debugging > General.&#160; If you are running under the <strong>Visual Basic Profile</strong>, you will need to check the box on the <strong>lower left of the Options Dialog </strong>marked "<strong>Show All Settings</strong>" before continuing (other profiles won't have this option).</p>  <p>Set the following two settings:</p>  <ul>   <li>Turn <strong>OFF </strong>the "<strong>Enable Just My Code</strong>" setting </li>    <li>Turn <strong>ON</strong> the "<strong>Enable Source Server Support</strong>" setting</li> </ul>  <p>Your settings should be as below:</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_38.png"><img height="439" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_11.png" width="756" border="0" /></a></p>  <p>3) Next, bring up the "Symbols" Page and set the symbols download URL and a cache location.&#160; Specifically, set the three settings below:</p>  <ul>   <ul>     <li>Set the symbol file location to be: <strong>http://referencesource.microsoft.com/symbols</strong></li>      <li>Set a cache location.&#160; Make sure this is a location that your account has read/write access to.&#160; A good option for this is to place this path somewhere under your user hive (e.g. c:\users\sburke\symbols) </li>      <li>Enable the "Search the above locations only when symbols are loaded manually" option.</li>   </ul> </ul>  <p>When you're finished, the settings should look like the image below:</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_23.png"><img height="438" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_2.png" width="763" border="0" /></a></p>  <p>Setup is done!&#160; That's it, really!</p>  <h6>DEBUGGING INTO FRAMEWORK SOURCE</h6>  <p>For this simple example, we'll start with a blank C# Windows Application project, but it will work the same with a VB, Web, or WPF project.&#160; To walk through this, go ahead and create that project.</p>  <p>Set a breakpoint in <strong>Form_Load</strong>:</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_10.png"><img height="87" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_4.png" width="616" border="0" /></a></p>  <p>Now run your project to hit that breakpoint and go to your <strong>Call Stack</strong> window (<strong>CTRL+ALT+C</strong>).&#160; In the Call Stack, right click a frame that starts with<strong>System.Windows.Forms.dll</strong>, and choose "<strong>Load Symbols</strong>".&#160; This will load the symbols for the System.Windows.Forms assembly, which are about 10 megabytes, so the speed of the download will vary according to your connection speed.&#160; Note that Visual Studio may be unresponsive during this time.&#160;&#160; However, this download is a one-time cost for each assembly.&#160; The symbols (PDB) file will be cached on your machine, in the directory specified in the steps above. </p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_12.png"><img height="378" alt="Loading Symbols Manually" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_5.png" width="801" border="0" /></a></p>  <p>This will load the symbols for the DLL from the server, and you'll see some information in the status bar to reflect this.&#160; Note that when this completes, the call frames will turn black and line numbers will be available.&#160; Note you'll need to do the <strong>Right Click -> Load Symbols</strong> step each time you launch a debugging session (but, again, the symbols will now be cached locally so they won't have to download).&#160; For more information on this, see the ADVANCED USERS section below.</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_14.png"><img height="124" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_6.png" width="719" border="0" /></a></p>  <p>You have now loaded the symbols for the Windows Forms DLL and can begin viewing the code.&#160; You can view code in any way that you normally would in a debugging session.&#160; In this case you can either <strong>Step In</strong> to the line of code above, or you can<strong> double-click one of the frames</strong> in the Call Stack Window.&#160;&#160; For this case, we'll step in (<strong>F11</strong>).</p>  <p>The first time you step into code, we'll be presented with the EULA for accessing the source code.&#160; Please take the time to read this EULA.&#160; If you agree to the terms of the EULA, hit ACCEPT, and the source will then be downloaded.</p>  <p>That's it! You're now debugging .NET Framework Source!</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_16.png"><img height="484" alt="Debugging Form.cs in Windows Forms" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_7.png" width="542" border="0" /></a></p>  <p>Now, for each assembly that you'd like to debug into just repeat the steps above (note you'll only see the EULA <em>once</em>, not for each file).</p>  <p>There are times when the Assembly you'd like to debug into isn't on the call stack, for example in the code below:</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_18.png"><img height="100" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_8.png" width="729" border="0" /></a></p>  <p>Before you step in to <strong>Graphics.DrawRectangle</strong>, you need to get the symbols for <strong>System.Drawing.Dll</strong> loaded.&#160; To do this, we use the <strong>Modules Window</strong>(<strong>CTRL+ALT+U</strong>).&#160; This lists all of the modules (DLLs) loaded by the debuggee.&#160; Just find <strong>System.Drawing.DLL</strong> in this list, <strong>right click</strong>, and choose <strong>Load Symbols</strong>.</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_22.png"><img height="208" alt="Load via Modules Window" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_10.png" width="859" border="0" /></a></p>  <p>Note that once a symbol file is loaded, the path to the symbol file shows up in the "Symbol File" column.</p>  <p>You can now step into the Graphics.DrawRectangle code above using F11!&#160; In this case, note, you'll have to step through the PaintEventArgs.Graphics property code first.</p>  <h6>ADVANCED USERS</h6>  <p>Normally, each time you launch a debugging session, Visual Studio attempt to download symbols for each DLL that loads into the debuggee process.&#160; As part of this process, it asks each path specified in the Debugging Symbols dialog for the corresponding PDB.&#160; Some projects load a LOT of DLLs which won't have symbols available, so this process can significantly impact debugger startup time as this probing occurs.&#160; It is mainly for this reason we've recommended manual symbol loading in the steps above; we don't want using this feature to degrade the debugging experience across-the-board.</p>  <p>There is, however, a way to allow automatic symbol loading (which avoids the "Load Symbols" step) in a way that minimizes performance impact.&#160;&#160; This is for more advanced users because it requires regular trips back to this Debugging Symbols Dialog.&#160; Note you can quickly get to this dialog by choosing the "<strong>Symbol Settings...</strong>" item on the right click menus pictured in steps above form the Call Stack or Modules windows.</p>  <p>The key is to get all of the symbols for a given project type downloaded and cached locally, then turn off the automatic symbol downloads.&#160; This will prevent the pings at debugger startup as well.</p>  <p>To do this, configure your setup as above with the following difference: <strong>Uncheck the</strong> "<strong>Search from the above locations..."</strong> item on the dialog.</p>  <p>Now, launch your project in the debugger.&#160; This will cause all of the symbols available for the DLLs in your process to be downloaded at on-demand as the DLLs are loaded into the process.&#160; Depending on your connection speed, this could take a while (it's generally about 50MB of symbols), so it's a good idea to hit F5 then go do something else for a while.&#160; Again, these symbols are cached so this is a one-time cost.&#160; Visual Studio will likely be unresponsive during this download process.</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_26.png"><img height="437" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_12.png" width="758" border="0" /></a></p>  <p>Once that process has completed, stop the debugger, and UNCHECK the the Reference Source Server symbol location, and hit OK:</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_28.png"><img height="442" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_13.png" width="761" border="0" /></a></p>  <p>Now when you launch the debugger, symbols will load automatically and you'll be be able to step in and through call stacks normally.&#160; Note if you switch to a different project type (that has different assemblies), or have assemblies that are loaded later by your project, you can just repeat these steps to get any assemblies you don't have cached locally). </p>  <p><a name="faq"></a></p>  <h6>FAQ/TROUBLESHOOTING</h6>  <h6>1) Which assemblies are currently available for symbol/source loading:</h6>  <ul>   <li>Mscorlib.DLL </li>    <li>System.DLL </li>    <li>System.Data.DLL </li>    <li>System.Drawing.DLL </li>    <li>System.Web.DLL </li>    <li>System.Web.Extensions.DLL </li>    <li>System.Windows.Forms.DLL </li>    <li>System.XML.DLL </li>    <li>WPF (UIAutomation*.dll, System.Windows.DLL, System.Printing.DLL, System.Speech.DLL, WindowsBase.DLL, WindowsFormsIntegration.DLL, Presentation*.dll, some others) </li>    <li>Microsoft.VisualBasic.DLL</li> </ul>  <h6>2) When I choose "Load Symbols" I get an Open File dialog asking for the PDB.</h6>  <p>This can be caused by one of four situations:</p>  <ul>   <li>You didn't configure the symbol location URL properly from basic setup above.&#160; Ensure it's <strong>http://referencesource.microsoft.com/symbols</strong>. </li>    <li>You chose a cache symbols directory that your user account doesn't have write permissions for. </li>    <li>You attempted to Load Symbols for a DLL that's not available in the list above </li>    <li>You have a different version of the .NET Framework on your machine - this can happen, for example, if you're running a Windows Server 2008 Beta.&#160; To check this, go to the Modules Window in Visual Studio (CTRL+ALT+U) and ensure that the version number of your mscorlib.dll is 2.0.50727.1433, as below.&#160; If not, make sure you install the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6&amp;displaylang=en">RTM Version of the .NET Framework 3.5</a>.</li> </ul>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image61.png"><img height="82" alt="" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image61_thumb.png" width="472" border="0" /></a></p>  <ul>   <li>Check your "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE" (or wherever you installed VS) for a file called <strong>symsrv.no</strong>.&#160; If that file exists, rename it to <strong>symsrv.yes</strong>, and restart Visual Studio. </li> </ul>  <h6>3) When I try to open or step into a source code file, I get a dialog that says "Source is not available for this location" or I get an Open File dialog for the file.</h6>  <p>First, see FAQ item (2) above to ensure the symbols for the DLL were loaded successfully.&#160; You can verify this by looking in the Modules Window under the "Symbols Status" column.</p>  <p>If the Symbols Status is "Symbols loaded.", check the following.</p>  <ul>   <li>If you have configured <a href="http://www.microsoft.com/whdc/devtools/debugging/debugstart.mspx">Microsoft Symbol Server</a> in the past, you may have already downloaded symbols for this DLL that don't contain source information.&#160; Try specifying a different cache path or deleting your existing cache path, and then repeating the Load Symbols command.&#160;&#160; See FAQ #4 for more information on this. </li>    <li>Ensure you have checked the "<strong>Enable Source Server</strong>" item on the <strong>Tools -> Options -> Debugging -> General</strong> page </li>    <li>Ensure that your account has read/write access to your cache path </li>    <li>If you have _NT_SYMBOL_PATH set, it will override these settings.&#160; Details <a href="http://codebetter.com/blogs/james.kovacs/archive/2008/01/17/debugging-into-the-net-framework-source.aspx">here</a>.</li> </ul>  <h6>4) I also use <a href="http://www.microsoft.com/whdc/devtools/debugging/debugstart.mspx">Microsoft Symbol Server</a> to download symbols.&#160; What's the difference? Can these two programs co-exist?</h6>  <p>Microsoft Symbol Server provides symbols without any source information in them.&#160; That information has been removed (sometimes referred to as "stripped") before publishing.&#160; The symbols provided on the Reference Source Server are full symbols with debugging information.</p>  <p>The key to using both is to have your Reference Source path above the Symbol Server Path so that those symbols are searched/found first.&#160; As described in the ADVANCED USERS section above, you'll likely want to launch your debugger once with this configuration to get all the symbols downloaded, then uncheck both of these paths to avoid debugging launch slowdowns in the future.&#160; Also note that this may conflict in the future as more DLLs are added to the Reference Source Project.&#160; Meaning, if you've already downloaded the Symbol Server symbol, you'll need to delete that or change your cache path to get the Reference Source one (Visual Studio has no way of knowing which is which).</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_32.png"><img height="374" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_15.png" width="644" border="0" /></a></p>  <p>One final note here, if you have the Microsoft Symbol Server configured via _NT_SYMBOL_PATH, you'll need to add the Reference Source path above to that path as well - _NT_SYMBOL_PATH overrides the above settings.</p>  <h6>5) Does this work with 64-bit?</h6>  <p>Yes, we've also provided 64-bit versions of the PDBs.&#160; Note some DLLs work on multiple architectures, so not all of them need a separate 64-bit PDB.</p>  <h6>6) How do I set breakpoints in Framework code?</h6>  <p>Visual Studio requires the code to exactly match what is expected by the PDB.&#160; The source publishing process, however, makes some small updates to the code, such as pushing a standard copyright banner to the end of the source file.&#160; This changes the signature (CRC) of the code file.&#160; However, it's still easy to set a breakpoint. </p>  <p>Just set your breakpoint as normal (you'll see it fails with a little warning icon), then right click the breakpoint and choose "Location..."</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_34.png"><img height="244" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_16.png" width="807" border="0" /></a></p>  <p>Then check the "Allow Source to be Different" box, hit OK.</p>  <p><a href="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_36.png"><img height="233" alt="image" src="http://blogs.msdn.com/blogfiles/sburke/WindowsLiveWriter/ConfiguringVisual.NETFrameworkSourceCode_9B9C/image_thumb_17.png" width="598" border="0" /></a></p>  <p>Now the breakpoint will set successfully.</p>  <p>If you find yourself doing this often, you can also disable source matching in general by disabling Tools->Options->Debugging: “Require source files to exactly match the original version.”</p>  <h6>7) Why don't some features like "Go To Definition" work?</h6>  <p>Browse database information is separate from symbol (PDB) information within the debugger, so that information is maintained by the project system when a project is compiled and is not present within the symbol files.&#160; So, unfortunately, that ability is not available here.</p>  <h6>8) Why are some member or local variables unavailable?&#160; Why can't I step into certain functions or lines of code?</h6>  <p>The .NET Framework bits that you have installed on your machine are “retail” bits, which means they are optimized for size and performance.&#160; Part of this optimization process removes certain information from the process when it is no longer needed.&#160; Debugging retail assemblies reflects this.&#160; However, most debugging information is still present in the session, and setting breakpoints earlier in a function often allows it to be visible.&#160;&#160; Another aspect of retail builds is that some small methods may be “inlined” which means you will not be able to step into them or set breakpoints in them.&#160; But for the most part you can step and debug as normal.</p>  <h6>9) Why does it take so long to download some source files?</h6>  <p>Some source files are very large - nearly 1MB - and unfortunately many of these are the common ones to download.&#160; However, most are significantly smaller and download quickly.&#160; Source files must be downloaded each time you restart Visual Studio.&#160; They are not persistently cached like symbols are.</p>  <h6>10) Can I just download all of the code at once?</h6>  <p>Not currently, but we are currently working on enabling this functionality in the future.</p>  <h6>11) When I debug into VB code, for example in Microsoft.VisualBasic.dll, there is a C# style comment at the bottom, is this a bug?</h6>  <p>Not really - we do run a post processing step when publishing the code and it adds a standard copyright banner at the bottom.&#160; The processor, at this time, isn't able to support multiple comment formats.&#160; Having it in a non-VB format doesn't affect the debugging functionality in any way.</p>  <h6>12) I got to a source file and all that downloaded was a blank file?</h6>  <p>This is something we've seen intermittently but have not been able to diagnose.&#160; If you see this, usually the workaround is to just restart VS, which will force the file to reload.&#160; If you observe this behavior, please use the "Email" link on the left to email me the name of the file that failed and about what time the failure occurred.</p>  <h6>13) What happens if I download a Hotfix or a Service Pack?&#160; Will I be able to get source for that?</h6>  <p>We've built a system that allows us to publish any number of versions of source and symbols for a given product.&#160; We haven't made any firm decisions on how often we'll publish source and are open to customer feedback on those issues.&#160; For example, it's clear that publishing source for each Service Pack makes sense, but it's unclear if we'll be able to do so for each Hotfix.&#160; Again, we're looking forward to feedback here.</p>  <p>In the meantime, also note that symbol files may no longer match a module if a framework DLL has been updated via a Hotfix. In those cases, the modules window will indicate that the symbols could not be downloaded for that module. Assuming a new symbol file was published, it can be downloaded and cached using “Load Symbols”.</p>  <h6>14) Can I point a web browser at the symbols URL and download the symbols directly?</h6>  <p>No, you'll get an <strong>HTTP 400 (Bad Request)</strong> response.</p>  <h6>SUPPORT</h6>  <p>If you have any other questions, please visit our new MSDN Forum on the topic: <a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=2019&amp;SiteID=1">Reference Source Server Discussion</a>.</p>  <p>Thanks!</p>  <p>from:<a href="http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx" target="_blank">Shawn Burke's Blog</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090909-213.html]]></link><pubdate><![CDATA[2009-9-9 9:48:26]]></pubdate></item><item><title><![CDATA[新版.Net开发必备十大工具]]></title><description><![CDATA[This Article is Published by Live Writer。<h5><strong>Snippet Compiler</strong></h5>  <p>&#160;&#160; Snippet Compiler是一个基于 Windows 的小型应用程序，你可以通过它来编写、编译和运行代码。如果你具有较小的代码段，并且你不想创建完整的 Visual Studio .NET项目（以及该项目附带的所有文件），则该工具会很有用。现在Snippet Compiler已经支持.NET Framework 3.5，最新版本为Snippet Compiler Live 2008 Ultimate Edition for Developers (Alpha)。</p>  <h5><strong>Microsoft Source Analysis for C#</strong></h5>  <p>&#160;&#160; Microsoft Source Analysis for C#是一款C#（不支持VB.NET）代码规范检查工具，前身是微软内部代码规范检查和代码格式强制工具StyleCop，目的是帮助项目团队执行一系列常用的源代码格式规范，它会根据预定义的C#代码格式的最佳实践进行检查，与FxCop不同的是它直接对源代码进行检查，且并不提供灵活的规则设置，强制开发者使用相同的习惯进行C#代码的编写。</p>  <h5><strong>GhostDoc</strong></h5>  <p>&#160;&#160; GhostDoc是Visual Studio的一个免费插件，可以帮助开发者生成比较完整规范的XML格式代码注释，如果你的代码遵循微软类库开发人员设计规范 ，由它自动产生的注释就已经完全可以很好地表达开发者创建的方法或者属性的意图，无需手工再进行修改。有了这些标准的XML注释，我们可以使用微软的文档工具Sandcastle生成专业级别的帮助文档。</p>  <h5><strong>Sandcastle</strong></h5>  <p>&#160;&#160; Sandcastle是微软发布的一个帮助文档生成工具，它通过反射程序集中的源代码和添加代码到中的XML注释来创建专业级别的帮助文档。Sandcastle于2006年推出，它的面世也使得曾经列入.NET开发必备十大工具之一的文档生成工具NDoc的作者Kevin Downs在2006年7月宣告不再投入NDoc Open Source Project的开发。</p>  <h5><strong>Nunit</strong></h5>  <p>&#160;&#160; NUnit 是为 .NET 框架生成的开放源代码单元测试框架。NUnit 使你可以用你喜欢的语言编写测试，从而测试应用程序的特定功能。当你首次编写代码时，单元测试是一种测试代码功能的很好方法，它还提供了一种对应用程序进行回归测试的方法。NUnit 应用程序提供了一个用于编写单元测试的框架，以及一个运行这些测试和查看结果的图形界面。</p>  <h5><strong>MyGeneration</strong></h5>  <p>作为.NET开发人员，手边有一款代码生成工具必不可少。旧版.NET开发必备十大工具中，曾经有非常著名的CodeSmith，不幸的是现在CodeSmith已经商业化，需要花钱购买；幸运的是我们又有一款免费并开源的代码生成工具选择MyGeneration，它的功能丝毫不亚于CodeSmith，完全基于模板引擎进行代码的生成。</p>  <h5><strong>Reflector for .NET</strong></h5>  <p>相信大名鼎鼎的Reflector for .NET大家都已经用过了，几年前它已经位于.NET开发必备十大工具榜，现在自然也不能例外。它是一个类浏览器和反编译器，可以分析程序集并向你展示它的所有秘密。使用Reflector for .NET可以浏览程序集的类和方法，可以分析由这些类和方法生成的 Microsoft 中间语言 (MSIL)，并且可以反编译这些类和方法并查看 C# 或 Visual Basic.NET 中的等价类和方法。经过多年的发展，Reflector for .NET已经发展到了5.1版本，并且提供了相当丰富的插件，利用这些插件我们可以浏览Silverlight程序结构、浏览WPF资源文件、与TestDriven.net集成等。</p>  <h5><strong>The Regulator</strong></h5>  <p>&#160;&#160; The Regulator能够使生成和测试正则表达式变得很容易，它允许你输入一个正则表达式以及一些针对其运行该表达式的输入。这样，在应用程序中实现该正则表达式之前，你便可以了解它将产生什么效果以及它将返回哪些种类的匹配项。另外它还提供了正则表达式库管理功能，在线更新正则表达式库，可以在RegexLib.com上搜索需要的正则表达式。</p>  <h5><strong>LINQPad</strong></h5>  <p>随着在.NET Framework 3.5中对于LINQ的支持，越来越多的开发者在开发中使用了LINQ to SQL，但是编写LINQ to SQL查询似乎又成了一件很麻烦的事情，好在我们还有LINQPad这个工具，用来编写LINQ查询，不仅仅是LINQ to SQL，同时它也支持LINQ to XML、LINQ to Objects，另外LINQPad是完全免费的且无需安装，只要下载它的可执行文件就可以了。</p>  <h5><strong>NAnt</strong></h5>  <p>&#160;&#160; NAnt 是一个基于 .NET 的生成工具，与当前版本的 Visual Studio .NET 不同，它使得为你的项目创建生成过程变得非常容易。当你拥有大量从事单个项目的开发人员时，你不能依赖于从单个用户的座位进行生成。你也不希望必须定期手动生成该项目。你更愿意创建每天晚上运行的自动生成过程。NAnt 使你可以生成解决方案、复制文件、运行 NUnit 测试、发送电子邮件，等等。遗憾的是，NAnt 缺少漂亮的图形界面，但它的确具有可以指定应该在生成过程中完成哪些任务的控制台应用程序和 XML 文件。目前NAnt已经支持.NET Framework 3.5，它的最新版本是0.86 Beta 1。</p>  <p>转自:<a href="http://www.cnblogs.com/psunny/archive/2009/09/07/1561971.html" target="_blank">新版.Net开发必备十大工具</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090908-211.html]]></link><pubdate><![CDATA[2009-9-8 16:37:14]]></pubdate></item><item><title><![CDATA[ZT-C#设计模式(23种设计模式)]]></title><description><![CDATA[This Article is Published by Live Writer。<p>创建型：   <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 1. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/08/28/873342.html">单件模式(Singleton Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 2. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/08/29/874891.html">抽象工厂（Abstract Factory）</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 3. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/08/30/876133.html">建造者模式(Builder)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 4. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/08/31/876994.html">工厂方法模式（Factory Method)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 5. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/03/879936.html">原型模式(Prototype)</a>    <br />结构型：    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 6. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/04/881674.html">适配器模式（Adapter Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 7. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/05/882918.html">桥接模式（Bridge Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 8. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/06/884495.html">装饰模式(Decorator Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 9. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/07/885951.html">组合模式(Composite Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 10. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/11/889542.html">外观模式（Facade Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 11. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/12/890556.html">享元模式(Flyweight Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 12. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/13/891638.html">代理模式(Proxy Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 13. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/14/892726.html">模板方法(Template Method)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 14. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/17/896195.html">命令模式(Command Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 15. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/18/896829.html">迭代器模式(Iterator Pattern)</a>    <br />行为型：    <br />&#160;&#160;&#160;&#160;&#160;&#160; 16. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/19/898856.html">观察者模式(Observer Pattern）</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 17. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/20/900264.html">解释器模式(Interpreter Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 18. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/24/904253.html">中介者模式(Mediator Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 19. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/25/905622.html">职责链模式(Chain of Responsibility Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 20. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/26/906636.html">备忘录模式(Memento Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 21. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/27/908190.html">策略模式(Strategy Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 22. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/28/909482.html">访问者模式(Visitor Pattern)</a>    <br />&#160;&#160;&#160;&#160;&#160;&#160; 23. <a href="http://www.cnblogs.com/abcdwxc/archive/2007/09/29/910726.html">状态模式(State Pattern)</a></p><br />
<a href="http://www.cnblogs.com/abcdwxc/archive/2007/10/30/942834.html" target="_blank">Terry's Blog</a>]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090907-209.html]]></link><pubdate><![CDATA[2009-9-7 8:25:36]]></pubdate></item><item><title><![CDATA[ZT-一个23设计模式的搞笑解释]]></title><description><![CDATA[This Article is Published by Live Writer。<p><strong>创建型模式     <br />1、FACTORY </strong>—追MM少不了请吃饭了，麦当劳的鸡翅和肯德基的鸡翅都是MM爱吃的东西，虽然口味有所不同，但不管你带MM去麦当劳或肯德基，只管向服务员说“来四个鸡翅”就行了。麦当劳和肯德基就是生产鸡翅的Factory    <br /><strong>工厂模式</strong>：客户类和工厂类分开。消费者任何时候需要某种产品，只需向工厂请求即可。消费者无须修改就可以接纳新产品。缺点是当产品修改时，工厂类也要做相应的修改。如：如何创建及如何向客户端提供。    <br /><strong>2</strong><strong>、BUILDER&#160; </strong>—MM最爱听的就是“我爱你”这句话了，见到不同地方的MM,要能够用她们的方言跟她说这句话哦，我有一个多种语言翻译机，上面每种语言都有一个按键，见到MM我只要按对应的键，它就能够用相应的语言说出“我爱你”这句话了，国外的MM也可以轻松搞掂，这就是我的“我爱你”builder。（这一定比美军在伊拉克用的翻译机好卖）    <br /><strong>建造模式</strong>：将产品的内部表象和产品的生成过程分割开来，从而使一个建造过程生成具有不同的内部表象的产品对象。建造模式使得产品内部表象可以独立的变化，客户不必知道产品内部组成的细节。建造模式可以强制实行一种分步骤进行的建造过程。    <br /><strong>3</strong><strong>、FACTORY METHOD</strong> —请MM去麦当劳吃汉堡，不同的MM有不同的口味，要每个都记住是一件烦人的事情，我一般采用Factory Method模式，带着MM到服务员那儿，说“要一个汉堡”，具体要什么样的汉堡呢，让MM直接跟服务员说就行了。    <br /><strong>工厂方法模式</strong>：核心工厂类不再负责所有产品的创建，而是将具体创建的工作交给子类去做，成为一个抽象工厂角色，仅负责给出具体工厂类必须实现的接口，而不接触哪一个产品类应当被实例化这种细节。    <br /><strong>4</strong><strong>、PROTOTYPE</strong> —跟MM用QQ聊天，一定要说些深情的话语了，我搜集了好多肉麻的情话，需要时只要copy出来放到QQ里面就行了，这就是我的情话prototype了。（100块钱一份，你要不要）    <br /><strong>原始模型模式</strong>：通过给出一个原型对象来指明所要创建的对象的类型，然后用复制这个原型对象的方法创建出更多同类型的对象。原始模型模式允许动态的增加或减少产品类，产品类不需要非得有任何事先确定的等级结构，原始模型模式适用于任何的等级结构。缺点是每一个类都必须配备一个克隆方法。    <br /><strong>5</strong><strong>、SINGLETON</strong> —俺有6个漂亮的老婆，她们的老公都是我，我就是我们家里的老公Sigleton，她们只要说道“老公”，都是指的同一个人，那就是我(刚才做了个梦啦，哪有这么好的事)    <br /><strong>单例模式</strong>：单例模式确保某一个类只有一个实例，而且自行实例化并向整个系统提供这个实例单例模式。单例模式只应在有真正的“单一实例”的需求时才可使用。    <br /><strong>结构型模式 </strong>    <br /><strong>6</strong><strong>、ADAPTER</strong> —在朋友聚会上碰到了一个美女Sarah，从香港来的，可我不会说粤语，她不会说普通话，只好求助于我的朋友kent了，他作为我和Sarah之间的Adapter，让我和Sarah可以相互交谈了(也不知道他会不会耍我)    <br /><strong>适配器模式</strong>：把一个类的接口变换成客户端所期待的另一种接口，从而使原本因接口原因不匹配而无法一起工作的两个类能够一起工作。适配类可以根据参数返还一个合适的实例给客户端。    <br /><strong>7</strong><strong>、BRIDGE </strong>—早上碰到MM，要说早上好，晚上碰到MM，要说晚上好；碰到MM穿了件新衣服，要说你的衣服好漂亮哦，碰到MM新做的发型，要说你的头发好漂亮哦。不要问我“早上碰到MM新做了个发型怎么说”这种问题，自己用BRIDGE组合一下不就行了    <br /><strong>桥梁模式</strong>：将抽象化与实现化脱耦，使得二者可以独立的变化，也就是说将他们之间的强关联变成弱关联，也就是指在一个软件系统的抽象化和实现化之间使用组合/聚合关系而不是继承关系，从而使两者可以独立的变化。    <br /><strong>8</strong><strong>、COMPOSITE</strong> —Mary今天过生日。“我过生日，你要送我一件礼物。”“嗯，好吧，去商店，你自己挑。”“这件T恤挺漂亮，买，这条裙子好看，买，这个包也不错，买。”“喂，买了三件了呀，我只答应送一件礼物的哦。”“什么呀，T恤加裙子加包包，正好配成一套呀，小姐，麻烦你包起来。”“……”，MM都会用Composite模式了，你会了没有？    <br /><strong>合成模式</strong>：合成模式将对象组织到树结构中，可以用来描述整体与部分的关系。合成模式就是一个处理对象的树结构的模式。合成模式把部分与整体的关系用树结构表示出来。合成模式使得客户端把一个个单独的成分对象和由他们复合而成的合成对象同等看待。    <br /><strong>9</strong><strong>、DECORATOR </strong>—Mary过完轮到Sarly过生日，还是不要叫她自己挑了，不然这个月伙食费肯定玩完，拿出我去年在华山顶上照的照片，在背面写上“最好的的礼物，就是爱你的Fita”，再到街上礼品店买了个像框（卖礼品的MM也很漂亮哦），再找隔壁搞美术设计的Mike设计了一个漂亮的盒子装起来……，我们都是Decorator，最终都在修饰我这个人呀，怎么样，看懂了吗？    <br /><strong>装饰模式</strong>：装饰模式以对客户端透明的方式扩展对象的功能，是继承关系的一个替代方案，提供比继承更多的灵活性。动态给一个对象增加功能，这些功能可以再动态的撤消。增加由一些基本功能的排列组合而产生的非常大量的功能。    <br /><strong>10</strong><strong>、FAÇADE</strong> —我有一个专业的Nikon相机，我就喜欢自己手动调光圈、快门，这样照出来的照片才专业，但MM可不懂这些，教了半天也不会。幸好相机有Facade设计模式，把相机调整到自动档，只要对准目标按快门就行了，一切由相机自动调整，这样MM也可以用这个相机给我拍张照片了。    <br /><strong>门面模式</strong>：外部与一个子系统的通信必须通过一个统一的门面对象进行。门面模式提供一个高层次的接口，使得子系统更易于使用。每一个子系统只有一个门面类，而且此门面类只有一个实例，也就是说它是一个单例模式。但整个系统可以有多个门面类。    <br /><strong>11</strong><strong>、FLYWEIGHT</strong> —每天跟MM发短信，手指都累死了，最近买了个新手机，可以把一些常用的句子存在手机里，要用的时候，直接拿出来，在前面加上MM的名字就可以发送了，再不用一个字一个字敲了。共享的句子就是Flyweight，MM的名字就是提取出来的外部特征，根据上下文情况使用。    <br /><strong>享元模式</strong>：FLYWEIGHT在拳击比赛中指最轻量级。享元模式以共享的方式高效的支持大量的细粒度对象。享元模式能做到共享的关键是区分内蕴状态和外蕴状态。内蕴状态存储在享元内部，不会随环境的改变而有所不同。外蕴状态是随环境的改变而改变的。外蕴状态不能影响内蕴状态，它们是相互独立的。将可以共享的状态和不可以共享的状态从常规类中区分开来，将不可以共享的状态从类里剔除出去。客户端不可以直接创建被共享的对象，而应当使用一个工厂对象负责创建被共享的对象。享元模式大幅度的降低内存中对象的数量。    <br /><strong>12</strong><strong>、PROXY </strong>—跟MM在网上聊天，一开头总是“hi,你好”,“你从哪儿来呀？”“你多大了？”“身高多少呀？”这些话，真烦人，写个程序做为我的Proxy吧，凡是接收到这些话都设置好了自动的回答，接收到其他的话时再通知我回答，怎么样，酷吧。    <br /><strong>代理模式</strong>：代理模式给某一个对象提供一个代理对象，并由代理对象控制对源对象的引用。代理就是一个人或一个机构代表另一个人或者一个机构采取行动。某些情况下，客户不想或者不能够直接引用一个对象，代理对象可以在客户和目标对象直接起到中介的作用。客户端分辨不出代理主题对象与真实主题对象。代理模式可以并不知道真正的被代理对象，而仅仅持有一个被代理对象的接口，这时候代理对象不能够创建被代理对象，被代理对象必须有系统的其他角色代为创建并传入。    <br /><strong>行为模式 </strong><strong>     <br /></strong>    <br /><strong>13</strong><strong>、CHAIN OF RESPONSIBLEITY</strong> —晚上去上英语课，为了好开溜坐到了最后一排，哇，前面坐了好几个漂亮的MM哎，找张纸条，写上“Hi,可以做我的女朋友吗？如果不愿意请向前传”，纸条就一个接一个的传上去了，糟糕，传到第一排的MM把纸条传给老师了，听说是个老处女呀，快跑!    <br /><strong>责任链模式</strong>：在责任链模式中，很多对象由每一个对象对其下家的引用而接起来形成一条链。请求在这个链上传递，直到链上的某一个对象决定处理此请求。客户并不知道链上的哪一个对象最终处理这个请求，系统可以在不影响客户端的情况下动态的重新组织链和分配责任。处理者有两个选择：承担责任或者把责任推给下家。一个请求可以最终不被任何接收端对象所接受。    <br /><strong>14</strong><strong>、COMMAND</strong> —俺有一个MM家里管得特别严，没法见面，只好借助于她弟弟在我们俩之间传送信息，她对我有什么指示，就写一张纸条让她弟弟带给我。这不，她弟弟又传送过来一个COMMAND，为了感谢他，我请他吃了碗杂酱面，哪知道他说：“我同时给我姐姐三个男朋友送COMMAND，就数你最小气，才请我吃面。”，    <br /><strong>命令模式</strong>：命令模式把一个请求或者操作封装到一个对象中。命令模式把发出命令的责任和执行命令的责任分割开，委派给不同的对象。命令模式允许请求的一方和发送的一方独立开来，使得请求的一方不必知道接收请求的一方的接口，更不必知道请求是怎么被接收，以及操作是否执行，何时被执行以及是怎么被执行的。系统支持命令的撤消。    <br /><strong>15</strong><strong>、INTERPRETER</strong> —俺有一个《泡MM真经》，上面有各种泡MM的攻略，比如说去吃西餐的步骤、去看电影的方法等等，跟MM约会时，只要做一个Interpreter，照着上面的脚本执行就可以了。    <br /><strong>解释器模式</strong>：给定一个语言后，解释器模式可以定义出其文法的一种表示，并同时提供一个解释器。客户端可以使用这个解释器来解释这个语言中的句子。解释器模式将描述怎样在有了一个简单的文法后，使用模式设计解释这些语句。在解释器模式里面提到的语言是指任何解释器对象能够解释的任何组合。在解释器模式中需要定义一个代表文法的命令类的等级结构，也就是一系列的组合规则。每一个命令对象都有一个解释方法，代表对命令对象的解释。命令对象的等级结构中的对象的任何排列组合都是一个语言。    <br /><strong>16</strong><strong>、ITERATOR</strong> —我爱上了Mary，不顾一切的向她求婚。    <br />&#160;&#160; Mary：“想要我跟你结婚，得答应我的条件”    <br />&#160;&#160; 我：“什么条件我都答应，你说吧”    <br />&#160;&#160; Mary：“我看上了那个一克拉的钻石”    <br />&#160;&#160; 我：“我买，我买，还有吗？”    <br />&#160;&#160; Mary：“我看上了湖边的那栋别墅”    <br />&#160;&#160; 我：“我买，我买，还有吗？”    <br />&#160;&#160; Mary：“你的小弟弟必须要有50cm长”    <br />&#160;&#160; 我脑袋嗡的一声，坐在椅子上，一咬牙：“我剪，我剪，还有吗？”    <br />&#160;&#160; ……    <br /><strong>迭代子模式</strong>：迭代子模式可以顺序访问一个聚集中的元素而不必暴露聚集的内部表象。多个对象聚在一起形成的总体称之为聚集，聚集对象是能够包容一组对象的容器对象。迭代子模式将迭代逻辑封装到一个独立的子对象中，从而与聚集本身隔开。迭代子模式简化了聚集的界面。每一个聚集对象都可以有一个或一个以上的迭代子对象，每一个迭代子的迭代状态可以是彼此独立的。迭代算法可以独立于聚集角色变化。    <br /><strong>17</strong><strong>、MEDIATOR</strong><strong> </strong>—四个MM打麻将，相互之间谁应该给谁多少钱算不清楚了，幸亏当时我在旁边，按照各自的筹码数算钱，赚了钱的从我这里拿，赔了钱的也付给我，一切就OK啦，俺得到了四个MM的电话。    <br /><strong>调停者模式</strong>：调停者模式包装了一系列对象相互作用的方式，使得这些对象不必相互明显作用。从而使他们可以松散偶合。当某些对象之间的作用发生改变时，不会立即影响其他的一些对象之间的作用。保证这些作用可以彼此独立的变化。调停者模式将多对多的相互作用转化为一对多的相互作用。调停者模式将对象的行为和协作抽象化，把对象在小尺度的行为上与其他对象的相互作用分开处理。    <br /><strong>18</strong><strong>、MEMENTO</strong> —同时跟几个MM聊天时，一定要记清楚刚才跟MM说了些什么话，不然MM发现了会不高兴的哦，幸亏我有个备忘录，刚才与哪个MM说了什么话我都拷贝一份放到备忘录里面保存，这样可以随时察看以前的记录啦。    <br /><strong>备忘录模式</strong>：备忘录对象是一个用来存储另外一个对象内部状态的快照的对象。备忘录模式的用意是在不破坏封装的条件下，将一个对象的状态捉住，并外部化，存储起来，从而可以在将来合适的时候把这个对象还原到存储起来的状态。    <br /><strong>19</strong><strong>、OBSERVER</strong>&#160;&#160; —想知道咱们公司最新MM情报吗？加入公司的MM情报邮件组就行了，tom负责搜集情报，他发现的新情报不用一个一个通知我们，直接发布给邮件组，我们作为订阅者（观察者）就可以及时收到情报啦    <br /><strong>观察者模式</strong>：观察者模式定义了一种一队多的依赖关系，让多个观察者对象同时监听某一个主题对象。这个主题对象在状态上发生变化时，会通知所有观察者对象，使他们能够自动更新自己。    <br /><strong>20</strong><strong>、STATE</strong> —跟MM交往时，一定要注意她的状态哦，在不同的状态时她的行为会有不同，比如你约她今天晚上去看电影，对你没兴趣的MM就会说“有事情啦”，对你不讨厌但还没喜欢上的MM就会说“好啊，不过可以带上我同事么？”，已经喜欢上你的MM就会说“几点钟？看完电影再去泡吧怎么样？”，当然你看电影过程中表现良好的话，也可以把MM的状态从不讨厌不喜欢变成喜欢哦。    <br /><strong>状态模式</strong>：状态模式允许一个对象在其内部状态改变的时候改变行为。这个对象看上去象是改变了它的类一样。状态模式把所研究的对象的行为包装在不同的状态对象里，每一个状态对象都属于一个抽象状态类的一个子类。状态模式的意图是让一个对象在其内部状态改变的时候，其行为也随之改变。状态模式需要对每一个系统可能取得的状态创立一个状态类的子类。当系统的状态变化时，系统便改变所选的子类。    <br /><strong>21</strong><strong>、STRATEGY</strong> —跟不同类型的MM约会，要用不同的策略，有的请电影比较好，有的则去吃小吃效果不错，有的去海边浪漫最合适，单目的都是为了得到MM的芳心，我的追MM锦囊中有好多Strategy哦。    <br /><strong>策略模式</strong>：策略模式针对一组算法，将每一个算法封装到具有共同接口的独立的类中，从而使得它们可以相互替换。策略模式使得算法可以在不影响到客户端的情况下发生变化。策略模式把行为和环境分开。环境类负责维持和查询行为类，各种算法在具体的策略类中提供。由于算法和环境独立开来，算法的增减，修改都不会影响到环境和客户端。    <br /><strong>22</strong><strong>、TEMPLATE METHOD</strong> ——看过《如何说服女生上床》这部经典文章吗？女生从认识到上床的不变的步骤分为巧遇、打破僵局、展开追求、接吻、前戏、动手、爱抚、进去八大步骤(Template method)，但每个步骤针对不同的情况，都有不一样的做法，这就要看你随机应变啦(具体实现)；    <br /><strong>模板方法模式</strong>：模板方法模式准备一个抽象类，将部分逻辑以具体方法以及具体构造子的形式实现，然后声明一些抽象方法来迫使子类实现剩余的逻辑。不同的子类可以以不同的方式实现这些抽象方法，从而对剩余的逻辑有不同的实现。先制定一个顶级逻辑框架，而将逻辑的细节留给具体的子类去实现。    <br /><strong>23</strong><strong>、VISITOR</strong> —情人节到了，要给每个MM送一束鲜花和一张卡片，可是每个MM送的花都要针对她个人的特点，每张卡片也要根据个人的特点来挑，我一个人哪搞得清楚，还是找花店老板和礼品店老板做一下Visitor，让花店老板根据MM的特点选一束花，让礼品店老板也根据每个人特点选一张卡，这样就轻松多了；    <br /><strong>访问者模式</strong>：访问者模式的目的是封装一些施加于某种数据结构元素之上的操作。一旦这些操作需要修改的话，接受这个操作的数据结构可以保持不变。访问者模式适用于数据结构相对未定的系统，它把数据结构和作用于结构上的操作之间的耦合解脱开，使得操作集合可以相对自由的演化。访问者模式使得增加新的操作变的很容易，就是增加一个新的访问者类。访问者模式将有关的行为集中到一个访问者对象中，而不是分散到一个个的节点类中。当使用访问者模式时，要将尽可能多的对象浏览逻辑放在访问者类中，而不是放到它的子类中。访问者模式可以跨过几个类的等级结构访问属于不同的等级结构的成员类。</p>  <p>转自:<a href="http://tianshi0253.javaeye.com/blog/230088" target="_blank">tianshi0253's Blog</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090907-208.html]]></link><pubdate><![CDATA[2009-9-7 8:23:26]]></pubdate></item><item><title><![CDATA[ZT-委托和事件之总结篇]]></title><description><![CDATA[This Article is Published by Live Writer。<p>通过参考委托和事件的定义规范我们总结出这么几条：</p>  <p>&#160;&#160;&#160;&#160; (1)事件委托名称应以 EventHandler 结尾。   <br />&#160;&#160;&#160;&#160; (2)事件委托应该有两个参数：    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 第一个是 object 类型的 sender，代表发出事件通知的对象。    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 第二个参数 e，应该是 EventArgs 或其派生类型。    <br />&#160;&#160;&#160; （3）事件参数类型，应从 EventArgs 继承，名称应以 EventArgs 结尾。应将所有想通过事件传达到外界的信息都放在事件参数 e 中。    <br />&#160;&#160;&#160;&#160; (4)应该为每个事件提供一个 protected&#160; virtual的 OnXxxx 方法：方法名称为 On 加上事件的名称；只有一个事件参数 e；    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; 并在该方法中进行 null 判断。 在需要发出事件通知的地方，调用OnXxxx 方法。</p>  <p><a href="http://www.cnblogs.com/tenghoo/archive/2009/08/04/mom_baby_and_you.html" target="_blank">也谈事件---Mom,Baby and you[一,二,三]</a></p>  <p><a href="http://msdn.microsoft.com/zh-cn/library/wkzf914z(VS.80).aspx" target="_blank">.NET Framework 开发人员指南</a></p>
]]></description><author><![CDATA[Jack]]></author><link><![CDATA[http://www.dongpad.com/CSharp-20090804-207.html]]></link><pubdate><![CDATA[2009-8-4 14:48:09]]></pubdate></item></channel></rss>