本文整理汇总了C#中System.Web.Mvc.ControllerContext.GetControllerName方法的典型用法代码示例。如果您正苦于以下问题:C# ControllerContext.GetControllerName方法的具体用法?C# ControllerContext.GetControllerName怎么用?C# ControllerContext.GetControllerName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.ControllerContext
的用法示例。
在下文中一共展示了ControllerContext.GetControllerName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
public object GetData(ControllerContext context, QueryParameters parameters)
{
var repositoryName = context.GetControllerName() + "repository";
var repository =
Locator.GetAllInstances(typeof(IDynamicRepository)).FirstOrDefault(
o => o.GetType().Name.ToLowerInvariant() == repositoryName);
if (repository == null)
{
throw new Exception(string.Format("Could not locate a repository named '{0}'", repositoryName));
}
return repository.GetType().GetMethod("All").Invoke(repository, null);
}
示例2: NavigationLink
public NavigationLink(ControllerContext context,
string controllerName, string actionName, string title)
{
var logger = ObjectFactory.GetInstance<Logger>();
if (context == null)
{
logger.Error("[ViewModels].[Management].[NavigationLink()] throwing exception ([context] == null).");
throw new ArgumentNullException("context");
}
if (title == null)
{
logger.Error("[ViewModels].[Management].[NavigationLink()] throwing exception ([title] == null).");
throw new ArgumentNullException("title");
}
IsEnabled = context.GetControllerName() != controllerName;
Url = context.ResolveUrl(controllerName, actionName);
Title = title;
}
示例3: GetVirtualPath
string GetVirtualPath(ControllerContext controllerContext)
{
string controllerName = controllerContext.GetControllerName();
string actionName = controllerContext.GetActionName();
string areaName = controllerContext.GetAreaName();
string path = VirtualPath;
if (string.IsNullOrEmpty(areaName))
{
path = path.Replace("{area}", "");
}
else
{
path = path.Replace("{area}", areaName + "/");
}
path = path.Replace("{controller}", controllerName);
path = path.Replace("{action}", actionName);
path += ".____html";
//return path;
return System.Web.Hosting.HostingEnvironment.MapPath(path).ToLower();
}