﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-小蟒蛇IronPython </title><link>http://ipy.cnblogs.com</link><description>关注IronPython的快乐团队</description><language>zh-cn</language><lastBuildDate>Tue, 08 Jul 2008 21:22:02 GMT</lastBuildDate><pubDate>Tue, 08 Jul 2008 21:22:02 GMT</pubDate><ttl>60</ttl><item><title>[翻译]修改 .NET 对象使其在 IronPython 中表现出动态性（属性注入）</title><link>http://www.cnblogs.com/RChen/archive/2008/04/14/1151899.html</link><dc:creator>木野狐(Neil Chen)</dc:creator><author>木野狐(Neil Chen)</author><pubDate>Sun, 13 Apr 2008 19:24:00 GMT</pubDate><guid>http://www.cnblogs.com/RChen/archive/2008/04/14/1151899.html</guid><description><![CDATA[<p><font color="#0000ff">原文：</font><a href="http://blogs.msdn.com/srivatsn/comments/8383517.aspx"><font color="#0000ff">http://blogs.msdn.com/srivatsn/comments/8383517.aspx</font></a><br></p>
<h2>修改 .NET 对象使其在 IronPython 中表现出动态性<br></h2>
<p><br>假设你要和一个 .NET 的库进行互操作，但同时你又想让它表现的像动态语言中的对象那样，你想动态的给对象添加/删除方法或属性。在 python 中你可以这样写：<br></p>
<blockquote><pre class="code"><span style="color: blue;">class </span>x(object):
    <span style="color: blue;">pass

</span>y = x()
y.z = 42
dir(y)</pre></blockquote>
<p>这样 dir(y) 就会包含 z. 如果 x 是 .NET 类而不是一个 python 类呢，能做到这一点吗？让我们尝试一个简单的 .NET 类：<br></p><blockquote><pre class="code"><span style="color: blue;">public class </span><span style="color: rgb(43, 145, 175);">TestExt
</span>{
}<br></pre></blockquote>
<p>在 IronPython 中你可以这样:<br></p>
<blockquote><pre class="code"><span style="color: blue;">import </span>clr
clr.AddReference(<span style="color: maroon;">"TestExtensions.dll"</span>)
<span style="color: blue;">from </span>TestExtensions <span style="color: blue;">import </span>TestExt
y = TestExt()
y.z = 42</pre></blockquote>
<p><br>但这个代码会抛出 AttributeError，提示 'TestExt' 不存在属性 'z'。现在该怎么办呢？这正是 DLR 的扩展机制所要做的。有5个方法可以让 .NET 类来实现，这些方法可以对 binder 显示特殊含义，它们是：<br></p>
<ul>
<li><font color="#0000ff"><b>GetCustomMember</b>&nbsp;<font color="#000000">– 在常规的 .NET 查找前执行</font> 
</font></li><li><font color="#0000ff"><b>GetBoundMember</b>&nbsp;<font color="#000000">– 在常规的 .NET 查找后执行</font> 
</font></li><li><font color="#0000ff"><b>SetMember</b>&nbsp;<font color="#000000">– 在常规的 .NET 成员赋值前执行</font> 
</font></li><li><font color="#0000ff"><b>SetMemberAfter</b>&nbsp;<font color="#000000">– 在常规的 .NET 成员赋值后执行</font> 
</font></li><li><font color="#0000ff"><b>DeleteMember</b>&nbsp;<font color="#000000">– 在常规的 .NET 操作符访问之前执行（没有对应的 .NET 版本 —— 因此是唯一的一个）</font></font></li></ul>
<p>.NET 类可以实现这些函数，并用 <a href="http://msdn2.microsoft.com/en-us/library/system.runtime.compilerservices.specialnameattribute%28VS.80%29.aspx"><font color="#0000ff">SpecialName 特性</font></a> 来标注它们。现在绑定规则可以在常规 .NET 绑定的前后，调用 Getter/Setter. GetCustomMember/SetMember 首先被调用，并且，如果它返回一个值，则会被当作成员查找的返回值。这就可以覆盖任意可能存在的 .NET 成员。但如果你从该函数中返回 OperationFailed.Value，就会按常规方法继续进行查找。GetBoundMember/SetMemberAfter 在常规调用失败的时候会被调用到 —— ‘失败’表示不存在要绑定到的名字的成员。记住这些，我们来修改一下 .NET 类，向其中添加一些东西：</p>
<blockquote><pre class="code"><span style="color: rgb(43, 145, 175);">Dictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">object</span>&gt; dict = <span style="color: blue;">new </span><span style="color: rgb(43, 145, 175);">Dictionary</span>&lt;<span style="color: blue;">string</span>, <span style="color: blue;">object</span>&gt;();
[<span style="color: rgb(43, 145, 175);">SpecialName</span>]
<span style="color: blue;">public object </span>GetBoundMember(<span style="color: blue;">string </span>name)
{
    <span style="color: blue;">if </span>(dict.ContainsKey(name))
        <span style="color: blue;">return </span>dict[name];
    <span style="color: blue;">else
        return </span><span style="color: rgb(43, 145, 175);">OperationFailed</span>.Value;
}

[<span style="color: rgb(43, 145, 175);">SpecialName</span>]
<span style="color: blue;">public void </span>SetMemberAfter(<span style="color: blue;">string </span>methodName, <span style="color: blue;">object </span>o)
{
    dict.Add(methodName, o);
}</pre></blockquote>


<p>现在如果我尝试 y.z = 42, 代码会成功运行。同样我可以把 y.z 设定为一个函数，这样就可以调用 y.z() 了。换一种方法，我也可以重写 GetCustomMember 和 SetMember 方法来实现，例子一样有效，因为如果在 dict 中查找不到成员就会返回 OperationFailed.Value. 但这会带来一个负担，就是会影响到所有 .NET 成员的查找过程。<br><br>SetMember 函数可以返回 bool 而不是 void. 如果返回 bool 值，这个返回值会控制是否继续进行绑定查找。<br><br>那么，这个特性的作用是什么？我为什么要用它呢？假设我们要写一个类似下面 xml 所表示的对象模型：<br></p><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">foo</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">bar</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">baz</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">bar</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">foo</span><span style="color: rgb(0, 0, 255);">&gt;</span></div><br><br>我想通过 foo.bar 访问这个 xml，并且取得的值应该是 baz. 要实现这个功能，只要给 .NET 的 XmlElement 类添加 GetBoundMember 方法，该方法去进行查找，并返回一个 XmlElement. 或者，还可以给 XmlElement 加一个扩展方法。但是扩展方法并不出现在反射的结果中，所以在 IronPython 中目前还没有这个支持。好在有一个避开的办法：可以用 ExtensionType 特性去修饰一个 assembly，该特性指出你要去扩展哪个类型，用哪个类来扩展。然后，你需要注册一次这个 assembly，以使这些方法被注入到合适的地方去。以后也许会修改为其他更好的实现方法，但目前而言，这个办法是可用的。下面就是你需要实现的代码：<br><p><br> 
</p><blockquote><pre class="code">[<span style="color: blue;">assembly</span>: <span style="color: rgb(43, 145, 175);">ExtensionType</span>(<span style="color: blue;">typeof</span>(System.Xml.<span style="color: rgb(43, 145, 175);">XmlElement</span>), <span style="color: blue;">typeof</span>(TestExtensions.<span style="color: rgb(43, 145, 175);">ExtClass</span>.<span style="color: rgb(43, 145, 175);">XmlElementExtension</span>))]
<span style="color: blue;">namespace </span>TestExtensions
{    
    <span style="color: blue;">public class </span><span style="color: rgb(43, 145, 175);">ExtClass
    </span>{
        <span style="color: blue;">static </span>ExtClass()
        {
            Microsoft.Scripting.Runtime.<span style="color: rgb(43, 145, 175);">RuntimeHelpers</span>.RegisterAssembly(<span style="color: blue;">typeof</span>(<span style="color: rgb(43, 145, 175);">ExtClass</span>).Assembly);
        }

        <span style="color: blue;">public static </span><span style="color: rgb(43, 145, 175);">XmlElement </span>Load(<span style="color: blue;">string </span>fileName)
        {
            <span style="color: rgb(43, 145, 175);">XmlDocument </span>doc = <span style="color: blue;">new </span><span style="color: rgb(43, 145, 175);">XmlDocument</span>();
            doc.Load(fileName);
            <span style="color: blue;">return </span>doc.DocumentElement;
        }
        <span style="color: blue;">public static class </span><span style="color: rgb(43, 145, 175);">XmlElementExtension
        </span>{
            [<span style="color: rgb(43, 145, 175);">SpecialName</span>]
            <span style="color: blue;">public static object </span>GetCustomMember(<span style="color: blue;">object </span>myObj, <span style="color: blue;">string </span>name)
            {
                <span style="color: rgb(43, 145, 175);">XmlElement </span>xml = myObj <span style="color: blue;">as </span><span style="color: rgb(43, 145, 175);">XmlElement</span>;

                <span style="color: blue;">if </span>(xml != <span style="color: blue;">null</span>)
                {
                    <span style="color: blue;">for </span>(<span style="color: rgb(43, 145, 175);">XmlNode </span>n = xml.FirstChild; n != <span style="color: blue;">null</span>; n = n.NextSibling)
                    {
                        <span style="color: blue;">if </span>(n <span style="color: blue;">is </span><span style="color: rgb(43, 145, 175);">XmlElement </span>&amp;&amp; <span style="color: blue;">string</span>.CompareOrdinal(n.Name, name) == 0)
                        {
                            <span style="color: blue;">if </span>(n.HasChildNodes &amp;&amp; n.FirstChild == n.LastChild &amp;&amp; n.FirstChild <span style="color: blue;">is </span><span style="color: rgb(43, 145, 175);">XmlText</span>)
                            {
                                <span style="color: blue;">return </span>n.InnerText;
                            }
                            <span style="color: blue;">else
                            </span>{
                                <span style="color: blue;">return </span>n;
                            }

                        }
                    }
                }
                <span style="color: blue;">return </span><span style="color: rgb(43, 145, 175);">OperationFailed</span>.Value;
            }
        }
    }
}
</pre></blockquote><a href="http://11011.net/software/vspaste"></a>
<p>现在，在 IronPython 中可以这样写：<br> 
</p><blockquote><pre class="code"><span style="color: blue;">import </span>clr
clr.AddReference(<span style="color: maroon;">"TestExtensions.dll"</span>)
<span style="color: blue;">from </span>TestExtensions <span style="color: blue;">import </span>ExtClass
foo = ExtClass.Load(<span style="color: maroon;">"test.xml"</span>)
<span style="color: blue;">print </span>foo.bar</pre></blockquote>结果会输出 "baz".<br><br> 
<div class="postfoot">Published Saturday, April 12, 2008 3:16 AM by <a id="ctl00___ctl00___ctl01___Entry___AuthorLink" href="http://blogs.msdn.com/user/Profile.aspx?UserID=10699">srivatsn</a> <br></div><img src ="http://ipy.cnblogs.comaggbug/1151899.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37581/" target="_blank">[新闻]校内网宣布开放平台 陈一舟称将优先推招聘服务</a>]]></description></item><item><title>在Silverlight 2 beta1中使用IronPython等动态语言</title><link>http://www.cnblogs.com/redmoon/archive/2008/03/08/1096331.html</link><dc:creator>redmoon</dc:creator><author>redmoon</author><pubDate>Sat, 08 Mar 2008 03:37:00 GMT</pubDate><guid>http://www.cnblogs.com/redmoon/archive/2008/03/08/1096331.html</guid><description><![CDATA[<p>目前在Silverlight Tools Beta 1 for Visual Studio 2008 中包括了3个动态语言的运行库：IronPython、IronRuby和Managed JScript。</p>
<p>但是VS2008针对这三个动态语言的模板还没有完成，所以现在我们没有办法创建动态语言的Silverlight 2项目（甚至于VB的都不行，默认只是C#的）；不过Silverlight 2 SDK提供了一个工具来帮助我们生成部署的xap文件——Chiron工具，它在目录：C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Tools\Chiron里。</p>
<p>另外，在CodePlex上还提供了一个<a href="http://www.codeplex.com/dynamicsilverlight" target="_blank">Dynamic Silverlight Sample</a>的项目，来指导我们在Silverlight 2中使用动态语言，不过目前这个项目还是针对Silverlight 1.1的。</p>
<p>下面我就给大家演示一下（以IronPython为例）：</p>
<ul>
    <li>创建一个目录，如IPSL2，在里面创建2个子目录：app（包含动态语言代码文件和XAML文件文件）和assets（包含资源文件，如图片等）；在assets中在创建一个子目录js（这个目录其实可以不要，在1.1中是用于保存silverlight.js的，不过现在可以保存其他js文件）。
    <li>在app目录中创建一个IronPython代码文件：app.py，代码如下（在这里，我是使用XamlReader.Load把xaml字符串直接加载，本来我想用Application.Current.LoadRootVisual方法把app.xaml载入，但是一直没有成功，有朋友知道怎么弄吗？）：</li>
