Exemple #1
0
        public static IEnumerable <ConsoleStyle> GetAnsiStyles(this TextDecoration decorations)
        {
            if (!decorations.IsValid())
            {
                throw new ArgumentException($"The { nameof(TextDecoration) } provided must be a valid enum.", nameof(decorations));
            }

            var result = new List <ConsoleStyle>();

            var validDecorations = decorations.GetFlags().Where(d => d != TextDecoration.None);

            foreach (var decoration in validDecorations)
            {
                result.Add(_decorations[decoration]);
            }

            return(result);
        }