August 2008 Blog Posts
Enterprise Library Validation MessageTemplate Tokens

I always forget... pulled from MSDN with my notes added in italics:

Understanding Message Template Tokens

Custom message templates can contain tokens. The validator replaces these tokens with values before it adds the resulting message to an instance of the ValidationResult class. Tokens are represented by using the strings {0}, {1}, {2}, and so on within the message template strings. All validators provided by the Validation Application Block use the first three tokens {0}, {1}, and {2} for the same purposes. Different validators may also understand additional tokens, beginning with {3}. The following table describes tokens {0}, {1}, and {2}.




This token represents the value of the object that is being validated. Although it can be useful to show the original value as a part of the validation message, you must be careful to avoid injection attacks by escaping any characters that can be used to attack the system that conveys the message to the user.

In simple terms: returns "ObjectBeingValidatedFullTypeName+Field"


This token represents the key of the object that is being validated. When the validator is attached to a member of a type such as a property or a field, the key is set to the member name. When the validator is attached to an object, the key is null and the token is replaced by an empty string.

In simple terms: returns "Field" name being validated


This token represents the tag that is specified on the validator instance. If no tag is supplied, the token is replaced by an empty string.

In simple terms: returns contents of [Validator Tag="foo"] property defined in the attribute.

Add Comment Filed Under [ Tips & Tricks C# ]
Fluent C Sharp Language Extension Helpers - Part 1

So, I found myself doing a lot of for( int i = 0; i < n; i++ ){} stuff lately.  So, I've decided to try something new. I've started a small collection of "Fluent Helpers" that alleviate a lot of the verbosity in C#.

About 28 characters (including spaces) for a simple for loop to do some constant iteration.

for( int i = 0; i < n, i++){

About 18 characters to do this (no pun intended):

Do.This( 5, () =>{

Here's an example:

   51             Do.This( 5,

   52                     () =>

   53                         {

   54                             Console.Write( "Hello " );

   55                             Console.WriteLine( "World!" );

   56                         }

   57                 );


Hello World!
Hello World!
Hello World!
Hello World!
Hello World!

Now that feels much better on my hands, and looks much cleaner too, IMHO.  Here's the simple implementation for Do.This:

   42     public static class Do

   43     {

   44         public static void This(int times, Action what)

   45         {

   46             for( int i = 0; i < times; i++ )

   47             {

   48                 what();

   49             }

   50         }

   51     }

I've already started a little library of these small syntax helpers I've collected.  If you have any suggestions, please share! cool0003.gif

-Brian Chavez

Add Comment Filed Under [ Tips & Tricks C# ]
NHibernate 2.0 GA released!

Per Fabio's Post, NHibernate 2.0 has been released:

NHibernate 2.0.0.GA is released today
Enjoy it!
We start the work for NH2.0.0SP1
~20 days to:
- support parameters in HQLFunctions
- minors change in tests
- improv for some dialects
- some other minors
And we hope nothing tremendous happen ;)
Fabio Maulo
The human knowledge belong to the world

Go grab the download and upgrade today! :)

-Brian Chavez

Add Comment Filed Under [ NHibernate ]
Visual Studio 2008 SP1 and .NET 3.5 SP1 RTM

imageVisual Studio 2008 SP1 (Service Pack 1) is ready for download. 


Click below for the links:

VS2008 SP1 EXE Installer:


VS2008 SP1 ISO Installer:


Happy updating!

-Brian Chavez

Add Comment Filed Under [ ASP.NET C# ]