</ul>
<blockquote>
<p>from System.Windows import Application<br />
from System.Windows.Markup import XamlReader
<p>Application.Current.RootVisual = XamlReader.Load("""<br />
&lt;Canvas xmlns="<a href="http://schemas.microsoft.com/client/2007%22" href_cetemp='http://schemas.microsoft.com/client/2007"'>http://schemas.microsoft.com/client/2007"</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns:x="<a href="http://schemas.microsoft.com/winfx/2006/xaml%22" href_cetemp='http://schemas.microsoft.com/winfx/2006/xaml"'>http://schemas.microsoft.com/winfx/2006/xaml"</a>&gt;
<p>&nbsp;&nbsp;&nbsp; &lt;TextBlock x:Name="message" FontSize="30"/&gt;
<p>&lt;/Canvas&gt;""")
<p>Application.Current.RootVisual.message.Text="Welcome to Silverlight and IronPython!"</p>
</blockquote>
<ul>
    <li>在app目录中创建一个xaml代码文件：app.xaml（在我的例子中，可以不要这个文件，但是如果使用LoadRootVisual方法的话，就需要），代码如下：</li>
</ul>
<blockquote>
<p>&lt;Canvas xmlns="<a href="http://schemas.microsoft.com/client/2007%22" href_cetemp='http://schemas.microsoft.com/client/2007"'>http://schemas.microsoft.com/client/2007"</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xmlns:x="<a href="http://schemas.microsoft.com/winfx/2006/xaml%22" href_cetemp='http://schemas.microsoft.com/winfx/2006/xaml"'>http://schemas.microsoft.com/winfx/2006/xaml"</a>&gt;
<p>&nbsp;&nbsp;&nbsp; &lt;TextBlock x:Name="message" FontSize="30"/&gt;
<p>&lt;/Canvas&gt; </p>
</blockquote>
<ul>
    <li>在根目录中，本例即IPSL2目录中，创建一个Index.html文件来作为浏览页面，body中的代码如下（解释一下，我这里为什么要用图片的原因，这是因为在Windows Live Writer中贴入一下代码后，就在其中显示一个Silverlight的控件了，真是的！）：</li>
</ul>
<blockquote><!-- Runtime errors from Silverlight will be displayed here.
	This will contain debugging information and should be removed or hidden when debugging is completed -->
<div id="errorLocation" style="font-size: small; color: gray"></div>
<div id="errorLocation" style="font-size: small; color: gray"></div>
<div id="errorLocation" style="font-size: small; color: gray"></div>
<div id="silverlightControlHost"><a href="http://www.cnblogs.com/images/cnblogs_com/redmoon/WindowsLiveWriter/Silverlight2IronPython_14FAC/image_2.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="216" alt="image" src="http://www.cnblogs.com/images/cnblogs_com/redmoon/WindowsLiveWriter/Silverlight2IronPython_14FAC/image_thumb.png" width="644" border="0" /></a> <iframe style="border-top-width: 0px; border-left-width: 0px; visibility: hidden; border-bottom-width: 0px; width: 0px; height: 0px; border-right-width: 0px"></iframe></div>
</blockquote>
<ul>
    <li><font face="Courier New">现在开始使用Chrion工具来运行这个动态语言Silverlight 2应用程序了。</font>
    <li><font face="Courier New">首先，把Chrion所在的目录添加到PATH中</font>
    <li><font face="Courier New">启动命令行，进入到IPSL2目录中，运行Chrion /b来启动一个Web Server，并同时打开一个浏览器</font>
    <li><font face="Courier New">在浏览器中点index.html文件，就可以看到Silverlight over IronPython的应用程序运行了，如下图：</font></li>
