-
Notifications
You must be signed in to change notification settings - Fork 0
dev:Command
Väinämö Łūmikērø edited this page Feb 2, 2017
·
3 revisions
Provides functions to validate and parse commands. See Command Handling for further information.
Command(string name, string @namespace, string definer = "\\/")
Command(string name, F2Core.Extension.IExtension extension, string definer = "\\/")
-
string
name
The name of this command. Can only contain letters, numbers and-
. -
string
@namespace
The namespace of the extension registering this command. -
F2Core.Extension.IExtension
extension
The extension registering this command. -
string
definer
Optional. Change if the command should not be invoked with a leading slash/
.
Needs be to escaped for regex.
-
string
Definer
The sequence defining the invokation of this command. By default a leading slash/
. -
string
Name
The name of this command. -
string
Namespace
The namespace of the extension registering this command.
void AddParameter<T>(string name, int index, F2Core.Command.ParameterType parameterType) where T : IConvertible
Add a new parameter to the command.
-
T
<T>
The type the parameter requires. Can bestring
,bool
,double
orint
as of now. -
string
name
The name of this parameter. Can only contain letters, numbers and-
. -
int
index
Defines the order of this parameter. Needs to be distinct. Required parameters cannot follow optional parameters. -
F2Core.Command.ParameterType
parameterType
Defines whether the parameter isParameterType.Optional
orParameterType.Required
.
T Parse<T>(string content, string parameter) where T : IConvertible
Parses a command and returns the parameter value or the default value of the parameter type if the command doesn't match.
-
T
<T>
The type the parameter requires. Can bestring
,bool
,double
orint
as of now. -
string
content
The content to parse. -
string
parameter
The parameter value to return. -
T
(return)
Returns the parsed value or the default value of T.
bool Validate(string content)
Validates a command.
-
string
content
The content to validate. -
bool
(return)
Returns true if the content matches the command pattern.