public bool Add(IRoute route) { var key = GetKey(route.From, route.To); var result = true; if (_routes.TryGetValue(key, out var routes)) { foreach (var r in routes) { if (route.Equals(r)) { result = false; break; } } } else { routes = new List <IRoute>(); _routes.Add(key, routes); } if (result) { routes.Add(route); OnAddRoute(route); } return(result); }
public override IRouter Register(IRoute route) { if (RegisteredRoutes.All(r => !route.Equals(r))) RegisteredRoutes.Add(route); return this; }