示例#1
0
        /// <summary>
        /// Returns a <see cref="string"/> that represents the provided configuration.
        /// </summary>
        /// <param name="name">The configuration's name.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>A <see cref="string"/> that represents the provided configuration.</returns>
        protected static string DescribeSubConfiguration(string name, ConfigurationBase configuration)
        {
            var descriptionBuilder = new StringBuilder();

            descriptionBuilder.AppendLine($"{name} : {{");
            foreach (var line in configuration.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                descriptionBuilder.AppendLine(Indent + line);
            }

            descriptionBuilder.AppendLine("}");

            return(descriptionBuilder.ToString());
        }
示例#2
0
        /// <summary>
        /// Casts a configuration of type <see cref="ConfigurationBase"/> to the provided type.
        /// </summary>
        /// <typeparam name="TConfiguration">The type of the configuration.</typeparam>
        /// <param name="configuration">The configuration.</param>
        /// <returns>The cast configuration.</returns>
        /// <exception cref="ArgumentException">Thrown if the cast is unsuccessful.</exception>
        public static TConfiguration CastToConfigurationType <TConfiguration>(ConfigurationBase configuration)
            where TConfiguration : ConfigurationBase
        {
            switch (configuration)
            {
            case null:
                return(null);

            case TConfiguration correctTypeFallback:
                return(correctTypeFallback);

            default:
                throw new ArgumentException(
                          $"Configuration should be {typeof(TConfiguration)} but is {configuration.GetType()}.",
                          nameof(configuration));
            }
        }
示例#3
0
 /// <summary>
 /// Checks whether two <see cref="ConfigurationBase"/>s are compatible for one to be used in a continued run
 /// based on a run using the other.
 /// </summary>
 /// <param name="other">Configuration used for the start of tuning.</param>
 /// <returns>True iff this configuration can be used for continued run.</returns>
 public abstract bool IsCompatible(ConfigurationBase other);
示例#4
0
 /// <summary>
 /// Checks whether two <see cref="ConfigurationBase"/>s are compatible in a technical sense for one
 /// to be used in a continued run based on a run using the other.
 /// <para>The difference to <see cref="IsCompatible"/> is that this function only checks for technical
 /// compatibility and does not consider whether the combination of configurations is compatible in the sense
 /// that the continued run looks like a longer single run.</para>
 /// </summary>
 /// <param name="other">Configuration used for the start of run.</param>
 /// <returns>True iff this configuration can be used for continued run.</returns>
 public abstract bool IsTechnicallyCompatible(ConfigurationBase other);