Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SetUserSetting.cs
1using System.Threading.Tasks;
7
9{
14 {
25 : base(new ScriptNode[] { User, Name, Value }, argumentTypes3Scalar, Start, Length, Expression)
26 {
27 }
28
32 public override string FunctionName => nameof(SetUserSetting);
33
37 public override string[] DefaultArgumentNames => new string[] { "User", "Name", "Value" };
38
43 public override bool IsAsynchronous => true;
44
52 {
53 return this.EvaluateAsync(Arguments, Variables).Result;
54 }
55
62 public override async Task<IElement> EvaluateAsync(IElement[] Arguments, Variables Variables)
63 {
64 string User = await GetSetting.GetUser(Arguments[0].AssociatedObjectValue, this);
65
66 if (string.IsNullOrEmpty(User))
67 throw new ScriptRuntimeException("User not defined.", this);
68
69 string Name = ToString(Arguments[1]);
70 object Value = Arguments[2].AssociatedObjectValue;
71 bool Result;
72
73 Result = await UserSettings.SetAsync(User, Name, Value);
74
75 return new BooleanValue(Result);
76 }
77 }
78}
Static class managing persistent user settings. User settings default to runtime settings if user-spe...
Definition: UserSettings.cs:18
static async Task< bool > SetAsync(string User, string Key, string Value)
Sets a string-valued setting.
Definition: UserSettings.cs:77
Class managing a script expression.
Definition: Expression.cs:41
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
static readonly ArgumentType[] argumentTypes3Scalar
Three scalar parameters.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
override string ToString()
Definition: ScriptNode.cs:359
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Boolean-valued number.
Definition: BooleanValue.cs:12
Gets a runtime setting with name Name. If Host is provided, the function first tries to get the corre...
Definition: GetSetting.cs:18
static async Task< string > GetUser(object Value, ScriptNode Node)
Gets the host name from a value.
Definition: GetSetting.cs:124
Sets a runtime user setting with name Name to the value Value. User defines the user.
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
override string[] DefaultArgumentNames
Default Argument names
override string FunctionName
Name of the function
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the function.
SetUserSetting(ScriptNode User, ScriptNode Name, ScriptNode Value, int Start, int Length, Expression Expression)
Sets a runtime user setting with name Name to the value Value. User defines the user.
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21