</ul>
<blockquote>
<p><a href="http://www.cnblogs.com/images/cnblogs_com/redmoon/WindowsLiveWriter/Silverlight2IronPython_14FAC/image_4.png"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="197" alt="image" src="http://www.cnblogs.com/images/cnblogs_com/redmoon/WindowsLiveWriter/Silverlight2IronPython_14FAC/image_thumb_1.png" width="644" border="0" /></a> </p>
</blockquote>
<p>另外对于使用IronRuby的同学来说，可以参考John Lam的文章（注：下面我给的连接是通过Web代理访问，直接是访问不了的）：</p>
<p><a href="http://proxmate.com/?__proxy_url=aHR0cDovL3d3dy5pdW5rbm93bi5jb20vMjAwOC8wMy9keW5hbWljLXNpbHZlcmwuaHRtbA==&amp;" target="_blank">John Lam on Software Dynamic Silverlight Part 1 Hello, World!</a></p>
<p><a href="http://proxmate.com/?__proxy_url=aHR0cDovL3d3dy5pdW5rbm93bi5jb20vMjAwOC8wMy9keW5hbWljLXNpbHZlLTEuaHRtbA==" target="_blank">John Lam on Software Dynamic Silverlight Part 2 Managed JScript and flickr</a></p>
<p dir="ltr" style="margin-right: 0px">整个示例的代码在这里下载：<a title="http://www.91files.com/?GXW6W7RN1L2N1N358LJC" href="http://www.91files.com/?GXW6W7RN1L2N1N358LJC">http://www.91files.com/?GXW6W7RN1L2N1N358LJC</a><br />
<br />
Update!<br />
对于app.py和app.xaml得到思归的提醒，可以使用如下代码（其实一下代码，我昨晚也尝试过，结果没有成功，简直晕死！）：<br />
app.py：<br />
============<br />
<font face="Verdana">from System.Windows import Application<br />
from System.Windows.Controls import UserControl<br />
<br />
Application.Current.LoadRootVisual(UserControl(), 'app.xaml')</font></p>
<p dir="ltr" style="margin-right: 0px"><font face="Verdana">Application.Current.RootVisual.message.Text="Welcome to Silverlight and IronPython!"<br />
============<br />
app.xaml：<br />
============<br />
<font face="Verdana">&lt;UserControl<br />
&nbsp;&nbsp; xmlns="http://schemas.microsoft.com/client/2007"<br />
&nbsp;&nbsp; xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
&nbsp;&nbsp; x:Class="System.Windows.Controls.UserControl"<br />
&nbsp;&nbsp; x:Name="Page"&nbsp;&gt;<br />
<br />
&nbsp;&nbsp;&nbsp; &lt;TextBlock x:Name="message" FontSize="30"/&gt; </font></p>
<p><font face="Verdana">&lt;/UserControl&gt; <br />
============</font></p>
</font>
<img src ="http://ipy.cnblogs.comaggbug/1096331.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37580/" target="_blank">[新闻]七月开发语言排行榜出炉 PowerShell有望成为年度黑马</a>]]></description></item><item><title>IronPython 目前的状态</title><link>http://www.cnblogs.com/RChen/archive/2008/01/30/1059112.html</link><dc:creator>木野狐(Neil Chen)</dc:creator><author>木野狐(Neil Chen)</author><pubDate>Wed, 30 Jan 2008 11:52:00 GMT</pubDate><guid>http://www.cnblogs.com/RChen/archive/2008/01/30/1059112.html</guid><description><![CDATA[<div align="left">IronPython 这几天刚发布了两个新的版本，一个是去年发布的 1.1 的升级和修正版：1.1.1, 在这里下载：<br><a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&amp;ReleaseId=5141">http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&amp;ReleaseId=5141</a><br><br>另一个，则是基于 DLR 的 2.0 alpha 8:<br><a href="http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&amp;ReleaseId=9219">http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&amp;ReleaseId=9219</a><br><br>IronPython 2.0 alpha 8 是第一个包含了 VS 2008 solution 文件的发布版本。<br><br>目前，正式的开发还是使用 1.1.1 比较好，如果想研究 DLR 的相关实现细节，可以研究 2.0 alpha 8 的代码。<br><br></div><img src ="http://ipy.cnblogs.comaggbug/1059112.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37579/" target="_blank">[新闻]阿里巴巴软肋明显 网盛携低会员价细分B2B市场</a>]]></description></item><item><title>推荐IronPython开发IDE： IronPython Studio</title><link>http://www.cnblogs.com/Terrylee/archive/2007/12/13/ironpython-studio-ide-overview.html</link><dc:creator>TerryLee</dc:creator><author>TerryLee</author><pubDate>Thu, 13 Dec 2007 11:04:00 GMT</pubDate><guid>http://www.cnblogs.com/Terrylee/archive/2007/12/13/ironpython-studio-ide-overview.html</guid><description><![CDATA[摘要: IronPython是运行于.Net上的给予DLR的Python开发语言，目前最新的版本是2.0 Alpha 6，IronPython Studio是一个强大的开发IronPython的IDE，它基于Visual Studio 2008 Shell开发，并且完全开源。在IronPython Studio中不仅可以使用IronPython开发Windows应用，还可以开发WPF应用，现在最新版本是December 2007 CTP。对于IronPython爱好者来说，这的确是一个喜讯；对于非IronPython爱好者来说，也可以把它当作一个学习Visual Studio 2008 Shell的示例项目。&nbsp;&nbsp;<a href='http://www.cnblogs.com/Terrylee/archive/2007/12/13/ironpython-studio-ide-overview.html'>阅读全文</a><img src ="http://ipy.cnblogs.comaggbug/994015.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37577/" target="_blank">[新闻]Google七年51次收购盘点:从搜索走向云计算</a>]]></description></item><item><title>IronPython 2.0 Alpha3 发布了</title><link>http://www.cnblogs.com/shanyou/archive/2007/08/03/842282.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Fri, 03 Aug 2007 13:04:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/08/03/842282.html</guid><description><![CDATA[<P>IronPython是运行于.Net上的给予DLR的Python开发语言,CodePlex 2007年7月27日正式发布了2.0 Alpha 3版本.安装IronPython前,您必须确认已经安装了.Net 2.0如果您已经安装了Microsoft Visual Studio 2005,则不需再次安装.Net Framework.</P>
<P>&nbsp;<A href="http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=3749">Download IronPython v2.0 Alpha 3</A><BR><BR>Note: Due to dependencies upon APIs that are not present in Silverlight 1.1 Alpha (released at MIX) you won’t be able to re-build this release for use with Silverlight. As both products stabilize more we expect better compatibility between releases.<BR></P><img src ="http://ipy.cnblogs.comaggbug/842282.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37576/" target="_blank">[新闻]微软即将推出中文版Expression 2开发工具</a>]]></description></item><item><title>IronRuby 发布第一个版本</title><link>http://www.cnblogs.com/shanyou/archive/2007/07/25/830188.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Tue, 24 Jul 2007 23:52:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/07/25/830188.html</guid><description><![CDATA[微软的<A href="http://www.iunknown.com/">John Lam</A>发布了IronRuby <A href="http://www.iunknown.com/2007/07/a-first-look-at.html">first preview</A> ，使用微软的开源协议MS-Pl （<A id=CategoryEntryList1_EntryStoryList_Entries_ctl21_TitleUrl href="/shanyou/archive/2007/05/05/736691.html">Microsoft 的 OpenSource Licence</A>）。这个版本的代码也是基于DLR构建的，也可以运行于Mono平台，不过Mono需要从SVN中拉代码来编译，才能运行它。详细信息参见Miguel de Icaza's的blog：<A href="http://tirania.org/blog/archive/2007/Jul-23-1.html">http://tirania.org/blog/archive/2007/Jul-23-1.html</A> <img src ="http://ipy.cnblogs.comaggbug/830188.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37575/" target="_blank">[新闻]Google公布内部数据语言 速度比XML快100倍</a>]]></description></item><item><title>在 IronPython for ASP.NET 中改写 print 以方便调试</title><link>http://www.cnblogs.com/RChen/archive/2007/07/16/ipy_aspnet_print.html</link><dc:creator>木野狐</dc:creator><author>木野狐</author><pubDate>Mon, 16 Jul 2007 03:29:00 GMT</pubDate><guid>http://www.cnblogs.com/RChen/archive/2007/07/16/ipy_aspnet_print.html</guid><description><![CDATA[python 语言中最方便的莫过于 print 语句，搭配 dir() 等函数，能随时查看对象的属性，内容等。而 IronPython for ASP.NET 的环境下 print 是不会显示出来的。用下面的办法，可以改写输出流到 web 页面上。<br><br>先在 App_Script 目录下建立一个 debug.py，内容如下：<br><br><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 0);">#</span><span style="color: rgb(0, 128, 0);">coding:utf-8</span><span style="color: rgb(0, 128, 0);"><br></span><span style="color: rgb(0, 0, 0);"><br></span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;sys<br></span><span style="color: rgb(0, 0, 255);">from</span><span style="color: rgb(0, 0, 0);">&nbsp;System.Web&nbsp;</span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;HttpContext<br><br></span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;Log(object):<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">def</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">__init__</span><span style="color: rgb(0, 0, 0);">(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.response&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;HttpContext.Current.Response<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">def</span><span style="color: rgb(0, 0, 0);">&nbsp;write(self,&nbsp;data):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.response.Write(data)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br></span><span style="color: rgb(0, 0, 255);">def</span><span style="color: rgb(0, 0, 0);">&nbsp;start_debug():<br>&nbsp;&nbsp;&nbsp;&nbsp;sys.stdout&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;Log()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br></span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 128);">__name__</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">'</span><span style="color: rgb(128, 0, 0);">__main__</span><span style="color: rgb(128, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">:<br>&nbsp;&nbsp;&nbsp;&nbsp;start_debug()<br>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">print</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(128, 0, 0);">test</span><span style="color: rgb(128, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><br>&nbsp;&nbsp;&nbsp;&nbsp;</span></div><br>这样就把输出流重定向到了 Response.Write 上。<br>在具体页面中，这样调用：<br><br><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);">&nbsp;debug<br>debug.start_debug()<br></span><span style="color: rgb(0, 0, 255);">print</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(128, 0, 0);">'</span><span style="color: rgb(128, 0, 0);">测试输出</span><span style="color: rgb(128, 0, 0);">'</span><span style="color: rgb(0, 0, 0);"><br></span></div><br>输出结果会在网页上显示出来。<br><br><img src ="http://ipy.cnblogs.comaggbug/819567.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37574/" target="_blank">[新闻]互联网站总量已达1.72亿</a>]]></description></item><item><title>IronPython 2.0 Alpha2</title><link>http://www.cnblogs.com/shanyou/archive/2007/07/08/810198.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Sun, 08 Jul 2007 05:39:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/07/08/810198.html</guid><description><![CDATA[<P>IronPython是运行于.Net上的给予DLR的Python开发语言,CodePlex 2007年6月30日正式发布了2.0 Alpha 2版本.安装IronPython前,您必须确认已经安装了.Net 2.0如果您已经安装了Microsoft Visual Studio 2005,则不需再次安装.Net Framework.</P>
<P><IMG alt="" src="http://www.cnbeta.com/articles/pic/down.gif"><STRONG>下载:</STRONG><A href="http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=5246" target=_blank>IronPython 2.0 Alpha2</A> <BR><BR>Note: Due to dependencies upon APIs that are not present in Silverlight 1.1 Alpha (released at MIX) you won’t be able to re-build this release for use with Silverlight. As both products stabilize more we expect better compatibility between releases.<BR></P><img src ="http://ipy.cnblogs.comaggbug/810198.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37573/" target="_blank">[新闻]博客园发布Windows Embedded专题 征文比赛开始</a>]]></description></item><item><title>微软在动态语言支持上超越了Java？</title><link>http://www.cnblogs.com/shanyou/archive/2007/07/02/803572.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Mon, 02 Jul 2007 13:07:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/07/02/803572.html</guid><description><![CDATA[摘要: 微软在宣布了动态语言运行时（Dynamic Language Runtime，DLR）之后，到处都开始沸沸扬扬起来，Java领域也不能幸免。有不少人看起来已经相信，DLR使得.NET平台在和JVM的大比拼中先胜一筹了，原因是DLR已经解决了许多Java才刚刚开始意识到的问题。现在让我们一起来审视一下对动态语言支持的现状，以及和DLR的对比。<br>&nbsp;&nbsp;<a href='http://www.cnblogs.com/shanyou/archive/2007/07/02/803572.html'>阅读全文</a><img src ="http://ipy.cnblogs.comaggbug/803572.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37572/" target="_blank">[新闻]马云:淘宝10年打败沃尔玛</a>]]></description></item><item><title>Mono SVN最新代码或者Mono 1.2.5 支持IronPython 2.0 </title><link>http://www.cnblogs.com/shanyou/archive/2007/05/19/752580.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Sat, 19 May 2007 10:32:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/05/19/752580.html</guid><description><![CDATA[IronPython 2.0基于Dynamic Language Runtime(DLR). Mono开发团队迅速完成了对DLR的支持.<A href="http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=438" target=_blank>IronPython 2.0 Aplal</A>一起发布的DLR（Dynamic Language Runtime ）都是采用<A href="http://www.microsoft.com/resources/sharedsource/licensingbasics/permissivelicense.mspx">Microsoft Permissive License (Ms-PL)</A>许可发布的 IronPython架构师Jim Hugunin改变了微软和Opensource社区的关系，微软现在够Open，可以看看微软目前的所有OpenSource方面的Licence <A id=_1ace5f5f6e58_HomePageDays_DaysList_ctl07_DayItem_DayList_ctl00_TitleUrl href="/shanyou/archive/2007/05/05/736691.html"><FONT color=#0000ff>Microsoft 的 OpenSource Licence</FONT></A>&nbsp;&nbsp;。<BR><BR>在Mono 1.2.4版本是在Mix 07会议之前准备好发布的，所以最新的支持代码没有在1.2.4中，可以通过SVN获取Mono的代码编译支持<A href="http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=438" target=_blank>IronPython 2.0 Aplal</A>&nbsp;。或者等到Mono 1.2.5发布后享用。具体参见<A class=permalink href="http://www.oreillynet.com/xml/blog/2007/05/monodlr_hello_dynamic_language.html"><FONT color=#000000>[Mono:DLR] Hello, Dynamic Language Runtime-enabled World!</FONT></A><BR><BR>Mono 在不断成熟，对Asp.net 2.0的支持不断完善，可参看这个blog：<A href="http://grendello.blogspot.com/2007/05/mono-124-best-aspnet-20-release-so-far.html">Mono 1.2.4 - the best ASP.NET 2.0 release so far</A> <BR>客户端应用程序例子： <A class=entryTitle href="http://tirania.org/blog/archive/2007/May-15-1.html">Paint.NET 3.0 for Mono: Now Public</A><BR><img src ="http://ipy.cnblogs.comaggbug/752580.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37571/" target="_blank">[新闻]北京奥组委指定明复为官方移动搜索提供商</a>]]></description></item><item><title>反射之人千万不能错过的 EmitHelper</title><link>http://www.cnblogs.com/Dah/archive/2007/05/07/738215.html</link><dc:creator>Adrian.</dc:creator><author>Adrian.</author><pubDate>Mon, 07 May 2007 11:57:00 GMT</pubDate><guid>http://www.cnblogs.com/Dah/archive/2007/05/07/738215.html</guid><description><![CDATA[摘要: 用EmitHelper写”给人读”的“生成MSIL代码“的代码&nbsp;&nbsp;<a href='http://www.cnblogs.com/Dah/archive/2007/05/07/738215.html'>阅读全文</a><img src ="http://ipy.cnblogs.comaggbug/738215.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37570/" target="_blank">[新闻][图]GMail发布新功能:访问记录</a>]]></description></item><item><title>Dynamic Language Runtime 微软打出的王牌</title><link>http://www.cnblogs.com/shanyou/archive/2007/05/06/736869.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Sun, 06 May 2007 01:21:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/05/06/736869.html</guid><description><![CDATA[摘要: Dynamic Language Runtime(DLR)。DLR和IronPython全部开源，如果你微软这样的动作吃惊,请看看Microsoft 的 OpenSource Licence,可以到codeplex下载。新的动态语言运行时（Dynamic Language Runtime，DLR）向CLR中加入了一小部分核心特性，使之得到显著改善。它向平台中加入了一系列明确为动态语言需求所设计的服务，包括同享的动态类型系统、标准托管模型（Standard Hosting Model），以及轻松生成快速动态代码的支持。&nbsp;&nbsp;<a href='http://www.cnblogs.com/shanyou/archive/2007/05/06/736869.html'>阅读全文</a><img src ="http://ipy.cnblogs.comaggbug/736869.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37568/" target="_blank">[新闻]腾讯研发官方版Linux QQ将于本月问世</a>]]></description></item><item><title>5.1节的微软大礼（SilverLight1.1Alpha，IronPython2.0Alpha，Microsoft ASP.NET Futures May 2007 ，DLR，Jasper ）</title><link>http://www.cnblogs.com/redmoon/archive/2007/05/01/733969.html</link><dc:creator>redmoon</dc:creator><author>redmoon</author><pubDate>Tue, 01 May 2007 05:11:00 GMT</pubDate><guid>http://www.cnblogs.com/redmoon/archive/2007/05/01/733969.html</guid><description><![CDATA[摘要: 5.1节的微软大礼（SilverLight1.1Alpha，IronPython2.0Alpha，Microsoft ASP.NET Futures May 2007 ，DLR，Jasper ）&nbsp;&nbsp;<a href='http://www.cnblogs.com/redmoon/archive/2007/05/01/733969.html'>阅读全文</a><img src ="http://ipy.cnblogs.comaggbug/733969.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37569/" target="_blank">[新闻]康盛 Manyou 开放平台 (MYOP) 体验版上线</a>]]></description></item><item><title>IronPython 2.0 Alpha 1 发布，其构建于DLR之上</title><link>http://www.cnblogs.com/redmoon/archive/2007/05/01/733959.html</link><dc:creator>redmoon</dc:creator><author>redmoon</author><pubDate>Tue, 01 May 2007 04:22:00 GMT</pubDate><guid>http://www.cnblogs.com/redmoon/archive/2007/05/01/733959.html</guid><description><![CDATA[今天，微软发布了IronPython 2.0 Alpha 1。这个版本的IronPython构建于DLR（dynamic language runtime）之上。DLR将是微软昨晚CLR的一个扩展，专门用于支持动态语言的实现。<br>=====================<br>
<p><span>Hello IronPython Community,<br><br>We have just released IronPython 2.0 Alpha 1. IronPython 2.0 will be the first release of IronPython built upon a common dynamic language runtime (DLR) as well as targeting version 2.5 of Python. These release notes list what is new in IronPython 2.0, a brief overview of the DLR, and what to expect from the 2.0 release.</span></p>
<p><span><br>One major focus during this release will be further improving our conformance with CPython. We&#8217;ve already made several improvements, for example one is that our type system no longer contains a hierarchy of types: now type(type) is type. We have also fixed a number of issues related to various statements such as imports and function definitions inside of exec or eval. There have also been a number of other small issues fixed that our users reported to us.<br><br>IronPython 2.0 will also be the first major release to support 2.5 out of the box. In IronPython 1.x, and in this initial alpha release, users must enable this with a command line switch. During the 2.0 release cycle we will flush out the remaining 2.5 features and permanently enable this option. We will also start looking at supporting v2.6 features via command line switch and start some experimentation around the 3.0 features. In particular, we are excited about looking at the new bytes and string types as well as formatting options that we believe will fit nicely with .NET.<br><br>IronPython 2.0 is also the first release built upon the Dynamic Language Runtime: a shared runtime for dynamic languages on .NET. The DLR both reduces the amount of work to create new dynamic languages on .NET enables rich interoperability between dynamic languages, and provides a shared module for consuming those languages from applications. We are particularly excited about the ability to share code across dynamic languages enabling users to share libraries without worrying the particular language in which the library is written. Over time, the DLR will expand and improve bringing language developers more benefits from this shared infrastructure. We also look forward to seeing a new era of programmable apps that can support a wide range of options for end-users.<br><br>When we started working on the DLR we initially used the IronPython v1.0 code base. From there we extracted the core concepts that were common to dynamic languages, generalized the concepts that were specific to Python, expanded the framework to provide rich support for other dynamic languages, and exposed all of the languages via a common interface. Starting with IronPython 1.0 was an obvious choice because it had already captured many of the best practices for building dynamic languages on .NET and had done a great job leveraging many of the underlying features of .NET. In IronPython 2.0 all of these best practices are expanded and implemented with an eye on maximizing forward compatibility with new features in .NET v3.5 such as LINQ and extension methods. Moreover, the DLR exposes this functionality to the language implementer via a small set of core concepts that all dynamic language implementations can share.<br><br>One additional change in this release is that we&#8217;re moving to use the Microsoft Permissive License for IronPython 2.0. Our original release of IronPython predated the Microsoft Permissive License, and so we created a custom license specifically for Iron Python. After releasing Iron Python, we created new Microsoft Shared Source licenses, including the Microsoft Permissive License, to facilitate and standardize source code licensing for appropriate Microsoft projects. We believe our users appreciate consistency in licensing from Microsoft. Therefore, because we are now using the more modern Microsoft Permissive License where appropriate for similar current source code releases, we feel we should offer IronPython under the Microsoft Permissive License as well.<br><br>Note because this is an alpha release there is also some missing functionality that was formerly present in v1.0. This includes CodeDom support, the static compiler that produced .NET assemblies, support for creating strongly typed delegates to script code, as well as a drastically changed hosting API. We will be bringing this functionality back to future releases in the IronPython 2.0 series as well many other improvements.<br>You can download IronPython v2.0 at: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=438" target=_blank>2.0 Alpha</a><br><br>If you&#8217;d like more details about the DLR, Jim will be using his blog to post design notes as they are written over the next couple of weeks &#8211; <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://blogs.msdn.com/hugunin" target=_blank>http://blogs.msdn.com/hugunin</a>.<br>===================================</span></p>
<img src ="http://ipy.cnblogs.comaggbug/733959.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37567/" target="_blank">[新闻]百度首页人物08年6月号:比尔·盖茨</a>]]></description></item><item><title>pypy -- 用python实现的python</title><link>http://www.cnblogs.com/shanyou/archive/2007/04/25/727557.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Wed, 25 Apr 2007 15:02:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/04/25/727557.html</guid><description><![CDATA[pypy 分为两部分：一个 python 的实现 和 一个编译器：<BR>
<BLOCKQUOTE><EM>pypy provides infrastructure for building interpreters in [r]python. This infrastructure makes it much easier than starting from scratch, e.g. by providing reusable components for language runtimes (like GC's).</EM></BLOCKQUOTE><A href="http://codespeak.net/svn/user/antocuni/eos-due-2007/rpython.pdf"><BR>http://codespeak.net/svn/user/antocuni/eos-due-2007/rpython.pdf</A><BR><BR><A href="http://docs.google.com/Doc?id=dczg8vtk_24g5sdrr">Trying out PyPy</A> <BR><BR><A href="http://codespeak.net/pypy/dist/pypy/doc/cli-backend.html">http://codespeak.net/pypy/dist/pypy/doc/cli-backend.html</A><BR><BR>国外的社区红红火火阿，实在太有激情了，Python,IronPython,.NET非常的热闹哦，最近园子里的火药味极浓阿，安心下来，不要浮躁！！<BR><BR><A class=titlelink id=Editor_Results_rprSelectionList_ctl02_Hyperlink1 href="/shanyou/archive/2007/04/25/727423.html"><FONT color=#000000>CPython 和IronPython的基准测试</FONT></A> <img src ="http://ipy.cnblogs.comaggbug/727557.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37566/" target="_blank">[新闻]篱笆网第二轮融资1500万美元</a>]]></description></item><item><title>CPython 和IronPython的基准测试</title><link>http://www.cnblogs.com/shanyou/archive/2007/04/25/727423.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Wed, 25 Apr 2007 14:34:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/04/25/727423.html</guid><description><![CDATA[&nbsp;Seo 在Mono上做的IronPython的基准测试<A href="http://sparcs.kaist.ac.kr/~tinuviel/pybench/">http://sparcs.kaist.ac.kr/~tinuviel/pybench/</A><BR>在Ironpython邮件列表中，Jim Hugunin 也发布了一个在Windows vista上<A class=reference href="http://lists.ironpython.com/pipermail/users-ironpython.com/2007-April/004773.html">IronPython 1.1 and Python 2.5 on .NET</A>.<BR>这两个基准测试非常的有意思。有兴趣的可以去看看。<BR>这里还有一个比较 <A href="http://lists.ironpython.com/pipermail/users-ironpython.com/2007-April/004779.html">Microsoft .NET vs. Mono on running IronPython</A><BR><BR><A href="http://sourceforge.net/project/showfiles.php?group_id=173546&amp;package_id=198777">http://sourceforge.net/project/showfiles.php?group_id=173546&amp;package_id=198777</A><!--htdig_noindex--><img src ="http://ipy.cnblogs.comaggbug/727423.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37565/" target="_blank">[新闻]51.COM开放平台正式上线内测</a>]]></description></item><item><title>IronPython 1.1  发布</title><link>http://www.cnblogs.com/redmoon/archive/2007/04/18/717717.html</link><dc:creator>redmoon</dc:creator><author>redmoon</author><pubDate>Wed, 18 Apr 2007 01:16:00 GMT</pubDate><guid>http://www.cnblogs.com/redmoon/archive/2007/04/18/717717.html</guid><description><![CDATA[&nbsp;这一版本的IronPython主要是支持了MD5,SHA，并修正了一些Bug。<br><br>======================<br>Hello IronPython Community,<br><br>We have just released IronPython 1.1. It started out as the work on v1.0 started to wind down. We could not get the features ready before we started locking down for the v1.0 release but we're happy we can finally include them - as will be our summer interns who worked on some of these features and many of the modules during their stay with us. After that we have been looking at the most requested bug fixes and new features from the community. Based upon this feedback we've fixed a large number of bugs, greatly improved compatibility of some of the built-in modules, and a few other new features such as XML doc comments and the array module.<br><br>IronPython v1.1 is a minor update to IronPython including both new functionality as fixes for the most voted for bugs. The new functionality in v1.1 includes several new modules (array, SHA, MD5, and select), support for .NET XML Doc comments within the help system and doc tags, as well as support for loading cached pre-compiled modules. This release improves compatibility with CPython and gives the .NET developer a better interactive experience.<br><br>You can download the release from: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=2573" target=_blank>http://www.codeplex.com<wbr>/IronPython/Release/ProjectRel<wbr>eases.aspx?ReleaseId=2573</a><br><br>We'd like to thank everyone in the community for your bug reports and suggestions that helped make this a better release: Arman0, Anthony Baxter, Christopher Baus, Christian Muirhead, Coleyc, Diane Trout, Doubleyewdee, Eloff, J. Merrill, JoeSox, J&#246;rgen Stenarson, Michael Foord, Mike Raath, Py_Sunil, Seo Sanghyeon, Sylvain Hellegouarch, sophros, Tarlano, and Whit537.<br><br>More complete list of changes and bug fixes:<br>==============================<wbr>==============<br>CodePlex bug #1216: ironpython shows different error msgs when we use cpython's os module<br>CodePlex bug #1403 int.dict0=0<br>
<script><!--
D(["mb","CodePlex bug #2704 import and packages aren\'t mixing well\u003cbr /\>CodePlex bug #5083 operator.contains is broken\u003cbr /\>CodePlex bug #5445 socket.getaddrinfo(...) does not throw on nonsense parameters\u003cbr /\>CodePlex bug #5446 socket.getaddrinfo(...) proto parameter CodePlex bug #5566 base64 slash bug\u003cbr /\>CodePlex bug #5609 (Py2.5) File lacks enter and exit\u003cbr /\>CodePlex bug #5641 co_name in code objects is None\u003cbr /\>CodePlex bug #5712 iterating over main.dict throws\u003cbr /\>CodePlex bug #5904 Multi-line dictionary expressions in IP interpreter console not compatible w/ CPython Interpreter console CodePlex bug #6010 UnicodeErrorInit sets @object instead of object\u003cbr /\>CodePlex bug #6142 Setting func_name on function doesn\'t show up in name\u003cbr /\>CodePlex bug #6265 maxsplit keyword arg of re.split not accepted\u003cbr /\>CodePlex bug #6704 globals().fromkeys(...) broken\u003cbr /\>CodePlex bug #6706 globals().Values enumerator broken\u003cbr /\>CodePlex bug #6735 help incorrectly displays arguments for params functions\u003cbr /\>CodePlex bug #6805 funccode.coargcount and funccode.coflags are wrong\u003cbr /\>CodePlex bug #7532 func_defaults is empty tuple when there are no defaults\u003cbr /\>CodePlex bug #7982 ^L yields SyntaxError CodePlex bug #7827 IronPython thread module does not implement stack_size\u003cbr /\>CodePlex bug #7828 IronPython lock type does not support context manager methods\u003cbr /\>Support importing pre-compiled modules produced when running in -X:SaveAssemblies mode\u003cbr /\>Enable inheritance of static op_Implicit implicit conversion operators on .NET types\u003cbr /\>Fixed tracebacks when catching exceptions in the method that threw them and a few other fixes here\u003cbr /\>Bugfix: 4859 datetime.date.str broken\u003cbr /\>Bugfix: 4870 datetime.datetime.isoformat does not report microseconds\u003cbr /\>Bugfix: 5148 datetime.time(..., None).tzname() returns \'\' instead of None\u003cbr /\>Bugfix: Bugfix: 5146 datetime.time(...).isoformat() does not work\u003cbr /\>Bugfix: 4860 datetime.datetime.* only accurate to 1000 microseconds\u003cbr /\>Bugfix: 3850 datetime.datetime(...) allows negative microsecond parameter\u003cbr /\>",1]
);
//--></script>
CodePlex bug #2704 import and packages aren't mixing well<br>CodePlex bug #5083 operator.contains is broken<br>CodePlex bug #5445 socket.getaddrinfo(...) does not throw on nonsense parameters<br>CodePlex bug #5446 socket.getaddrinfo(...) proto parameter CodePlex bug #5566 base64 slash bug<br>CodePlex bug #5609 (Py2.5) File lacks enter and exit<br>CodePlex bug #5641 co_name in code objects is None<br>CodePlex bug #5712 iterating over main.dict throws<br>CodePlex bug #5904 Multi-line dictionary expressions in IP interpreter console not compatible w/ CPython Interpreter console CodePlex bug #6010 UnicodeErrorInit sets @object instead of object<br>CodePlex bug #6142 Setting func_name on function doesn't show up in name<br>CodePlex bug #6265 maxsplit keyword arg of re.split not accepted<br>CodePlex bug #6704 globals().fromkeys(...) broken<br>CodePlex bug #6706 globals().Values enumerator broken<br>CodePlex bug #6735 help incorrectly displays arguments for params functions<br>CodePlex bug #6805 funccode.coargcount and funccode.coflags are wrong<br>CodePlex bug #7532 func_defaults is empty tuple when there are no defaults<br>CodePlex bug #7982 ^L yields SyntaxError CodePlex bug #7827 IronPython thread module does not implement stack_size<br>CodePlex bug #7828 IronPython lock type does not support context manager methods<br>Support importing pre-compiled modules produced when running in -X:SaveAssemblies mode<br>Enable inheritance of static op_Implicit implicit conversion operators on .NET types<br>Fixed tracebacks when catching exceptions in the method that threw them and a few other fixes here<br>Bugfix: 4859 datetime.date.str broken<br>Bugfix: 4870 datetime.datetime.isoformat does not report microseconds<br>Bugfix: 5148 datetime.time(..., None).tzname() returns '' instead of None<br>Bugfix: Bugfix: 5146 datetime.time(...).isoformat() does not work<br>Bugfix: 4860 datetime.datetime.* only accurate to 1000 microseconds<br>Bugfix: 3850 datetime.datetime(...) allows negative microsecond parameter<br>
<script><!--
D(["mb","Bugfix: 5147 datetime.time(..., None).utcoffset() returns 0 instead of None\u003cbr /\>Bugfix: 5145 datetime.time.resolution is the wrong type\u003cbr /\>Bugfix: 5143 datetime.time(...) allows parameters &lt; time.min and &gt; time.max\u003cbr /\>Bugfix: 5139 datetime.timedelta and datetime.time objects should work correctly in boolean contexts\u003cbr /\>Bugfix: 5133 datetime.timedelta.* does not normalize negative parameters and return values\u003cbr /\>Bugfix: 5132 datetime.timedelta(...) constructor does not round off floating point parameters correctly\u003cbr /\>Bugfix: 4871 datetime.timedelta.init does not accept the 4 optional keyword parameters\u003cbr /\>Bugfix: 4868 datetime.datetime.timetuple returns an incorrect value\u003cbr /\>Bugfix: 4867 datetime.datetime.tzname returns incorrect value if tzinfo member is None\u003cbr /\>Bugfix: 4866 datetime.datetime.resolution is of the wrong type\u003cbr /\>Bugfix: 4865 datetime.datetime.cmp broken for datetime.datetime.max\u003cbr /\>Bugfix: 4864 datetime.datetime.max has the wrong value for the microsecond member\u003cbr /\>Bugfix: 4863 datetime.datetime.init(...) defaults the hour keyword param to 1 (should be 0)\u003cbr /\>Bugfix: 4861 datetime.timedelta + datetime.datetime throws a TypeError\u003cbr /\>Bugfix: 3990 datetime.timedelta member attributes out of range\u003cbr /\>Bugfix: 5149 datetime.timdelta(...) does not add fractional microseconds correctly\u003cbr /\>Bugfix: 5136 datetime.timedelta.min(imum), datetime.timedelta.max(imum), and datetime.timedelta.resolution all have incorrect values\u003cbr /\>Bugfix: 5135 datetime.timedelta.min and datetime.timedelta.max are missing\u003cbr /\>Bugfix: 4858 datetime.date.reduce broken\u003cbr /\>Bugfix 7426: in operator doesn\'t check for overloaded contains on dictionary\u003cbr /\>Implemented array module\u003cbr /\>Bugfix: KeyboardInterrupt propagates after except block that catches it\u003cbr /\>Bugfix: Compiled regex gets different results for findall then non-compiled\u003cbr /\>Bugfix: regex match doesn\'t implement lastgroup\u003cbr /\>Bugfix: Import in exec doesn\'t publish into provided dictionary\u003cbr /\>Bugfix: Lacking file open() modes (at, rt, etc...)\u003cbr /\>",1]
);
//--></script>
Bugfix: 5147 datetime.time(..., None).utcoffset() returns 0 instead of None<br>Bugfix: 5145 datetime.time.resolution is the wrong type<br>Bugfix: 5143 datetime.time(...) allows parameters &lt; time.min and &gt; time.max<br>Bugfix: 5139 datetime.timedelta and datetime.time objects should work correctly in boolean contexts<br>Bugfix: 5133 datetime.timedelta.* does not normalize negative parameters and return values<br>Bugfix: 5132 datetime.timedelta(...) constructor does not round off floating point parameters correctly<br>Bugfix: 4871 datetime.timedelta.init does not accept the 4 optional keyword parameters<br>Bugfix: 4868 datetime.datetime.timetuple returns an incorrect value<br>Bugfix: 4867 datetime.datetime.tzname returns incorrect value if tzinfo member is None<br>Bugfix: 4866 datetime.datetime.resolution is of the wrong type<br>Bugfix: 4865 datetime.datetime.cmp broken for datetime.datetime.max<br>Bugfix: 4864 datetime.datetime.max has the wrong value for the microsecond member<br>Bugfix: 4863 datetime.datetime.init(...) defaults the hour keyword param to 1 (should be 0)<br>Bugfix: 4861 datetime.timedelta + datetime.datetime throws a TypeError<br>Bugfix: 3990 datetime.timedelta member attributes out of range<br>Bugfix: 5149 datetime.timdelta(...) does not add fractional microseconds correctly<br>Bugfix: 5136 datetime.timedelta.min(imum), datetime.timedelta.max(imum), and datetime.timedelta.resolution all have incorrect values<br>Bugfix: 5135 datetime.timedelta.min and datetime.timedelta.max are missing<br>Bugfix: 4858 datetime.date.reduce broken<br>Bugfix 7426: in operator doesn't check for overloaded contains on dictionary<br>Implemented array module<br>Bugfix: KeyboardInterrupt propagates after except block that catches it<br>Bugfix: Compiled regex gets different results for findall then non-compiled<br>Bugfix: regex match doesn't implement lastgroup<br>Bugfix: Import in exec doesn't publish into provided dictionary<br>Bugfix: Lacking file open() modes (at, rt, etc...)<br>
<script><!--
D(["mb","Bugfix: PythonBinaryReader shouldn\'t access Position if stream isn\'t seekable\u003cbr /\>Bugfix: Cannot pass arbitrary sequence to method defined w/ both * and ** args\u003cbr /\>Bugfix: rb+ mode on file not implemented\u003cbr /\>Bugfix: improved thread safety of dictionaries\u003cbr /\>Bugfix: KeyError from dict adds quotes (and doesn\'t contain original key, only string repr)\u003cbr /\>Bugfix: del {None:23} raises a TypeError\u003cbr /\>Support for external region blocks when producing errors\u003cbr /\>Bugfix: line number information in VS SDK is incorrect for web projects\u003cbr /\>Support for Python 2.5 unified try/except/finally\u003cbr /\>Support for Python 2.5 yield from finally block\u003cbr /\>help supports documentation on reflected fields, properties, and events\u003cbr /\>Support for XML Doc comments (requires XML files to live next to DLLs) for help and doc\u003cbr /\>Nt module implements spawnle, spawnv, spawnve functions\u003cbr /\>Socket implements makefile function\u003cbr /\>Support for picking exception instances\u003cbr /\>Fix issue with metaclass &amp; deriving from mixed new-style / old-style classes\u003cbr /\>Implement select module\u003cbr /\>Implement sha module\u003cbr /\>Implement md5 module\u003cbr /\>Add new tests for codecs and CLR numeric interop\u003cbr /\>______________________________\u003cwbr /\>_________________\u003cbr /\>users mailing list\u003cbr /\>\u003ca onclick\u003d\"return top.js.OpenExtLink(window,event,this)\" href\u003d\"mailto:users@lists.ironpython.com\"\>users@lists.ironpython.com\u003c/a\>\u003cbr /\>\u003ca onclick\u003d\"return top.js.OpenExtLink(window,event,this)\" href\u003d\"http://lists.ironpython.com/listinfo.cgi/users-ironpython.com\" target\u003d_blank\>http://lists.ironpython.com\u003cwbr /\>/listinfo.cgi/users-ironpython\u003cwbr /\>.com\u003c/a\>\u003cbr /\>\u003c/div\>",0]
);
//--></script>
Bugfix: PythonBinaryReader shouldn't access Position if stream isn't seekable<br>Bugfix: Cannot pass arbitrary sequence to method defined w/ both * and ** args<br>Bugfix: rb+ mode on file not implemented<br>Bugfix: improved thread safety of dictionaries<br>Bugfix: KeyError from dict adds quotes (and doesn't contain original key, only string repr)<br>Bugfix: del {None:23} raises a TypeError<br>Support for external region blocks when producing errors<br>Bugfix: line number information in VS SDK is incorrect for web projects<br>Support for Python 2.5 unified try/except/finally<br>Support for Python 2.5 yield from finally block<br>help supports documentation on reflected fields, properties, and events<br>Support for XML Doc comments (requires XML files to live next to DLLs) for help and doc<br>Nt module implements spawnle, spawnv, spawnve functions<br>Socket implements makefile function<br>Support for picking exception instances<br>Fix issue with metaclass &amp; deriving from mixed new-style / old-style classes<br>Implement select module<br>Implement sha module<br>Implement md5 module<br>Add new tests for codecs and CLR numeric interop<br>
<img src ="http://ipy.cnblogs.comaggbug/717717.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37564/" target="_blank">[新闻]李想：未来两年业绩达标就可以独立去上市</a>]]></description></item><item><title>IronPython中使用Cecil类库指南</title><link>http://www.cnblogs.com/shanyou/archive/2007/04/07/703886.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Sat, 07 Apr 2007 07:17:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/04/07/703886.html</guid><description><![CDATA[摘要: 这三篇文章介绍了如何以IronPython去使用Cecil，是很不错的指导性文章： <br>Nauman Leghari's Blog : Fun with IronPython and Cecil <br>Nauman Leghari's Blog : Fun with IronPython and Cecil (Part II) <br>Method Tree Visualizer :: Fun with IronPython, Cecil and Netron Graph - Part III <br><br>&nbsp;&nbsp;<a href='http://www.cnblogs.com/shanyou/archive/2007/04/07/703886.html'>阅读全文</a><img src ="http://ipy.cnblogs.comaggbug/703886.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37563/" target="_blank">[新闻]优酷网证实已于上周四获得视频牌照</a>]]></description></item><item><title>Fun with IronPython and Cecil （Part I）翻译</title><link>http://www.cnblogs.com/redmoon/archive/2007/04/04/699541.html</link><dc:creator>redmoon</dc:creator><author>redmoon</author><pubDate>Wed, 04 Apr 2007 05:33:00 GMT</pubDate><guid>http://www.cnblogs.com/redmoon/archive/2007/04/04/699541.html</guid><description><![CDATA[<span style="FONT-WEIGHT: bold">什么是Cecil</span><br>&#8220;Cecil是由Jb Evain 开发，用于生成和浏览ECMA CIL 格式的程序和函数库。它完全支持泛型，支持部分调试符号。简单说来，利用Cecil，你可以加载存在的程序集，浏览其中所有的类型，动态的编辑他们，并保存到磁盘上成为一个新的编辑过的程序集&#8221;<br>以上说明来自：<a href="http://www.mono-project.com/Cecil"><em>http://www.mono-project.com/Cecil</em></a><br><br>在这个教程中，我将花一些时间演示在IronPython中使用Cecil的功能。基本上，我就是用Cecil来找到不同的方法，这些方法能从一个方法中被调用。是不是很由意思呀？那么请继续往下看吧。<br><br>在继续之前，请下载并安装<a href="http://www.codeplex.com/IronPython">IronPython</a>和<a href="http://www.mono-project.com/Cecil">Cecil</a>先。你可以不用下载Cecil，因为我已经把它包含在我的这个<a href="http://www.devmobile.net/nleghari/cecilbox.zip">Solution</a>文件中了。<br><br>首先，我们用C#来创建一个简单的Class Library项目，我们用这个项目生成的程序集用于在后面被Cecil加载。源代码如下（CecilCase.dll 是非常简单的）：<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;MainCase.cs</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;MainCase<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;PublicMethod()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Hello</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrivateMethod();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">new</span><span style="COLOR: #000000">&nbsp;SecondCase().Help(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Help&nbsp;me</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;AddMethod()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">private</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;PrivateMethod()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;MethodWithArgument(</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&nbsp;name)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(name);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;SecondCase.cs</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;SecondCase<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;Help(</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&nbsp;message)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(message);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br><br></span></div>
<br>把这个项目编译成dll，然后打开IronPython的控制台。<br><br><img alt="" src="http://www.devmobile.net/nleghari/IronPythonShell.png"><br><br>保证把IronPython启动目录和CecilCase.dll的输入目录是同一个。也要记得把Mono.Cecil.dll拷贝到同一目录。<br>我们开始添加CLR的支持，并引用Mono.Cecil dll<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;clr<br></span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">&nbsp;clr.AddReference(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">Mono.Cecil</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br></span></div>
<br>接着我们要导入所有类型<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;Mono.Cecil&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span></div>
<br>用dir()命令来看看我们加载了那些类型<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">&nbsp;dir()</span></div>
<br>接下来，我们需要把上面编译好的程序集加载进来。根据<a href="http://www.mono-project.com/Cecil:FAQ">FAQ</a> ,我们使用AssemblyFactory类来加载目标程序集。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">&nbsp;myAsm&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;AssemblyFactory.GetAssembly(</span><span style="COLOR: #800000">"</span><span style="COLOR: #800000">CecilCase.dll</span><span style="COLOR: #800000">"</span><span style="COLOR: #000000">)<br></span><span style="COLOR: #000000">&gt;&gt;</span><span style="COLOR: #000000">&nbsp;myAsm<br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Mono.Cecil.AssemblyDefinition&nbsp;object&nbsp;at&nbsp;</span><span style="COLOR: #000000">0x000000000000002B</span><span style="COLOR: #000000">&nbsp;[CecilCase,&nbsp;Version</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1.0</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">0.0</span><span style="COLOR: #000000">,&nbsp;Culture</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">neutral, <br>PublicKeyToken</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">null]</span><span style="COLOR: #000000">&gt;<br></span></div>
<br><span style="FONT-WEIGHT: bold; TEXT-DECORATION: underline">类型</span><br><br>现在，我们来得到程序集中类型。数量是多少？<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;myAsm.MainModule.Types.Count<br></span><span style="COLOR: #000000">3</span></div>
<br>3个类型？我想我只编写了2个啊？让我们看看为什么会这样？<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;caseType&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;myAsm.MainModule.Types:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;caseType<br><img src="http://www.cnblogs.com/Images/dot.gif"><br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Module</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br>CecilCase.MainCase<br>CecilCase.SecondCase<br><br>So&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Module</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000">&nbsp;was&nbsp;the&nbsp;hidden&nbsp;type.&nbsp;We</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">ll&nbsp;ignore&nbsp;it&nbsp;from&nbsp;now&nbsp;on.</span><span style="COLOR: #800000"><br></span><span style="COLOR: #000000"><br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;caseType&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;myAsm.MainModule.Types:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;caseType.Name&nbsp;</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">&lt;Module&gt;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;caseType.Name<br><img src="http://www.cnblogs.com/Images/dot.gif"><br>MainCase<br>SecondCase</span></div>
<br><span style="FONT-WEIGHT: bold; TEXT-DECORATION: underline">方法</span><br><br>从一个特定的类型得到其中的方法也是很容易。我们从MainCase开始。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;mainCaseType&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;myAsm.MainModule.Types[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]<br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;mainCaseType<br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Mono.Cecil.TypeDefinition&nbsp;object&nbsp;at&nbsp;</span><span style="COLOR: #000000">0x000000000000002D</span><span style="COLOR: #000000">&nbsp;[CecilCase.MainCase]</span><span style="COLOR: #000000">&gt;</span></div>
<br>记住[0]类型是<em>&lt;Module&gt;</em>。现在，我们得到了<em>MainCase</em>的类型定义。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;mainCaseType.Methods.Count<br></span><span style="COLOR: #000000">4</span><span style="COLOR: #000000"><br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;met&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;mainCaseType.Methods:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;met.Name<br><img src="http://www.cnblogs.com/Images/dot.gif"><br>PublicMethod<br>AddMethod<br>PrivateMethod<br>MethodWithArgument</span></div>
<br>得到完整的方法定义<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;met&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;mainCaseType.Methods:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;met<br><img src="http://www.cnblogs.com/Images/dot.gif"><br>System.Void&nbsp;CecilCase.MainCase::PublicMethod()<br>System.Void&nbsp;CecilCase.MainCase::AddMethod()<br>System.Void&nbsp;CecilCase.MainCase::PrivateMethod()<br>System.Void&nbsp;CecilCase.MainCase::MethodWithArgument(System.String)</span></div>
<br><strong><u>Method Body:<br></u><span style="FONT-WEIGHT: normal"><br>为了看到方法的内部，我们从第一个方法</span></strong>MainCase.PublicMethod()开始<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;pMet&nbsp;</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&nbsp;mainCaseType.Methods[0]<br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;pMet<br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Mono.Cecil.MethodDefinition&nbsp;object&nbsp;at&nbsp;</span><span style="COLOR: #000000">0x000000000000002F</span><span style="COLOR: #000000">&nbsp;[System.Void&nbsp;CecilCase<br>.MainCase::PublicMethod()]</span><span style="COLOR: #000000">&gt;</span></div>
<br>为了看到pMet包含的方法和属性，使用dir()<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;dir(pMet)<br>[</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Accept</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Attributes</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Body</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">CallingConvention</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Cctor</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Clone</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Ctor</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,<br></span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">CustomAttributes</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">DeclaringType</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Equals</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">ExplicitThis</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Finalize</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Gene</span><span style="COLOR: #800000"><br></span><span style="COLOR: #000000">ricParameters</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">GetHashCode</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">GetSentinel</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">GetType</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">HasBody</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">HasThis</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000"><br>ImplAttributes</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">IsAbstract</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">IsConstructor</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">IsFinal</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">IsHideBySignature</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,</span><span style="COLOR: #800000"><br>'</span><span style="COLOR: #800000">IsInternalCall</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">IsNewSlot</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">IsRuntime</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">IsRuntimeSpecialName</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">IsSpecialNa</span><span style="COLOR: #800000"><br></span><span style="COLOR: #000000">me</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">IsStatic</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">IsVirtual</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">MakeDynamicType</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">MemberwiseClone</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">MetadataTok<br>en</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Name</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Overrides</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">PInvokeInfo</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Parameters</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">RVA</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Reduce</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Referen<br>ceEquals</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">ReturnType</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">SecurityDeclarations</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">SemanticsAttributes</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">This</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,</span><span style="COLOR: #800000"><br>'</span><span style="COLOR: #800000">ToString</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__class__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__doc__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__init__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__module__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__new__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__redu</span><span style="COLOR: #800000"><br></span><span style="COLOR: #000000">ce__</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800080">__reduce_ex__</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800080">__repr__</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800080">__str__</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">]</span></div>
<br>这里，我们感兴趣的是Body<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;pMet.Body<br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">MethodBody&nbsp;object&nbsp;at&nbsp;</span><span style="COLOR: #000000">0x0000000000000034</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;dir(pMet.Body)<br>[</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Accept</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">CilWorker</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">CodeSize</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Equals</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">ExceptionHandlers</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Finalize</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'<br></span><span style="COLOR: #000000">GetHashCode</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">GetType</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">InitLocals</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Instructions</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">MakeDynamicType</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">MaxSt<br>ack</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">MemberwiseClone</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Method</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Reduce</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">ReferenceEquals</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Scopes</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Simpl<br>ify</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">ToString</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">Variables</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800080">__class__</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800080">__doc__</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800080">__init__</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800080">__module__</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">,</span><span style="COLOR: #800000"><br></span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__new__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__reduce__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__reduce_ex__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">__repr__</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">]</span></div>
<br>现在我们来看看pMet.Body中的<span style="COLOR: #000000">Instructions（译者注：Instructions就是IL语句的序列，它是一个集合对象，我们需要枚举它。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;ins&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;pMet.Body.Instructions:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;ins<br><img src="http://www.cnblogs.com/Images/dot.gif"><br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction<br>Mono.Cecil.Cil.Instruction</span></div>
<br>好，它显示出了我们期望的结果。如果你尝试看看ins是否具有智能感知功能的话，目前是无法正常工作的。所以，我们需要添加从Cecil命名空间中添加所有类型。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">from</span><span style="COLOR: #000000">&nbsp;Mono.Cecil.Cil&nbsp;</span><span style="COLOR: #0000ff">import</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"><br><br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;ins&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;pMet.Body.Instructions:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;ins.OpCode.Name<br><img src="http://www.cnblogs.com/Images/dot.gif"><br>nop<br>ldstr<br>call<br>nop<br>ldarg.0<br>call<br>nop<br>newobj<br>ldstr<br>call<br>nop<br>ret</span></div>
<br>我们来和Reflector的反编译输出结果比较一下：<br><br><img alt="" src="http://www.devmobile.net/nleghari/ReflectorCecil.png"><br><br>很酷吧！基本使用我们介绍到这里。接下来，我们将开始关注3个&#8220;call&#8221;语句（译者注：call语句指的是上图所显示出的IL语句）。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;ins&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;pMet.Body.Instructions:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;ins.OpCode.Name&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">call</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ins.Operand<br><img src="http://www.cnblogs.com/Images/dot.gif"><br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Mono.Cecil.MethodReference&nbsp;object&nbsp;at&nbsp;</span><span style="COLOR: #000000">0x000000000000003F</span><span style="COLOR: #000000">&nbsp;[System.Void&nbsp;System.Console::WriteLine(System.String)]</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Mono.Cecil.MethodDefinition&nbsp;object&nbsp;at&nbsp;</span><span style="COLOR: #000000">0x0000000000000031</span><span style="COLOR: #000000">&nbsp;[System.Void&nbsp;CecilCase.MainCase::PrivateMethod()]</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #000000"><br></span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">Mono.Cecil.MethodDefinition&nbsp;object&nbsp;at&nbsp;</span><span style="COLOR: #000000">0x000000000000003D</span><span style="COLOR: #000000">&nbsp;[System.Void&nbsp;CecilCase.SecondCase::Help(System.String)]</span><span style="COLOR: #000000">&gt;</span></div>
<br>以上得到了Operand的细节。现在，我们需要得到这方法的定义对象以便我们能递归的浏览每一个子方法。为了达到目的，我们定义了一个方法，它能把传入的</span>MethodDefinition的对象递归浏览，并打印出子call方法。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000">&nbsp;parseMethodBody(methodDef):<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;ins&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;methodDef.Body.Instructions:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;ins.OpCode.Name&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">call</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;ins.Operand<br><img src="http://www.cnblogs.com/Images/dot.gif"></span></div>
<br>从上面可知，ins.Operand返回了MethodDefinition/MethodReference。我们还不知道MethodDefinition和MethodReference之间的区别。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;ins&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;pMet.Body.Instructions:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;ins.OpCode.Name&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">call</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parseMethodBody(ins.Operand)<br><img src="http://www.cnblogs.com/Images/dot.gif"><br>Traceback&nbsp;(most&nbsp;recent&nbsp;call&nbsp;last):<br>&nbsp;&nbsp;File&nbsp;,&nbsp;line&nbsp;0,&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #000000">&lt;</span><span style="COLOR: #000000">stdin</span><span style="COLOR: #000000">&gt;</span><span style="COLOR: #008000">#</span><span style="COLOR: #008000">#168</span><span style="COLOR: #008000"><br></span><span style="COLOR: #000000">&nbsp;&nbsp;File&nbsp;,&nbsp;line&nbsp;0,&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;parseMethodBody<br>AttributeError:&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">MethodReference</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">&nbsp;object&nbsp;has&nbsp;no&nbsp;attribute&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">Body</span><span style="COLOR: #800000">'</span></div>
<br>好，现在我们知道了MethodReference不具有Body，所以我们可以忽略它，这样需要修改一下parseMethodBody方法。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">def</span><span style="COLOR: #000000">&nbsp;parseMethodBody(mDef):<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;isinstance(mDef,&nbsp;MethodDefinition):<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;ins&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;mDef.Body.Instructions:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;ins.OpCode.Name&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">call</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">print</span><span style="COLOR: #000000">&nbsp;ins.Operand<br><img src="http://www.cnblogs.com/Images/dot.gif"><br><br></span><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;ins&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;pMet.Body.Instructions:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;ins.OpCode.Name&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">call</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parseMethodBody(ins.Operand)<br><img src="http://www.cnblogs.com/Images/dot.gif"></span></div>
<br>通过运行这个代码，我们不能得到任何结果，因为我一开始并没有（有点傻的）在SecondCase.Help()添加需要的代码。现在，我们来添加之。<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;SecondCase.cs&nbsp;after&nbsp;adding&nbsp;another&nbsp;method</span><span style="COLOR: #008000"><br></span><span style="COLOR: #0000ff">class</span><span style="COLOR: #000000">&nbsp;SecondCase<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;Help(</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&nbsp;message)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(message);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HelpMeToo(message);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">public</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">&nbsp;HelpMeToo(</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">&nbsp;message2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(message2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}</span></div>
<br>我们需要用AssemblyFactory 重新添加程序集来看看刚刚我们添加的<span style="COLOR: #000000">HelpMeToo方法。让我们</span>扼要重述一下上面做个的一些步骤，看看你记得多少：<br>
<ol>
    <li>在添加Mono.Cecil的引用之后用AssemblyFactory来加载程序集
    <li>得到需要的类型
    <li>得到需要的方法
    <li>得到Instructions（只需要得到&#8220;call&#8221;）
    <li>得到每一个&#8220;call&#8221;的Operand信息 </li>
</ol>
我们继续：<br><br>
<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: #000000">&gt;&gt;&gt;</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">&nbsp;inst&nbsp;</span><span style="COLOR: #0000ff">in</span><span style="COLOR: #000000">&nbsp;pMet.Body.Instructions:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;inst.OpCode.Name&nbsp;</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #800000">'</span><span style="COLOR: #800000">call</span><span style="COLOR: #800000">'</span><span style="COLOR: #000000">:<br><img src="http://www.cnblogs.com/Images/dot.gif">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parseMethodBody(inst.Operand)<br><img src="http://www.cnblogs.com/Images/dot.gif"><br>System.Void&nbsp;System.Console::WriteLine(System.String)<br>System.Void&nbsp;CecilCase.SecondCase::HelpMeToo(System.String)</span></div>
<br>你能看到我们得到了一个从<em>SecondCase::Help() </em>中调用方法的列表<br><br>类似的，我们能开发一个递归函数来枚举这些方法。但是，我觉得现在对于第一个教程来说已经足够多。需要我还会准备下一个练习。<br>（译者注：最后没有再翻译作者的一些口水话了）<br><br>=========================<br>原文地址：http://weblogs.asp.net/nleghari/pages/ironpythoncecil.aspx<br><br>为什么我要翻译这篇文章：<br>一直以来，我一直希望让IronPython能运行在Smart Device上，但可惜IronPython内部用到的.NET的动态程序集生成机制在.NET CF中不支持，所以IronPython也无法成功在.NET CF中运行。<br>但是，Cecil是一个完全可以在.NET CF中运行的函数库。所以，我曾经在IronPython的邮件列表中提到过，可以在IronPython底层使用Cecil来生成动态程序集，这样就可以运行于.NET CF下了。<br>当然，让IronPython运行于.NET CF下最好的方法是，让.NET CF也具有动态生成程序集的功能。<br>这是一个我翻译本文的原因。另外Cecil是非常好的一个函数库，也借此机会介绍给大家。<br><br>作者关于这个话题，还写了<a href="http://weblogs.asp.net/nleghari/archive/2007/04/02/fun-with-ironpython-and-cecil-part-ii.aspx">PartII</a>，和<a href="http://weblogs.asp.net/nleghari/archive/2007/04/03/method-tree-visualizer-fun-with-ironpython-cecil-and-netron-graph-part-iii.aspx">PartIII</a>。我以后有时间再继续翻译Part2和Part3了。<br>这些文章其中还随带介绍了如下组件：<br><a href="http://research.microsoft.com/~levnach/GLEEWebPage.htm">GLEE</a> ，GLEE是微软研究院开发的一个做图的组件<br><a href="http://sourceforge.net/projects/netron-reloaded">Netron Graph</a>，Netron Graph是一个著名的开源做图组件<br><br>作者关于GLEE的文章：<a href="http://weblogs.asp.net/nleghari/archive/2007/04/02/fun-with-ironpython-glee.aspx">Fun With Ironpython GLEE</a><br>
<img src ="http://ipy.cnblogs.comaggbug/699541.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37562/" target="_blank">[新闻]谷歌产品体验中心(Google Discovery Zone)即将上线</a>]]></description></item><item><title>IronPython整合Windows PowerShell</title><link>http://www.cnblogs.com/shanyou/archive/2007/02/12/648568.html</link><dc:creator>自由、创新、研究、探索……</dc:creator><author>自由、创新、研究、探索……</author><pubDate>Mon, 12 Feb 2007 10:13:00 GMT</pubDate><guid>http://www.cnblogs.com/shanyou/archive/2007/02/12/648568.html</guid><description><![CDATA[摘要: Windows PowerShell 是微软为 Windows 环境所开发的 shell 及脚本语言技术，这项全新的技术提供了丰富的控制与自动化的系统管理能力；关于PowerShell参看易学易用的Windows PowerShell 。IronPython也是脚本语言,两种脚本语言的联姻可以解决Windows 系统管理的任务,是系统管理员的必备工具。这里有一篇文章在提醒DBA们要开始学PowerShell   RTFM ：http://weblog.infoworld.com/dbunderground/archives/2007/01/rtfm.html&nbsp;&nbsp;<a href='http://www.cnblogs.com/shanyou/archive/2007/02/12/648568.html'>阅读全文</a><img src ="http://ipy.cnblogs.comaggbug/648568.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/37561/" target="_blank">[新闻]微软2008年7月「最有价值专家」(MVP)当选名单</a>]]></description></item></channel></rss>