January 2006 - Posts

As promised in an earlier post I am putting together some ‘extensions’ to go with the January 2006 release of Enterprise Library (or Enterprise Library for .NET 2.0).

Since the extensions share common code, I started out with 2 relative simple nodes: “Configuration Constants Writer” and “Configuration Protector”. These implementations seem trivial but introduce new designtime concepts like “ExtenderProviders” and “DesignerVerbs”, which I’ll need for the other (more complex) extensions.

The implementation of the first 2 extensions are pretty stable (though unlike the p&p dev-team, I don’t have a test-team) and reckoned this might be a good time to put them on the online (and - who knows? - get some feedback).

Configuration Constants Writer
This extension provides compiletime safety when referencing EntLib providers from your code. It maintains a code file with constants that contain the names of the providers you would like to use. If you include this file in your project, you don’t have to worry about changing the names of the providers you used.

Make sure you reference providers by their constant, the constant's value will change after changing the provider’s name.
The Configuration Constants Writer node and its settings.|
The Configuration Constants Writer node and its settings.


A 'Constant name' on a connectionstring node and the code file that is generated.
A 'Constant name' on a connectionstring node and the code file that is generated.



Configuration Protector
The Configuration Protector can be used to encrypt your configuration file to protect sensitive information such as connectionstrings. It uses the .net v2 frameworks Protected Configuration API, which is well documented on MSDN.

The Configuration Protector node and its settings.
The Configuration Protector node and its settings.

Example of a protected Data Access Application block's configuration.
Example of a protected Data Access Application block's configuration.

Password (connectionstring) Parameter
Since we can protect our configuration, it would be a shame to have to edit the connectionstring’s password property in plain text. Therefore I added a “Password Parameter” to the configuration console. The Password Parameter provides a nice UI to edit your databases connectionstring.

Fancy UI to edit a connectionstring's password property.
Fancy UI to edit a connectionstring's password property.

Installation and download
EDIT: Please visit the Enterprise Library Extensions page for the latest download and installation notes.

(Somewhat late to the party....) EntLib for .NET 2.0 shipped last friday!

I feel really proud to have been part of the development team that put this release together and hope it serves you well.

Go get it at the
Enterprise Library for .NET Framework 2.0 landingpage on MSDN.

Just in case it you didn’t know….
Enterprise Library 2.0 is scheduled to ship end of this week!


For all of you that have been using some of the enterprise library extensions I enjoyed coding for the previous version, you are not left out in the cold either.
For this version I plan to rewrite the extensions, add a couple and bundle the whole lot into 1 ‘Extension pack’.

Below is what I’m aiming for. Most of it has been proven to work, though there is still a fair amount of implementing to be done....

ConfigurationConstsWriter
An extension that maintains a codefile with constant declarations for the names of the providers from your configuration.
This basically gives you compiletime validation on the providers you reference from within your code.
(
Read about ConfigurationConstsWriter for EntLib 1)

 
ConfigurationProtector
Adds the ability to the configuration console to encrypt parts of your configurationfile and protect sensitiveinformation such as ConnectionStrings.
This feature uses the Protected Configuration API provided by the .net framework 2.0


NakedConfigurationNode
A generic ConfigurationNode class that can be used to manage *any* ConfigurationSection (either yours or the frameworks) in the configuration console.
(Somewhat similar to:
This little widget, that never actually made it)

EnvironmentalOverrides
Allows you to manage configuration over different environments from within the configuration console and keep them consistent.
(
Read about EnvironmentalOverrides for EntLib 1)

 

For the development of this Extension pack I opened a GDN Workspace at http://workspaces.gotdotnet.com/EntLib2Ex.
If you want to help me develop the above or have some other feedback or suggestions......please feel welcome to join :-)


Since the extensions are build on EntLib for .net 2.0, the workspace will be empty until the actual release.

"Web 2.0” applications aim at being more interactive by eliminating full page requests (and the flickering of pages between requests).
Ever since google released GMail this has been all the hype amongst web developers.

Even though this overcomes one of the usability problems we currently have with web applications, I think the biggest usability problem still remains the 1-2 second wait for a response from the server after clicking.


Hence, a silly idea I had…: What if hyperlinks would preload their target?

When browsing pages in content-centric environments you could easily use the time in between reading and clicking on a hyperlink to load the page someone navigates to on its next click. Even though preloading all links doesn’t seem like a good idea, preloading the 5 most possible succeeding pages would decrease the average wait time significantly.

Imagine a wiki that preloads the referred pages from the current entry.

…Or a searchengine that preloads the first 5 search results?

…Or a weblog engine that preloads linked pages?

Preloading rules could also be based on log file analysis, to reflect a common usage pattern or be hard coded into the html.

Below is a little example implementation that preloads all hyperlinks that have an attribute called “PreLoad” set to “true” (for example: <a href="NextPage.aspx" PreLoad="true" />). The code below might have some side effects for pages that otherwise rely on javascript (which should be easily overcome) but should give you a view on how what I meant.

<script type="text/javascript">

    Function.prototype.ExecuteWhenHttpRequestFinished=function(HttpReq, Object) {

      var r=HttpReq;

      var t=this;

      var o=Object;

      return function() {

          if (r.readyState == 4 && r.status == 200)

            t(r, o);

      }

    }

    function PreLoadHyperlinks() {

        var linksCollection = document.getElementsByTagName("a");

        for(i=0; i<linksCollection.length; i++){

            if (linksCollection[i].getAttribute("PreLoad") == "true") {

                new LinkLoader(linksCollection[i]).PreLoadTarget();

            }

        }

    }

    function GetHttpRequest() {

        try {

            return new XMLHttpRequest();

        } catch(e) {

            try {

                return  new ActiveXObject("Microsoft.XMLHTTP");

            } catch(e) { }

        }

    }

    function LinkLoader(hyperlink) {

        this.Hyperlink = hyperlink;

       

        this.PreLoadTarget=function() {

            var HttpReq = GetHttpRequest();

            HttpReq.open("GET", this.Hyperlink.href, true);

            HttpReq.onreadystatechange = this.BufferDocument.ExecuteWhenHttpRequestFinished(HttpReq, this.Hyperlink);

            HttpReq.send("");

        }

       

        this.BufferDocument=function(HttpReq, Object) {

            Object.targetDocument = HttpReq.responseText;

            Object.href="#";

            Object.onclick = function(){

                document.body.innerHTML = this.targetDocument;

                PreLoadHyperlinks();

            }

        }

    }

   

    window.onload = PreLoadHyperlinks;

    </script>