private static IEnumerable <RouteInfo> GetRoutes(IServiceScopeFactory factory) { using (var scope = factory.CreateScope()) { foreach (var controller in scope.ServiceProvider.GetServices <IController>()) { var ctype = controller.GetType(); foreach (var mi in ctype .GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) .Where(x => x.ReturnType == typeof(ActionResult) || x.ReturnType.BaseType == typeof(ActionResult))) { yield return(RouteInfo.Create(ctype, mi)); } } } }
public void ConnectTo(Route destination, int price) { RouteInfo.Create(price, this, destination); }