This project is read-only.

Reflection Command uses reflection to do invoke/execution based on the specific configuration. It would analyze the command content and then split into different parameters.

 

Command Format:

First, the format of command is: {CommandName} {ParameterName1}={Value1} {ParameterName2}={Value2}.

e.g.: add x=1 y=2

And the pair of parameter name and value can be none or multiple. So below expressions are fit the format.

  • add x=1 y=2 z=3 s=4 t=6
  • add

Separator of the parameters can be space (' '), tab ('\t'), return ('\n'). And multiple  characters  as one separator is also allowed.

But, it is invalid if you want to make some parameter value contain the character which is separator. For example, if you want to make some parameter value be 'I Love You', sorry it is not doable here.

 

The usage and rules of using Configuration are following within a sample:

Configuration: (File name: ReflectionCommand.xml)

 

Codes: (You can find it in sample code)

 

Comments:

  1. Only static methods are allowed to map a command. Because the codes have no idea how to create an instance for some object.
  2. FullName in StaticType node should be the full name of class which contains your static method(s) to run in command.
  3. The node of  StaticType can be one or more.
  4. The Key for each Item node should be found by commander as command name.
  5. The FullName for each Item node should be the full name of static method to run in command.
  6. The parameter name(s) would be mapped with the method declaration dynamically. In sample codes, the parameter name of method Add is x and y, so you just need to add value of x and value of y. It is OK if you change of order of parameters in your command. (Like "c y=3.21           x=0.982 " in sample code, it works well even x is the first parameter in method)
  7. Command names and parameter names are all case sensitive.

 

 

Running Result of the sample codes:

 

 

If you have question or concern, please feel free to let me know.

You can connect me via: rynn.wang@live.com

 

Last edited Nov 26, 2013 at 8:05 AM by rynnwang, version 3