ASP.NET MVC TempData Extension Methods - DONN FELKER: "public static class TempDataExtensions
{
public static void Put(this TempDataDictionary tempData, T value) where T : class
{
tempData[typeof(T).FullName] = value;
}
public static void Put(this TempDataDictionary tempData, string key, T value) where T : class
{
tempData[typeof(T).FullName + key] = value;
}
public static T Get(this TempDataDictionary tempData) where T : class
{
object o;
tempData.TryGetValue(typeof(T).FullName, out o);
return o == null ? null : (T)o;
}
public static T Get(this TempDataDictionary tempData, string key) where T : class
{
object o;
tempData.TryGetValue(typeof(T).FullName + key, out o);
return o == null ? null : (T)o;
}
}"
'via Blog this'
No comments:
Post a Comment