Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
GetDomainSetting.cs
1using System.Threading.Tasks;
3using Waher.Script;
7
9{
16 {
30 : base(new ScriptNode[] { Host, Name, DefaultValue }, argumentTypes3Scalar, Start, Length, Expression)
31 {
32 }
33
37 public override string FunctionName => nameof(GetDomainSetting);
38
42 public override string[] DefaultArgumentNames => new string[] { "Host", "Name", "DefaultValue" };
43
48 public override bool IsAsynchronous => true;
49
57 {
58 return this.EvaluateAsync(Arguments, Variables).Result;
59 }
60
67 public override async Task<IElement> EvaluateAsync(IElement[] Arguments, Variables Variables)
68 {
69 string Host = GetSetting.GetHost(Arguments[0].AssociatedObjectValue, this);
70 string Name = Arguments[1].AssociatedObjectValue?.ToString();
71 object DefaultValue = Arguments[2].AssociatedObjectValue;
72 object Result = await DomainSettings.GetSettingAsync(Host, Name, DefaultValue);
73
74 return Expression.Encapsulate(Result);
75 }
76
77 }
78}
static Task< string > GetSettingAsync(IHostReference HostRef, string Key, string DefaultValue)
Gets a setting that may vary depending on domain.
Gets a domain setting. If the Host (which can be a string or implement Waher.Content....
GetDomainSetting(ScriptNode Host, ScriptNode Name, ScriptNode DefaultValue, int Start, int Length, Expression Expression)
Gets a domain setting. If the Host (which can be a string or implement Waher.Content....
override bool IsAsynchronous
If the node (or its decendants) include asynchronous evaluation. Asynchronous nodes should be evaluat...
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the function.
override string[] DefaultArgumentNames
Default Argument names
Class managing a script expression.
Definition: Expression.cs:39
static IElement Encapsulate(object Value)
Encapsulates an object.
Definition: Expression.cs:4955
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 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
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20