Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

.NET

Build Providers in Theory


The key factor that differentiates ASP.NET from other Web development platforms (including classic ASP) is the compilation of requested pages. In the past, each requested page was interpreted and transformed into markup on the fly. But there's a full order of magnitude between the performance of interpreted and compiled code. That is the key factor in the success of ASP.NET.

In ASP.NET 1.x, though, only a few resources were really compiled-the most important and most frequently requested. The list of compiled resources includes Web pages (.aspx resources), ASP.NET Web services (.asmx resources), custom HTTP handlers (.ashx resources), the global application file (global.asax). What else is really worth a compilation?

Web pages, ASP.NET Web services, global.asax and custom HTTP handlers are written as a combination of source code and markup. That content is then parsed and dynamically transformed into a class; the class is then compiled to an assembly and loaded in the application domain.

A number of other auxiliary resources are involved with an ASP.NET application: helper classes, typed DataSets, Web service proxies, resources. In ASP.NET 1.x, all these resources require a compiled class to be fully integrated with the application. However, the developer is responsible for creating such a class with some help from system tools, so developers had to create satellite assemblies for resources, go through wsdl.exe for Web service proxies, and rely on xsd.exe for integrating typed DataSets. In the latter two cases, Visual Studio 2003 helped a lot with wizards, but in the end the compilation of such resources was manual and left to the developer.

The extensible compilation model in ASP.NET 2.0 automates all of these tasks and, in addition, gives developers a chance to integrate any type of data in any format into ASP.NET applications.

In ASP.NET 2.0 applications, any resource can be part of the application regardless of the extension. For example, you can have .xyz files in your Web project whose contents is a chunk of XML data. Normally, unknown file types are just copied to the production machine and consumed by pages in a way that is set in their code. In ASP.NET 2.0, you can create a component named the build provider to take files of a given type and generate a class to wrap the contents. In other words, you can create a component that parses the contents of the .xyz file and come up with a class that is automatically part of the application runtime.

The source code of this class never shows up in the Visual Studio 2005 project; instead it is created in the ASP.NET temporary folder where the source code for .aspx resources is saved. Yet, the class the .xyz resource represents is available to Visual Studio 2005, and it even shows up correctly through Intellisense. Let's go through this with an example.

In ASP.NET 1.x, you import a Web service by clicking on a Visual Studio 2003 menu item and then downloading the WSDL of the selected Web service. Visual Studio 2003 parses the WSDL on the fly and creates a proxy class. This class is named reference.cs or reference.vb and is part of the project. You could also run wsdl.exe offline, get a proxy class and incorporate that with the project. The bottom line is that the proxy class is part of the project; not the WSDL.

In ASP.NET 2.0, all that you have to do is incorporate the WSDL in the project. The same menu item in Visual Studio 2005 just lets you download the WSDL source file and copies it in a reserved folder of the Web application. The ASP.NET 2.0 runtime system, though, knows that .wsdl extension files are to be processed by a tailor-made build provider which will create--dynamically--the proxy class. This model is implemented throughout the whole ASP.NET 2.0 platform and involves a number of file extensions. But this makes good fodder for my next article.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.