Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RequestVariables.cs
2using Waher.Script;
4
6{
11 {
12 private readonly HttpRequest request;
13 private Variable requestVariable;
14
20 : base()
21 {
22 this.request = Request;
23 }
24
25 private void InitializeContext()
26 {
27 this.ContextVariables ??= this.request.GetSessionFromCookie();
28 }
29
36 public override bool TryGetVariable(string Name, out Variable Variable)
37 {
38 switch (Name)
39 {
40 case "Request":
41 this.requestVariable ??= new Variable(Name, new ObjectValue(this.request));
42 Variable = this.requestVariable;
43 return true;
44
45 default:
46 this.InitializeContext();
47 return base.TryGetVariable(Name, out Variable);
48 }
49 }
50
56 public override bool ContainsVariable(string Name)
57 {
58 switch (Name)
59 {
60 case "Request":
61 return true;
62
63 default:
64 if (base.ContainsVariable(Name))
65 return true;
66
67 this.InitializeContext();
68 return base.ContainsVariable(Name);
69 }
70 }
71 }
72}
Represents an HTTP request.
Definition: HttpRequest.cs:22
SessionVariables GetSessionFromCookie()
Gets the session variables from the cookie, if available.
Definition: HttpRequest.cs:350
Contains information about a variable.
Definition: Variable.cs:10
Collection of variables.
Definition: Variables.cs:25
Request variables used in script.
override bool ContainsVariable(string Name)
If the collection contains a variable with a given name.
RequestVariables(HttpRequest Request)
Request variables used in script.
override bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.