Beispiel #1
0
        /// <summary>
        /// Merges specified user and default configurations.
        /// </summary>
        /// <param name="userConfig">The user configuration.</param>
        /// <param name="defaultConfig">The default configuration.</param>
        /// <returns>A new configuration object with values stored in the user configuration
        /// if there are any or values stored in the default configuration otherwise.</returns>
        private static RoutesDefaults _Merge(
            RoutesDefaultsConfig userConfig,
            RoutesDefaultsConfig defaultConfig)
        {
            if (userConfig == null)
            {
                userConfig = new RoutesDefaultsConfig();
            }

            return(new RoutesDefaults
            {
                MaxOrder = _Merge(userConfig.MaxOrder, defaultConfig.MaxOrder),
                MaxTotalDuration = _Merge(
                    userConfig.MaxTotalDuration,
                    defaultConfig.MaxTotalDuration),
                MaxTravelDistance = _Merge(
                    userConfig.MaxTravelDistance,
                    defaultConfig.MaxTravelDistance),
                MaxTravelDuration = _Merge(
                    userConfig.MaxTravelDuration,
                    defaultConfig.MaxTravelDuration),
                StartTimeWindow = _Merge(userConfig.StartTimeWindow, defaultConfig.StartTimeWindow),
                TimeAtEnd = _Merge(userConfig.TimeAtEnd, defaultConfig.TimeAtEnd),
                TimeAtRenewal = _Merge(userConfig.TimeAtRenewal, defaultConfig.TimeAtRenewal),
                TimeAtStart = _Merge(userConfig.TimeAtStart, defaultConfig.TimeAtStart),
            });
        }
Beispiel #2
0
        /// <summary>
        /// Converts RoutesDefaults to RoutesDefaultsConfig.
        /// </summary>
        /// <param name="routesDefaults">RoutesDefaults object.</param>
        /// <returns>Converted object.</returns>
        private RoutesDefaultsConfig _ConvertRoutesDefaultsToConfig(RoutesDefaults routesDefaults)
        {
            Debug.Assert(routesDefaults != null);

            RoutesDefaultsConfig routesDefaultsConfig = new RoutesDefaultsConfig();

            routesDefaultsConfig.StartTimeWindow   = routesDefaults.StartTimeWindow;
            routesDefaultsConfig.TimeAtStart       = routesDefaults.TimeAtStart;
            routesDefaultsConfig.TimeAtEnd         = routesDefaults.TimeAtEnd;
            routesDefaultsConfig.TimeAtRenewal     = routesDefaults.TimeAtRenewal;
            routesDefaultsConfig.MaxOrder          = routesDefaults.MaxOrder;
            routesDefaultsConfig.MaxTravelDistance = routesDefaults.MaxTravelDistance;
            routesDefaultsConfig.MaxTravelDuration = routesDefaults.MaxTravelDuration;
            routesDefaultsConfig.MaxTotalDuration  = routesDefaults.MaxTotalDuration;

            return(routesDefaultsConfig);
        }