CommandParameter
Wraps a ParameterInfo from a command method, providing type metadata and string-to-value conversion via CommandParameterParser.
Definition
Namespace: Paragon.Core.Command Assembly: Paragon.dll
public class CommandParameterRemarks
CommandParameter instances are created by CommandMethod during construction. Each wraps a single method parameter and provides:
Type metadata — The parameter's
TypeandNameString parsing —
SetValueFromString()delegates toCommandParameterParser.Parse()to convert a string input to the parameter's expected typeValue storage — The parsed value is stored in
Valuefor later use during invocation
The constructor is private. Instances are created via the static Create() factory method.
Quick Lookup
Create from ParameterInfo
CommandParameter.Create(parameterInfo)
Parse a string value
parameter.SetValueFromString("42")
Read the parsed value
parameter.Value
Get parameter type
parameter.Type
Get parameter name
parameter.Name
Properties
Type
The CLR type of the parameter (e.g., typeof(int), typeof(string)).
Name
The parameter name as declared in the method signature.
Value
The parsed value after calling SetValueFromString(). Initially null until a value is parsed.
Methods
Create
Factory method that creates a CommandParameter from a ParameterInfo.
parameterInfo
ParameterInfo
The reflected parameter info
Returns: A new CommandParameter wrapping the given parameter.
SetValueFromString
Parses a string input into the parameter's expected type and stores the result in Value.
input
string
String representation of the value
Delegates to CommandParameterParser.Parse(Type, input) for conversion.
Common Pitfalls
Value is null before SetValueFromString The Value property returns null until SetValueFromString() is called. Always parse before reading.
Unsupported types throw KeyNotFoundException If the parameter type does not have a registered parser in CommandParameterParser, calling SetValueFromString() throws a KeyNotFoundException. Default parsers support: int, float, string.
Examples
Basic Usage (internal to Command system)
See Also
CommandMethod — Creates and owns
CommandParameterinstancesCommandParameterParser — Performs the actual string-to-value conversion
Command — Orchestrates parameter parsing during
Execute()
Last updated