public static IReadOnlyList <OptionPropertyMetadata> GetPropertiesForType(Type type)
        {
            var result     = new List <OptionPropertyMetadata>();
            var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);

            foreach (var propertyInfo in properties)
            {
                var propertyMetadata = new OptionPropertyMetadata(propertyInfo);

                if (propertyMetadata.HasPositionalIndex ||
                    propertyMetadata.Switches.Any() ||
                    propertyMetadata.OptionAliases.Any())
                {
                    result.Add(propertyMetadata);
                }
            }

            return(result);
        }
 public OptionsMetadata(Type optionsType)
 {
     OptionsType = optionsType;
     Properties  = OptionPropertyMetadata.GetPropertiesForType(optionsType);
 }
        public bool TryGetPropertyByOptionName(string name, out OptionPropertyMetadata property)
        {
            property = Properties.SingleOrDefault(x => x.OptionAliases.Contains(name));

            return(property != null);
        }
        public bool TryGetPropertyByIndex(int index, out OptionPropertyMetadata property)
        {
            property = Properties.SingleOrDefault(x => x.HasPositionalIndex && x.PositionalIndex == index);

            return(property != null);
        }