Exemple #1
0
        /// <summary>
        /// Returns true if the given key-value pair is relevant for any registered vehicle, false otherwise.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsRelevantForOneOrMore(string key, string value)
        {
            // register at least the default vehicles.
            if (VehiclesByName == null)
            { // no vehicles have been registered.
                Vehicle.RegisterVehicles();
            }

            foreach (var vehicle in VehiclesByName)
            {
                if (vehicle.Value.IsRelevant(key, value))
                { // ok, key is relevant.
                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Tries to the the vehicle given it's unique name.
        /// </summary>
        /// <param name="uniqueName"></param>
        /// <param name="vehicle"></param>
        /// <returns></returns>
        public static bool TryGetByUniqueName(string uniqueName, out Vehicle vehicle)
        {
            if (uniqueName == null)
            {
                throw new ArgumentNullException("uniqueName");
            }

            if (VehiclesByName == null)
            { // no vehicles have been registered.
                Vehicle.RegisterVehicles();
            }
            uniqueName = uniqueName.ToLowerInvariant();
            if (!VehiclesByName.TryGetValue(uniqueName, out vehicle))
            { // vehicle name not registered.
                return(false);
            }
            return(true);
        }