File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 11using JetBrains . Annotations ;
22using SER . Code . ArgumentSystem . BaseArguments ;
3+ using SER . Code . Helpers . Extensions ;
34using SER . Code . Helpers . ResultSystem ;
45using SER . Code . TokenSystem . Tokens ;
56using SER . Code . TokenSystem . Tokens . VariableTokens ;
@@ -24,4 +25,23 @@ public DynamicTryGet<Variable> GetConvertSolution(BaseToken token)
2425
2526 return new ( ( ) => variableToken . TryGetVariable ( ) ) ;
2627 }
28+ }
29+
30+ public class VariableArgument < T > ( string name ) : Argument ( name ) where T : Variable
31+ {
32+ public override string InputDescription => $ "A { typeof ( T ) . FriendlyTypeName ( ) } ";
33+
34+ [ UsedImplicitly ]
35+ public DynamicTryGet < T > GetConvertSolution ( BaseToken token )
36+ {
37+ if ( token is not VariableToken variableToken )
38+ {
39+ return $ "Value '{ token . RawRep } ' is not a variable.";
40+ }
41+
42+ return new ( ( ) => variableToken
43+ . TryGetVariable ( )
44+ . SuccessTryCast < Variable , T > ( )
45+ ) ;
46+ }
2747}
Original file line number Diff line number Diff line change @@ -22,6 +22,11 @@ public class ProvidedArguments(Method method)
2222{
2323 private Dictionary < ( string name , Type type ) , List < DynamicTryGet > > ArgumentValues { get ; } = [ ] ;
2424
25+ public T GetVariable < T > ( string argName ) where T : Variable
26+ {
27+ return GetValue < T , VariableArgument < T > > ( argName ) ;
28+ }
29+
2530 public Database GetDatabase ( string argName )
2631 {
2732 return GetValue < Database , DatabaseArgument > ( argName ) ;
You can’t perform that action at this time.
0 commit comments