SharePoint Dev Kata 2 – Working With Resource Files

One of the practices I’m trying to improve on in my teams is working with string literals. In Feature XML files, for instance, we can set the DisplayName of a Site Column to pull from a localized resource file instead of being hard-coded. See here for an introduction by Ton Stegeman. In addition to being able to localize the values, the resource file creates a strongly-typed “code behind”, if you like, which is a wrapper resource manager to allow you to access the values from code directly. This Kata is about practicing the pieces of this.

Here are the steps:

  1. Create a new Feature called “Testing Resources Feature”
  2. Add a Site Column called “My Test Column”
  3. Add a Resource file
  4. Create entries in the Resource File for these two strings
  5. Use the strings in the Feature and Site Columns xml files
  6. Modify the Site Column’s “Name” property to also use a Resource setting
  7. Create a new list definition in the Feature to use the new Site Column
  8. Add an item to the list in the Feature Receiver and use the strongly-typed Resource key to access the field
 

Leave a Reply