public IDictionary <OptionAttribute, PropertyInfo> GetCommandOptions(ICommand command)
{
var result = new Dictionary <OptionAttribute, PropertyInfo>();
foreach (PropertyInfo propInfo in command.GetType().GetProperties())
{
if (!command.IncludedInHelp(propInfo.Name))
{
continue;
}
foreach (OptionAttribute attr in propInfo.GetCustomAttributes(typeof(OptionAttribute), inherit: true))
{
if (!propInfo.CanWrite && !TypeHelper.IsMultiValuedProperty(propInfo))
{
// If the property has neither a setter nor is of a type that can be cast to ICollection<> then there's no way to assign
// values to it. In this case throw.
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
LocalizedResourceManager.GetString("OptionInvalidWithoutSetter"), command.GetType().FullName + "." + propInfo.Name));
}
result.Add(attr, propInfo);
}
}
return(result);
}