Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SetSetting.cs
1using System.Threading.Tasks;
6
8{
13 {
23 : base(new ScriptNode[] { Name, Value }, argumentTypes2Scalar, Start, Length, Expression)
24 {
25 }
26
37 : base(new ScriptNode[] { Host, Name, Value }, argumentTypes3Scalar, Start, Length, Expression)
38 {
39 }
40
44 public override string FunctionName => nameof(SetSetting);
45
49 public override string[] DefaultArgumentNames => new string[] { "Name", "Value" };
50
55 public override bool IsAsynchronous => true;
56
64 {
65 return this.EvaluateAsync(Arguments, Variables).Result;
66 }
67
74 public override async Task<IElement> EvaluateAsync(IElement[] Arguments, Variables Variables)
75 {
76 int i = 0;
77 int c = Arguments.Length;
78 string Host = c < 3 ? null : GetSetting.GetHost(Arguments[i++].AssociatedObjectValue, this);
79 string Name = Arguments[i++].AssociatedObjectValue?.ToString();
80 object Value = Arguments[i].AssociatedObjectValue;
81 bool Result;
82
83 if (string.IsNullOrEmpty(Host))
84 Result = await RuntimeSettings.SetAsync(Name, Value);
85 else
86 Result = await HostSettings.SetAsync(Host, Name, Value);
87
88 return new BooleanValue(Result);
89 }
90 }
91}
Static class managing persistent host settings. Host settings default to runtime settings if host-spe...
Definition: HostSettings.cs:18
static async Task< bool > SetAsync(string Host, string Key, string Value)
Sets a string-valued setting.
Definition: HostSettings.cs:77
Static class managing persistent settings.
static async Task< bool > SetAsync(string Key, string Value)
Sets a string-valued setting.
Class managing a script expression.
Definition: Expression.cs:39
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
static readonly ArgumentType[] argumentTypes2Scalar
Two scalar parameters.
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:16
static string GetHost(object Value, ScriptNode Node)
Gets the host name from a value.
Definition: GetSetting.cs:104
Sets a runtime setting with name Name to the value Value. If Host is provided, the corresponding runt...
Definition: SetSetting.cs:13
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
Definition: SetSetting.cs:55
SetSetting(ScriptNode Host, ScriptNode Name, ScriptNode Value, int Start, int Length, Expression Expression)
Sets a runtime setting with name Name to the value Value. If Host is provided, the corresponding runt...
Definition: SetSetting.cs:36
override string[] DefaultArgumentNames
Default Argument names
Definition: SetSetting.cs:49
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: SetSetting.cs:63
SetSetting(ScriptNode Name, ScriptNode Value, int Start, int Length, Expression Expression)
Sets a runtime setting with name Name to the value Value. If Host is provided, the corresponding runt...
Definition: SetSetting.cs:22
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: SetSetting.cs:74
override string FunctionName
Name of the function
Definition: SetSetting.cs:44
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20