public string ResolvePath(BeatrixPage page, string rawUrl)
        {
            var controllerAttribute = page
                .GetType()
                .GetCustomAttributes(true)
                .SingleOrDefault(x => typeof(ControllerAttribute).IsAssignableFrom(x.GetType())) as ControllerAttribute;

            var controllerName = (controllerAttribute != null)
                ? controllerAttribute.ControllerType.Name
                : BeatrixConventions.Instance.GetControllerNameFromPage(page);

            int urlStartIndex = (page.Url == "/")
                ? 0
                : page.Url.Length;

            return string.Concat(
                "/",
                BeatrixConventions.Instance.GetRouteFromControllerName(controllerName),
                rawUrl.Substring(urlStartIndex)
                ).TrimEnd('/').ToLower();
        }
Example #2
0
 public string GetDefaultControllerNameFromPage(BeatrixPage page)
 {
     var name = page.GetType().Name;
     return string.Concat(name.Substring(0, name.LastIndexOf("Page")), "Controller");
 }
 protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType, BeatrixPage page)
 {
     return Container.With(page.GetType(), page).GetInstance(controllerType) as IController;
 }
 protected virtual IController GetControllerInstance(RequestContext requestContext, Type controllerType, BeatrixPage page)
 {
     var constructor = controllerType.GetConstructor(new Type[] { page.GetType() });
     return constructor.Invoke(new [] { page }) as IController;
 }