-
Notifications
You must be signed in to change notification settings - Fork 0
Interfaces
This covers some of the most important basics of this library!
Let's go over the more simple first.
All command modules will implement this interface, it is impossible to Register a command without this ValueTask OnCommandExecute(MethodInfo, object, object[], object?)
.
- MethodInfo method - The method being invoked
- object instance - The instance of the type to which the
method
belongs to - object[] invokes - The object instances that were used to invoke the
method
- object? returnInstance - The returned type instance of the
method
if any
This interface is only used by the Handler to log messages like debug, info, warnings, and errors.
We must implement these 5
methods from this interface.
- void Log(string, LogLevel)
- void LogDebug(string)
- void LogInfo(string)
- void LogWarning(string)
- void LogError(string)
These are pretty self explanatory with their arguments, so no need to include the params.
This interface is used to convert objects that cannot be parsed by the IStringHandler
via the primal conversion methods.
Instead it provides the flexibility for you to build upon your own IStringHandler
and create types that can be converted by string.
class Person() { public string name; }
class PersonConverter : IConverter<Person>
{
public ValueTask<Person> Convert(object[] previousArgs, string parse, object[] afterArgs)
{
//Understanding:
//parse = The exact argument that needs to be converted. This is raw string passed in by a user!
//previousArgs/afterArgs = objects passed in by YOU, these can help you create command modules that require a certain object set before or after
var person = new Person();
person.name = parse; //we don't really care about the information that is passed and just want to set the name so it is not null
return parse;
}
}