CultureDemo from TechEd Barcelona
nuqneHdir and Qapla' - TechEd Samples

Custom ResourceReader - TechEd Sample

For my presentation at TechEd Barcelona I've created a custom ResourceReader to read localized values from a database instead of using resource files or satellite assemblies. This can be done very easily. All the code can be found on my web site:

1. Create a DBResourceReader class that implements the interface IResourceReader. The important method with this interface is GetEnumerator() that returns an IDictionaryEnumerator that can be used to enumerate the resources of one language. With this method I've read data from the database, stored it inside a Hashtable, and returned the enumerator of this hashtable.

2. Create a DBResourceSet class that derives from ResourceSet. All that's needed is passing a DBResourceReader to the constructor of the base class ResourceSet.

3.  Create a DBResourceManager class that derives from ResourceManager. In this class I'm using the ResourceSets property of the base class to store DBResourceSets of multiple cultures. The method InternalGetResourceSet() must be overridden, so that DBResourceSets are returned. This method is called by the base class ResourceManager when resources are read. Instead of reading resources from the database every time, ResourceSets are put into a Hashtable.

Have fun!

Christian

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

Patrick Steele

Very interesting Christian!

Our company has recently debated storing localization information in resource files/sat assemblies vs. a database. What's your opinion on when to use a database vs. a sat assembly?

Alex Lowe's .NET Blog

AUTHOR: Alex Lowe's .NET Blog
IP: 000.000.000.000
DATE: 08/31/2003 06:07:00 PM

Christian Nagel's OneNotes

AUTHOR: Christian Nagel's OneNotes
IP: 000.000.000.000
DATE: 09/12/2003 08:29:00 AM

Plip's Weblog

AUTHOR: Plip's Weblog
IP: 000.000.000.000
DATE: 02/05/2004 04:39:00 PM

Jeremy

Storing localization information on the database offers the possibility of allowing your customers to manage their own translations, rather than you having to deploy them.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)