How Commander uses Annotations
As you have read in Command Resolution the Commander can automatically resolve Command implementation on certain places (e.g. EntryAssembly or directory). Auto resolution will scan for Command-Annotated classes and store them in a list of CommandDesriptors
.
It is key to understand Command resolution and execution is a two steps process:
Resolve all annotated classes
store the results in the Commander's
public List<CommandDescriptor> CommandDescriptors
property.
Find the verb-matching Command in the
CommandDescriptors
listcreate the Command instance
run the Command's
Execute()
method
Interesting to see, that you have the chance to register additional command-descriptors between step 1 and 2 (see Sample03.Options).
A similar mechanism is used to resolve Options (better OptionDescriptors
and its Properties) and you can add your own Options without annotating properties SetOption
. You can also modify or remove Options before the Command is finally executed.
Last updated