Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Redirection.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
4using Waher.Things;
7
9{
14 {
18 public Redirection()
19 : base(null, null)
20 {
21 this.Resource = string.Empty;
22 this.Location = string.Empty;
23 this.IncludeSubPaths = false;
24 this.Permanent = false;
25 }
26
37 : base(Source, Parent)
38 {
39 this.Resource = Resource;
40 this.Location = Location;
41 this.IncludeSubPaths = IncludeSubPaths;
42 this.Permanent = Permanent;
43 }
44
48 [Page(7, "Configuration")]
49 [Header(72, "Resource:")]
50 [ToolTip(73, "Resource being redirected.")]
51 [Required]
52 public string Resource { get; set; }
53
57 [Page(7, "Configuration")]
58 [Header(74, "Location:")]
59 [ToolTip(75, "Resource or URL being redirected to.")]
60 [Required]
61 public string Location { get; set; }
62
66 [Page(7, "Configuration")]
67 [Header(76, "Include sub-paths.")]
68 [ToolTip(77, "If all resources beginning with this resource should also be redirected.")]
69 public bool IncludeSubPaths { get; set; }
70
74 [Page(7, "Configuration")]
75 [Header(78, "Permanent redirection.")]
76 [ToolTip(79, "If redirection is permanent and client can update its references.")]
77 [Text(TextPosition.AfterField, 63, "Note: Changes will take effect after broker has been restarted.")]
78 public bool Permanent { get; set; }
79
83 public override string NodeId => this.Resource;
84
89 public override Task<string> GetTypeNameAsync(Language Language) => Language.GetStringAsync(typeof(GatewayConfigSource), 80, "Redirection");
90
96 public override Task<bool> AcceptsParentAsync(INode Parent)
97 {
98 return Task.FromResult(Parent is WebServer);
99 }
100
107 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
108 {
109 LinkedList<Parameter> Parameters = new LinkedList<Parameter>();
111
112 Parameters.AddLast(new StringParameter("Location", await Namespace.GetStringAsync(82, "Location"), this.Location));
113 Parameters.AddLast(new BooleanParameter("IncludeSubPaths", await Namespace.GetStringAsync(83, "Subpaths"), this.IncludeSubPaths));
114 Parameters.AddLast(new BooleanParameter("Permanent", await Namespace.GetStringAsync(84, "Permanent"), this.Permanent));
115
116 return Parameters;
117 }
118 }
119}
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
Definition: Language.cs:99
Contains information about a namespace in a language.
Definition: Namespace.cs:17
Task< LanguageString > GetStringAsync(int Id)
Gets the string object, given its ID, if available.
Definition: Namespace.cs:65
Abstract base class for gateway configuration nodes.
virtual INode Parent
Parent Node, or null if a root node.
GatewayConfigSource Source
Source hosting the node.
bool IncludeSubPaths
If sub-paths should be included in the redirection.
Definition: Redirection.cs:69
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
Definition: Redirection.cs:107
bool Permanent
If redirection is permanent (true) or temporary (false).
Definition: Redirection.cs:78
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a presumptive parent, i.e. can be added to that parent (if that parent accepts th...
Definition: Redirection.cs:96
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
Redirection(GatewayConfigSource Source, WebServer Parent, string Resource, string Location, bool IncludeSubPaths, bool Permanent)
Defines a redirection.
Definition: Redirection.cs:36
string Location
Location client is redirected to.
Definition: Redirection.cs:61
Tokens available in request.
Definition: RequestOrigin.cs:9
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
TextPosition
Where the instructions are to be place.
Definition: TextAttribute.cs:9