Christian Nagel's OneNotes

.NET Training, Consulting, Coaching - C#, Web Services, Enterprise Services, ASP.NET, Whidbey, Longhorn and More!

Sponsors

Affiliations

Books I've written

INETA UG Leaders

My Blogroll

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

Posted: Jul 06 2003, 08:55 PM by CNagel | with 7 comment(s)
Filed under:

Comments

Patrick Steele said:

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?
# July 6, 2003 12:58 PM

TrackBack said:

Christian Nagel's OneNotes
# July 6, 2003 2:55 PM

TrackBack said:

# August 31, 2003 12:07 PM

TrackBack said:

# September 12, 2003 2:29 AM

TrackBack said:

# February 5, 2004 10:39 AM

Jeremy said:

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.
# May 26, 2004 6:01 AM

Angry Coder said:

I could not access the presentation and the sample code.

# February 16, 2009 7:52 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)