Exemplo n.º 1
0
 /// <summary>
 /// Defines all values in the given type.
 /// </summary>
 /// <param name="type">Type to inspect.</param>
 protected void AddValuesFromType(IEnumArgumentType type)
 {
     foreach (var value in type.GetValues())
     {
         AddValue(value);
     }
 }
Exemplo n.º 2
0
        private IEnumerable <ColoredMultistring> GetEnumValueEntries(IEnumArgumentType type)
        {
            var values = type.GetValues()
                         .Where(v => !v.Disallowed && !v.Hidden)
                         .OrderBy(v => v.DisplayName)
                         .ToList();

            // See if we can collapse the values onto one entry.
            if (values.All(v => string.IsNullOrEmpty(v.Description) && v.ShortName == null))
            {
                return(new[] { new ColoredMultistring($"{{{string.Join(", ", values.Select(v => v.DisplayName))}}}") });
            }
            else
            {
                return(values.Select(FormatEnumValueInfo));
            }
        }
Exemplo n.º 3
0
        private IEnumerable <ColoredMultistring> GetEnumValueEntries(
            int currentMaxWidth,
            IEnumArgumentType type)
        {
            var values = type.GetValues()
                         .Where(v => !v.Disallowed && !v.Hidden)
                         .OrderBy(v => v.DisplayName)
                         .ToList();

            // See if we can collapse the values onto one entry.
            if (values.All(v => string.IsNullOrEmpty(v.Description) && v.ShortName == null))
            {
                return(new[] { new ColoredMultistring($"{{{string.Join(", ", values.Select(v => v.DisplayName))}}}") });
            }
            else
            {
                var entries = values.Select(GetEnumValueInfo).ToList();
                var maxLengthOfParameterSyntax = entries.Count > 0 ? entries.Max(e => e.Syntax.Length) : 0;
                return(FormatParameterEntries(currentMaxWidth, entries, maxLengthOfParameterSyntax));
            }
        }