Overview


After 60 days’ intense development, the second preview of .NET Extension is going to be released at the end of September, 2012 with dozens of new features (!!! so far the download is still the first preview and it does not incorporate all features listed below). This latest version brings thrilling and delicately designed enhancement to WebBrowser and Reflection. Also more namespaces are cleaned up and reinforced. We dare to say this major update could make .NET Extension enlisted among the bests and your must-have. For any suggestion, please do not hesitate to send email to tonyriverms@gmail.com.

Stable Extensions

General Extension (8 methods, 25+ overloads)

DateTime Extension (6 methods, 15+ overloads)

String Extension (51 methods, 200+ overloads)

Regular Expression

Stream Extension

Collection Extension

New Features 2nd Preview

Navigation: Escape & Quotes, Extension Property, EPath

Escape & Quotes

Escapes and quotes are given little support by .NET yet they are common in command and script parsing. For example, the mklink command in windows console requires quotes to enclose path if it contains spaces,

The following line shows how the split method in the above list easily decomposes the mklink command into arguments.

Solution for Extension Property

This extension would not be feasible if it had not been for the extension methods. Likewise, extension properties could be extremely useful in some scenarios. You might have observed a build-in variation of extension property, the dependent property supported by Windows Presentation Foundation. Unfortunately enough, for some reason Microsoft does not plan such “extension properties” in recent future versions of .NET, so we work out a solution to compensate more or less. To associate a timer with a WebBrowser for some purpose like timeout checking, you may use the following codes:

The following is apiece demonstrating how such extension property can help us in to simplify development in an elegant way. Suppose you need to tag a string with its author.

Although this “extension property” is not as pleasing as the extension method, another door to upgrade existing classes is opened. This feature is widely used in implementation of EPath and XCrawler mentioned below.

EPath

It is impossible to control elements on web pages without first locating them. EPath is such a powerful tool that you can use it to select desired elements.

To search something in a tree-like structure like HTML, as we all know, a path is usually the option. Indeed we already have such a well-defined and implemented path named XPath, which is also a build-in component of .NET framework. However, on the one hand targetting general XML, on the other hand inflexible for specific HTML elment search tasks, XPath is rarely used to find web page elements in practice.

EPath, short for Element Path is our newly designed way to accurately express the position of an HTML elment. It is natural-looking, simple while still incorprating the spirits of XPath. The API is very simple. Suppose all elements of class name “btn_2” under all elements of class name “btn_1” are to be selected, you just need

where browser is a System.Windows.Forms.WebBrowser control and GetElements is an extension method with only one parameter. Full documentation about EPath will be released with .NET Extension.

Web Automation (XCrawler)

This is the core part we spare every effort on in the past two months. XCrawler targets at a mechanism as simple as possible for web automation and crawling with full support for active contents and necessary data processing.

You are enabled to construct a crawler represented by XML to cover 90% data of a major website within one hour or two without any need of hard coding. You may adjust the crawlers anytime with a software like Notepad. You are also able to manipulate any element on a web page by marking an element with easy script.

XML-Based Crawlers

XCrawler Data Flow

Go to xcrawler.codeplex.com to know more.

Natural Object Conversion

Natural Object Conversion tries to exploit the type information to understand what a string represents without explict instruction. With this extension, the following astonishing codes become plausible,

var fs = "@d:\test.data, OpenOrCreate, ReadWrite".To<FileStream>();

var matrix = "1,2,3;4,5;6".To<int[][]>();

var pair = "1,2".To<Pair<int>>();

var dict = "key1, 20, key2, 21, key3, 22".To<Dictionary<string, int>>();

var timer = "2000".To<System.Timers.Timer>();

 

//XMAL is automatically recognized and parsed

var xamlObj = "...some XAML...".To<ObjectType>();

The conversion is not only for existing classes but also user-defined ones.

class Foo { public Foo(int x, int y){ } }

var foo = "1,2".To<Foo>();

This functionality comes in extremely handy when the needs for parsing strings as objects arise, for example, when you are developing a matlab-like script or parsing some inline objects in XML.

Old Description Of The First Preview

.NET extension is an enormous library extension over Microsoft .NET platform. It includes 500+ useful, official-looking, well-structured and well-documented extension methods and 100+ new classes that are seamlessly integrated into the original system and facilitate developments of many fields.

With this extension, the following code becomes plausible,

 

 

 

 

String To Object Conversion

Also take a look at the following codes,

 

 

 

 

 

 

Extended System.IO.Stream

These codes demonstrate how the extended System.IO.Stream simplifies our programing. You can search methods related to a specific data type, illustrated below.

 

 

 

 

 

 

Method Search

I have been developing this project ever since 2008. Four years’ accumulation now grows to a scale (more than 100,000 lines of code) that I’m not able to maintain on my own. In the spirit of “one for everyone and everyone for one”, I publish this project hoping that it could be of help to many others and I could also get help from many others.

Well Documented Method

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 Project Overview

 

Although parts of this .NET extension remains not thoroughly debugged or incomplete, many important classes do have been robust enough to be used in even business development.

Now I’m looking forward to people who will help me develop, debug and write documents. Any donation is more than welcome.

Click the following links (most will be available in two weeks) to learn more about our major extensions. These are not formal documentation but will give an insight. You can go to download to retrieve the complete source codes and XML documentation. 

Tree & Binary Tree

New Collections

General Extension

Reflection Extension

String Extension

Array Extension

IO Extension

Network Extension

Random Extension

Math Extension

WinAPI Extension

Interface Extension

Extension of This Week

Last edited Sep 15, 2012 at 12:13 PM by rivermsfly, version 67