This extremely cool article written in the winter of 2007 shows me this code:
public static class TempDataExtensions
{
public static void PopulateFrom(this TempDataDictionary tempData, object o)
{
foreach (PropertyValue property in o.GetProperties())
{
tempData[property.Name] = property.Value;
}
}
public static void PopulateFrom(this TempDataDictionary tempData
, NameValueCollection nameValueCollection)
{
foreach (string key in nameValueCollection.Keys)
tempData[key] = nameValueCollection[key];
}
public static void PopulateFrom(this TempDataDictionary tempData
, IDictionary<string, object> dictionary)
{
foreach (string key in dictionary.Keys)
tempData[key] = dictionary[key];
}
public static string SafeGet(this TempDataDictionary tempData, string key)
{
object value;
if (!tempData.TryGetValue(key, out value))
return string.Empty;
return value.ToString();
}
}
I'm not seeing any code like this in the MVCContrib source or in MVC2 source. This makes me think that I can still use this pattern now without fear of the equivalent functionality already living in the current MVC2 release (might be in MVC3 Preview 1?).
I did not see any update edits to the article. Does this MVC code from 2007 stand the test of time? Is it still ready for now?