public void AddProperty(RouteProperty property) { if (property == null) { } properties.Add(property); }
public void Add(RouteProperty routeProperty) { var type = routeProperty.GetType(); if (!cache.ContainsKey(type)) { cache[type] = new Dictionary<RouteLocations, RouteProperty>(); lastAddedCache[type] = new List<RouteProperty>(); } cache[type][routeProperty.Locations] = routeProperty; lastAddedCache[type].Add(routeProperty); if(lastAddedCache[type].Count > itemsInLastAddedCache) lastAddedCache[type].RemoveAt(0); }
public void Add(RouteProperty routeProperty) { var type = routeProperty.GetType(); if (!cache.ContainsKey(type)) { cache[type] = new Dictionary <RouteLocations, RouteProperty>(); lastAddedCache[type] = new List <RouteProperty>(); } cache[type][routeProperty.Locations] = routeProperty; lastAddedCache[type].Add(routeProperty); if (lastAddedCache[type].Count > itemsInLastAddedCache) { lastAddedCache[type].RemoveAt(0); } }
public RouteProperty GetClosest(Type routePropertyType, RouteLocations locations, ParameterizedLocation.Direction direction) { if (!cache.ContainsKey(routePropertyType)) { return(null); } var cacheSection = cache[routePropertyType]; RouteProperty closestRouteProperty = null; ParameterizedLocation closestPL = null; if (locations.IsSpan) { foreach (var item in cacheSection) { if (item.Key.Start == locations.Start // need to have same start && (closestPL == null || (direction == ParameterizedLocation.Direction.Forward && item.Key.End >= locations.End && item.Key.End < closestPL) || (direction == ParameterizedLocation.Direction.Backward && item.Key.End <= locations.End && item.Key.End > closestPL) )) { closestPL = item.Key.End; closestRouteProperty = item.Value; } } } else { foreach (var item in cacheSection) { if (closestPL == null || (direction == ParameterizedLocation.Direction.Forward && item.Key.Location >= locations.Location && item.Key.Location < closestPL) || (direction == ParameterizedLocation.Direction.Backward && item.Key.Location <= locations.Location && item.Key.Location > closestPL) ) { closestPL = item.Key.End; closestRouteProperty = item.Value; } } } return(closestRouteProperty); }
public RoutePropertyType(RouteProperty rp) { Type = rp.GetType(); var rmp = rp as RouteMomentaneousProperty; if (rmp != null) { MomentaneousLocation = rmp.Location; } var rsp = rp as RouteSpanProperty; if (rsp != null) { SpanStart = rsp.Start; SpanEnd = rsp.End; } }