Ejemplo n.º 1
0
        /// <summary>
        /// This method will retrieve a path option from all the configurations, ensuring it has the same value.
        /// If none of the configurations have the option, it will return the fallback value
        /// </summary>
        /// <typeparam name="T">The type of the option to lookup in the configurations.</typeparam>
        /// <param name="configurations">The list of configurations to look into.</param>
        /// <param name="fallback">Optional: Fallback value to return in case none of the configurations have the option.</param>
        /// <param name="rootpath">Optional: The rootpath to convert the path relative to.</param>
        /// <returns></returns>
        public static string GetConfOption <T>(IEnumerable <Project.Configuration> configurations, string fallback = RemoveLineTag, string rootpath = null)
            where T : PathOption
        {
            var values = configurations.Select(conf => PathOption.Get <T>(conf, fallback, rootpath)).Distinct().ToList();

            if (values.Count != 1)
            {
                throw new Error(nameof(T) + " has conflicting values in the configurations, they must all have the same");
            }

            return(values.First());
        }