File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
MethodSystem/Methods/DatabaseMethods Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ using SER . ArgumentSystem . Arguments ;
2+ using SER . ArgumentSystem . BaseArguments ;
3+ using SER . Helpers . Exceptions ;
4+ using SER . MethodSystem . BaseMethods ;
5+ using SER . MethodSystem . MethodDescriptors ;
6+
7+ namespace SER . MethodSystem . Methods . DatabaseMethods ;
8+
9+ public class AppendDBMethod : SynchronousMethod , ICanError
10+ {
11+ public override string Description => "Adds a key-value pair to the database." ;
12+
13+ public string [ ] ErrorReasons =>
14+ [
15+ "Provided value cannot be stored in databases"
16+ ] ;
17+
18+ public override Argument [ ] ExpectedArguments =>
19+ [
20+ new DatabaseArgument ( "database" ) ,
21+ new TextArgument ( "key" ) ,
22+ new AnyValueArgument ( "value" )
23+ ] ;
24+
25+ public override void Execute ( )
26+ {
27+ if ( Args . GetDatabase ( "database" ) . Set (
28+ Args . GetText ( "key" ) ,
29+ Args . GetAnyValue ( "value" )
30+ ) . HasErrored ( out var error ) )
31+ throw new ScriptRuntimeError ( error ) ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments