【Dflying Chen 】.NET Framework原始碼釋出

iDotNetSpace發表於2008-06-11

Scott在Blog中聲稱微軟公司將部分公開.NET Framework的原始碼,為避免曲解,這裡引用他的原文,如下:

We'll begin by offering the source code (with source file comments included) for the .NET Base Class Libraries (System, System.IO, System.Collections, System.Configuration, System.Threading, System.Net, System.Security, System.Runtime, System.Text, etc), ASP.NET (System.Web), Windows Forms (System.Windows.Forms), ADO.NET (System.Data), XML (System.Xml), and WPF (System.Windows).  We'll then be adding more libraries in the months ahead (including WCF, Workflow, and LINQ).  The source code will be released under the Microsoft Reference License (MS-RL).

原始碼發放的許可是MS-RL,這是一個非常嚴格的許可,通俗來講就是讓你看看而已,別的就別想幹了……不過確實能夠在除錯的時候方便不少,例如:

更多相關介紹以及使用方法也可以參考這篇文章:http://blogs.msdn.com/sburke/archive/2007/10/04/channel-9-video-more-details-on-reference-source.aspx

 

[2] Tip/Trick: Building a ToJSON() Extension Method using .NET 3.5 (Tip/Trick:在.NET 3.5中編寫ToJSON擴充套件方法)

.NET 3.5中的擴充套件方法非常有意思,似乎讓框架本身有了那麼一些“動態語言”的特性。Scott這裡給出了一個ToJSON擴充套件方法,讓我們能夠將一個物件轉化為JSON表示的字串。該ToJSON()方法的定義很簡單:

使用起來則更加直觀:

 

[3] Tracking Silverlight-enabled Browsers via Analytics (在Google Analytics中統計訪客瀏覽器的Silverlight啟用狀況)

Google Analytics功能非常強大,不過尚不能統計訪客瀏覽器的Silverlight啟用狀況。Nikhil Kothari因此寫了這樣一段JavaScript,讓Google Analytics也能夠把這部分資訊收入囊中:

function onLoad() {
    var version = getSilverlightVersion();
    if (version) { __utmSetVar(version); }
}
 
function getSilverlightVersion() {
    var version = '';
    var container = null;
    try {
        var control = null;
        if (window.navigator.userAgent.indexOf('MSIE') >= 0) {
            control = new ActiveXObject('AgControl.AgControl');
        }
        else {
            if (navigator.plugins['Silverlight Plug-In']) {
                container = document.createElement('div');
                document.body.appendChild(container);
                container.innerHTML= '<embed>';
                control = container.childNodes[0];
            }
        }
        if (control) {
            if (control.isVersionSupported('1.1')) { version = 'Silverlight/1.1'; }
            else if (control.isVersionSupported('1.0')) { version = 'Silverlight/1.0'; }
        }
    }
    catch (e) { }
    if (container) {
        document.body.removeChild(container);
    }
    return version;
}
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }  

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12639172/viewspace-343324/,如需轉載,請註明出處,否則將追究法律責任。

相關文章