C# Class DotNetify.Routing.RoutableExtension

Exibir arquivo Open project: dsuryd/dotNetify Class Usage Examples

Public Methods

Method Description
GetRoute ( this routable, string templateId, string path = null ) : DotNetify.Routing.Route

Defines a route from a route template that belongs to the view model.

InitArgs ( this routable, object viewData ) : string

Returns HTML data attribute markup that contains routing initialization arguments. This needs to be placed in the same DOM element that has the "data-vm" attribute.

OnActivated ( this iRoutable, EventHandler eventHandler ) : void

Handles the activate event, which occurs when a route is being activated.

OnRouted ( this routable, EventHandler eventHandler ) : void

Handles the routed event, which occurs when this view model is being routed to.

Redirect ( this routable, string redirectRoot, string path ) : DotNetify.Routing.Route

Defines a route that belongs to another view model.

RegisterRoutes ( this routable, string root, List routeTemplates ) : void

Registers route templates.

Route ( RoutingViewData &viewData, IRoutable &oModel ) : string

Call this method from the controller to perform routing.

RouteUrl ( this routable, RoutingViewData &viewData ) : void

Performs routing. The URL path is given inside the view data, along with the initial route template to start from. This is a recursive method that will be called again by the nested views until the route is resolved.

Private Methods

Method Description
Match ( string urlPath, string root, string urlPattern, string &oPath ) : bool

Matches the URL path with the given URL pattern.

MatchTemplate ( List templates, string urlPath, string rootPath ) : string>?.KeyValuePair

Matches a URL path to any of the route templates.

Method Details

GetRoute() public static method

Defines a route from a route template that belongs to the view model.
public static GetRoute ( this routable, string templateId, string path = null ) : DotNetify.Routing.Route
routable this Routable view model.
templateId string Identifies a template that belongs to this view model.
path string Optional path, to be used to replace parameterized template's URL pattern.
return DotNetify.Routing.Route

InitArgs() public static method

Returns HTML data attribute markup that contains routing initialization arguments. This needs to be placed in the same DOM element that has the "data-vm" attribute.
public static InitArgs ( this routable, object viewData ) : string
routable this Routable view model.
viewData object Routing view data.
return string

OnActivated() public static method

Handles the activate event, which occurs when a route is being activated.
public static OnActivated ( this iRoutable, EventHandler eventHandler ) : void
iRoutable this Routable view model.
eventHandler EventHandler Activate event handler.
return void

OnRouted() public static method

Handles the routed event, which occurs when this view model is being routed to.
public static OnRouted ( this routable, EventHandler eventHandler ) : void
routable this Routable view model.
eventHandler EventHandler Routed event handler.
return void

Redirect() public static method

Defines a route that belongs to another view model.
public static Redirect ( this routable, string redirectRoot, string path ) : DotNetify.Routing.Route
routable this Routable view model.
redirectRoot string Root path of the route. If the path partially matches the view model's root path, they will be combined.
path string Route path.
return DotNetify.Routing.Route

RegisterRoutes() public static method

Registers route templates.
public static RegisterRoutes ( this routable, string root, List routeTemplates ) : void
routable this Routable view model.
root string Root path to which all other paths will be evaluated.
routeTemplates List Route templates that belong to the view model.
return void

Route() public static method

Call this method from the controller to perform routing.
public static Route ( RoutingViewData &viewData, IRoutable &oModel ) : string
viewData RoutingViewData Routing view data.
oModel IRoutable Model to be passed to the view.
return string

RouteUrl() public static method

Performs routing. The URL path is given inside the view data, along with the initial route template to start from. This is a recursive method that will be called again by the nested views until the route is resolved.
public static RouteUrl ( this routable, RoutingViewData &viewData ) : void
routable this Routable view model.
viewData RoutingViewData Routing view data.
return void