1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public abstract class Controller<TController> where TController : Controller<TController>, new()
{
protected Dictionary<Type, List<Object>> views;
public static TController Current
{
get
{
string controllerKey = typeof(TController).ToString();
if (HttpContext.Current.Items[controllerKey] == null)
HttpContext.Current.Items[controllerKey] = new TController();
return (TController)HttpContext.Current.Items[controllerKey];
}
}
}
public class SearchController : Controller<SearchController>
{
} |
Partager