Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
VanityResource.cs
1using System.Collections.Generic;
2using System.Text.RegularExpressions;
3using System.Threading.Tasks;
5using Waher.Things;
8
10{
15 {
16 private string regex;
17
22 : base(null, null)
23 {
24 this.regex = string.Empty;
25 this.Url = string.Empty;
26 }
27
36 : base(Source, Parent)
37 {
38 this.regex = Regex;
39 this.Url = Url;
40 }
41
45 [Page(7, "Configuration")]
46 [Header(56, "Regular expression:")]
47 [ToolTip(57, "Regular expression defining a vanity resource or set of vanity resources.")]
48 [Required]
49 public string Regex
50 {
51 get => this.regex;
52 set
53 {
54 new Regex(value); // Check if syntax is correct.
55 this.regex = value;
56 }
57 }
58
62 [Page(7, "Configuration")]
63 [Header(58, "URL:")]
64 [ToolTip(59, "URL the resource points to. Can include references to named group in the regular expression.")]
65 [Required]
66 [Text(TextPosition.AfterField, 63, "Note: Changes will take effect after broker has been restarted.")]
67 public string Url { get; set; }
68
72 public override string NodeId => this.Regex;
73
78 public override Task<string> GetTypeNameAsync(Language Language) => Language.GetStringAsync(typeof(GatewayConfigSource), 60, "Vanity Resource");
79
85 public override Task<bool> AcceptsParentAsync(INode Parent)
86 {
87 return Task.FromResult(Parent is WebServer);
88 }
89
96 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
97 {
98 LinkedList<Parameter> Parameters = new LinkedList<Parameter>();
100
101 Parameters.AddLast(new StringParameter("Location", await Namespace.GetStringAsync(82, "Location"), this.Url));
102
103 return Parameters;
104 }
105 }
106}
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.
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...
string Url
URL the resource points to. Can include references to named group in the regular expression.
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
string Regex
Regular expression defining a vanity resource or set of vanity resources.
VanityResource(GatewayConfigSource Source, WebServer Parent, string Regex, string Url)
Defines a vanity resource.
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