Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
IntervalNode.cs
1using System;
3using System.Threading.Tasks;
4using Waher.Content;
6using Waher.Things;
9
11{
16 {
17 private readonly string id = Guid.NewGuid().ToString();
18
22 public IntervalNode()
23 : base()
24 {
25 this.NrAttempts = 0;
26 this.Interval = null;
27 }
28
36 : base(Source, null)
37 {
38 this.NrAttempts = NrAttempts;
39 this.Interval = Interval;
40 }
41
45 public override string NodeId => this.id;
46
50 public override string LocalId
51 {
52 get
53 {
54 IEnumerable<ConfigurationNode> Siblings = this.Siblings;
55 if (Siblings is null)
56 return this.id;
57
58 int i = 0;
59
60 foreach (ConfigurationNode Sibling in Siblings)
61 {
62 if (Sibling is IntervalNode)
63 {
64 i++;
65 if (Sibling == this)
66 return "Interval " + i.ToString();
67 }
68 }
69
70 return this.id;
71 }
72 }
73
77 [Page(7, "Configuration")]
78 [Header(102, "Number of attempts:")]
79 [ToolTip(103, "Number of login attempts permitted during the interval duration.")]
80 [Required]
81 public int NrAttempts { get; set; }
82
86 [Page(7, "Configuration")]
87 [Header(104, "Interval Duration:")]
88 [ToolTip(105, "Duration of interval. The last interval can be an eternal interval. This is defined by omitting a value for this parameter.")]
89 public Duration? Interval { get; set; }
90
95 public override Task<string> GetTypeNameAsync(Language Language) => Language.GetStringAsync(typeof(GatewayConfigSource), 101, "Interval");
96
102 public override Task<bool> AcceptsParentAsync(INode Parent)
103 {
104 return Task.FromResult(
107 }
108
115 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
116 {
117 LinkedList<Parameter> Parameters = new LinkedList<Parameter>();
119
120 Parameters.AddLast(new Int64Parameter("Attempts", await Namespace.GetStringAsync(117, "Attempts"), this.NrAttempts));
121
122 if (this.Interval.HasValue)
123 Parameters.AddLast(new DurationParameter("Interval", await Namespace.GetStringAsync(101, "Interval"), this.Interval.Value));
124
125 return Parameters;
126 }
127 }
128}
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.
Represents an interval in a LoginAuditor configuration.
Definition: IntervalNode.cs:16
IntervalNode()
Represents an interval in a LoginAuditor configuration.
Definition: IntervalNode.cs:22
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.
int NrAttempts
Number of attempts during interval.
Definition: IntervalNode.cs:81
IntervalNode(GatewayConfigSource Source, int NrAttempts, Duration? Interval)
Represents an interval in a LoginAuditor configuration.
Definition: IntervalNode.cs:35
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...
override string LocalId
If provided, an ID for the node, but unique locally between siblings. Can be null,...
Definition: IntervalNode.cs:51
Contains configuration of the Login Auditor.
Tokens available in request.
Definition: RequestOrigin.cs:9
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
Represents a duration value, as defined by the xsd:duration data type: http://www....
Definition: Duration.cs:14