Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SetDomainSetting.cs
1using System.Threading.Tasks;
3using Waher.Script;
8
10{
17 {
30 : base(new ScriptNode[] { Host, Name, Value }, argumentTypes3Scalar, Start, Length, Expression)
31 {
32 }
33
37 public override string FunctionName => nameof(SetDomainSetting);
38
42 public override string[] DefaultArgumentNames => new string[] { "Host", "Name", "Value" };
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 = DomainSettings.IsAlternativeDomain(GetSetting.GetHost(Arguments[0].AssociatedObjectValue, this));
70 string Name = Arguments[1].AssociatedObjectValue?.ToString();
71 object Value = Arguments[2].AssociatedObjectValue;
72 bool Result;
73
74 if (!string.IsNullOrEmpty(Host))
75 Result = await HostSettings.SetAsync(Host, Name, Value);
76 else
77 Result = await RuntimeSettings.SetAsync(Name, Value);
78
79 return new BooleanValue(Result);
80 }
81 }
82}
Sets a domain setting. If the Host (which can be a string or implement Waher.Content....
override async Task< IElement > EvaluateAsync(IElement[] Arguments, Variables Variables)
Evaluates the function.
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 string[] DefaultArgumentNames
Default Argument names
SetDomainSetting(ScriptNode Host, ScriptNode Name, ScriptNode Value, int Start, int Length, Expression Expression)
Sets a domain setting. If the Host (which can be a string or implement Waher.Content....
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[] 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
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20