/// <summary> /// Install Routes from the specified class /// </summary> /// <param name="addonClass">The class that will be looked up</param> public static void RegisterRoutes(Type addonClass) { Routes.Clear(); Console.WriteLine("REGISTER ROUTES"); var methods = addonClass.GetMethods().Where(m => Attribute.IsDefined(m, typeof(RouteAttribute), false)); Console.WriteLine("Num Attribs: {0}", methods.Count()); foreach (var method in addonClass.GetMethods()) { var attributes = method.GetCustomAttributes(typeof(RouteAttribute), false); if (attributes.Length > 0) { RouteAttribute route = attributes[0] as RouteAttribute; string url = RemoveTrailingSlash(route.Url); RouteCallback callback = method.CreateDelegate(typeof(RouteCallback)) as RouteCallback; //RouteCallback callback = Delegate.CreateDelegate(typeof(RouteCallback), method) as RouteCallback; Routes.Add(url, callback); Console.WriteLine(string.Format("--> Registering route for '{0}'", url)); } } }
public NestedNavigator( GlobalKey <NavigatorState> navigatorKey, string initialRoute, Dictionary <string, WidgetBuilder> routes, RouteCallback onGenerateRoute = null, PopCallback onWillPop = null ) { _navigatorKey = navigatorKey; _initialRoute = initialRoute; _routes = routes; _onGenerateRoute = onGenerateRoute; _onWillPop = onWillPop; }
private void AddRoute(Route route, Queue <string> path, RouteCallback callback, RouteAttribute attribute) { if (path.Count == 0) { route.Attribute = attribute; route.Callback.Add(callback); return; } string name = path.Dequeue(); if (!route.Routes.ContainsKey(name)) { route.Routes.Add(name, new Route()); } AddRoute(route.Routes[name], path, callback, attribute); }
public static void SessionInitializer(string name, Action <Session, Request> callback) { RouteCallback initializer = new RouteCallback ( priority: 1, cb: (req) => { if (req.GetSession(name) == null) { Session s = new Session(name); callback(s, req); return(new PassThrough().AddSession(s)); } return(PassThrough.Skip); } ); Routing.AddHandler(initializer); }
internal static void Add(RouteCallback rc) { RouteCallback_A finalHandler = rc.Callback; if (Server.Config.EnableRouteDiagnostics) { finalHandler = (Request req) => { req.Diagnostics.PushHandler(rc.Callback); Response res = rc.Callback(req); req.Diagnostics.PushResult(res); return(res); }; } int priority = rc.Priority; if (handlers[priority] == null) { handlers[priority] = new List <RouteCallback_A>(1024); } handlers[priority].Add(finalHandler); }
private void AddRoute(string path, RouteCallback callback, RouteAttribute attribute) { AddRoute(_root, new Queue <string>(path.Split('/')), callback, attribute); }
public void Post(string path, RouteCallback callback) { postRoutes.Add(Tuple.Create <string, RouteCallback>(path, callback)); }
public void Get(string path, RouteCallback callback) { getRoutes.Add(Tuple.Create(path, callback)); }
public static extern unsafe CoreRouteInfo *ice_http_server_route_create( string path, RouteCallback callback, CoreResource *call_with );