1
如何創建從數據庫讀取設置的應用程序範圍實用程序/管理器類?我應該使用靜態類,例如在asp.net中創建和存儲實用程序/管理器類的正確方法mvc
public static class ThemeHelper
{
private static string themeDirectory { get; private set; }
static ThemeHelper()
{
// read from the database
themeDirectory = "blue-theme";
}
public static string ResolveViewPath(string viewName)
{
string path = string.Format("~/themes/{0}/{1}.aspx", themeDirectory, viewName);
// check if file exists...
// if not, use default
return path;
}
}
或者一個普通類的靜態實例,它存儲在HttpApplicationState中,例如? 還是應該使用依賴注入庫(如Ninject)?