Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
GetHostSetting.cs
1using System.Threading.Tasks;
6
8{
14 {
25 public GetHostSetting(ScriptNode Host, ScriptNode Name, ScriptNode DefaultValue, int Start, int Length, Expression Expression)
26 : base(new ScriptNode[] { Host, Name, DefaultValue }, argumentTypes3Scalar, Start, Length, Expression)
27 {
28 }
29
33 public override string FunctionName => nameof(GetHostSetting);
34
38 public override string[] DefaultArgumentNames => new string[] { "Host", "Name", "DefaultValue" };
39
44 public override bool IsAsynchronous => true;
45
53 {
54 return this.EvaluateAsync(Arguments, Variables).Result;
55 }
56
63 public override async Task<IElement> EvaluateAsync(IElement[] Arguments, Variables Variables)
64 {
65 string Host = GetSetting.GetHost(Arguments[0].AssociatedObjectValue, this);
66
67 if (string.IsNullOrEmpty(Host))
68 throw new ScriptRuntimeException("Host not defined.", this);
69
70 string Name = ToString(Arguments[1]);
71 object DefaultValue = Arguments[2].AssociatedObjectValue;
72 object Result;
73 Result = await HostSettings.GetAsync(Host, Name, DefaultValue);
74
75 return Expression.Encapsulate(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< string > GetAsync(string Host, string Key, string DefaultValue)
Gets a string-valued setting.
Definition: HostSettings.cs:40
Class managing a script expression.
Definition: Expression.cs:41
static IElement Encapsulate(object Value)
Encapsulates an object.
Definition: Expression.cs:5241
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
Gets a runtime hgost setting with name Name. Host defines the host. If a host setting is not found,...
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the function.
GetHostSetting(ScriptNode Host, ScriptNode Name, ScriptNode DefaultValue, int Start, int Length, Expression Expression)
Gets a runtime hgost setting with name Name. Host defines the host. If a host setting is not found,...
override string FunctionName
Name of the function
override string[] DefaultArgumentNames
Default Argument names
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
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
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21