Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SetHostSetting.cs
1using System.Threading.Tasks;
7
9{
14 {
25 : base(new ScriptNode[] { Host, Name, Value }, argumentTypes3Scalar, Start, Length, Expression)
26 {
27 }
28
32 public override string FunctionName => nameof(SetHostSetting);
33
37 public override string[] DefaultArgumentNames => new string[] { "Host", "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 Host = GetSetting.GetHost(Arguments[0].AssociatedObjectValue, this);
65
66 if (string.IsNullOrEmpty(Host))
67 throw new ScriptRuntimeException("Host not defined.", this);
68
69 string Name = ToString(Arguments[1]);
70 object Value = Arguments[2].AssociatedObjectValue;
71 bool Result;
72
73 Result = await HostSettings.SetAsync(Host, Name, Value);
74
75 return new BooleanValue(Result);
76 }
77 }
78}
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
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 string GetHost(object Value, ScriptNode Node)
Gets the host name from a value.
Definition: GetSetting.cs:106
Sets a runtime host setting with name Name to the value Value. Host defines the host.
SetHostSetting(ScriptNode Host, ScriptNode Name, ScriptNode Value, int Start, int Length, Expression Expression)
Sets a runtime host setting with name Name to the value Value. Host defines the host.
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.
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
override string[] DefaultArgumentNames
Default Argument names
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21