internal static CommandLineAction Create(PropertyInfo actionProperty, List<string> knownAliases)
{
var ret = PropertyInitializer.CreateInstance<CommandLineAction>();
ret.ActionMethod = ArgAction.ResolveMethod(actionProperty.DeclaringType, actionProperty);
ret.Source = actionProperty;
ret.Arguments.AddRange(new CommandLineArgumentsDefinition(actionProperty.PropertyType).Arguments);
ret.IgnoreCase = true;
if (actionProperty.DeclaringType.HasAttr<ArgIgnoreCase>() && actionProperty.DeclaringType.Attr<ArgIgnoreCase>().IgnoreCase == false)
{
ret.IgnoreCase = false;
}
if (actionProperty.HasAttr<ArgIgnoreCase>() && actionProperty.Attr<ArgIgnoreCase>().IgnoreCase == false)
{
ret.IgnoreCase = false;
}
ret.Metadata.AddRange(actionProperty.Attrs<IArgMetadata>().AssertAreAllInstanceOf<ICommandLineActionMetadata>());
// This line only calls into CommandLineArgument because the code to strip 'Args' off the end of the
// action property name lives here. This is a pre 2.0 hack that's only left in place to support apps that
// use the 'Args' suffix pattern.
ret.Aliases.AddRange(CommandLineArgument.FindDefaultShortcuts(actionProperty, knownAliases, ret.IgnoreCase));
return ret;
}