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); }
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; }
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(); }