/// <summary> /// Defines a route from a route template that belongs to the view model. /// </summary> /// <param name="routable">Routable view model.</param> /// <param name="templateId">Identifies a template that belongs to this view model.</param> /// <param name="path">Optional path, to be used to replace parameterized template's URL pattern.</param> /// <returns>Route object to be bound to vmRoute on the view.</returns> public static Route GetRoute(this IRoutable routable, string templateId, string path = null) { if (routable.RoutingState == null) { routable.RoutingState = new RoutingState(); } RouteTemplate template = null; if (routable.RoutingState.Templates != null) { template = routable.RoutingState.Templates.FirstOrDefault(i => i.Id == templateId); } if (template == null) { throw new InvalidOperationException(String.Format("ERROR: Route template '{0}' was not found.", templateId)); } return(new Route { TemplateId = template.Id, Path = path ?? template.UrlPattern }); }
public RoutingViewData(string iUrlPath, string iViewUrl, Type iVMType) { UrlPath = iUrlPath; ActiveTemplate = new RouteTemplate { ViewUrl = iViewUrl, VMType = iVMType }; Root = Origin = ""; }
public RoutingViewData(string urlPath, string viewUrl, Type vmType) { UrlPath = urlPath; ActiveTemplate = new RouteTemplate { ViewUrl = viewUrl, VMType = vmType }; Root = Origin = ""; }