Usage:
GlobalAppParameter gp = GetSession<GlobalAppParameter>("gp", delegate {
return GlobalAppParameter.NewGlobalAppParameter();
});
protected delegate T CallBack<T>();
protected T GetSession<T>(string sessionName, CallBack<T> callBack ){ T ret;
if (Session[sessionName] == null)
{
ret = callBack();
Session[sessionName] = ret;
}
else
ret = (T) Session[sessionName];
return ret;
}
No comments:
Post a Comment