NTP Analyzer  0.8.2
Analyze the operation of time servers
PeerPageConfiguration.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using System;
23 using System.Collections.Generic;
24 using System.Globalization;
28 using Ntp.Analyzer.Config.Table;
29 using Ntp.Common.Process;
30 using Ntp.Common.Web;
31 
32 namespace Ntp.Analyzer.Config.Node.Page
33 {
35  {
37  string configName,
38  int? frequency,
39  bool? initialRun,
40  bool? fixedRun,
41  DateTimeKind? showUtc,
42  PageTheme? theme,
43  string title,
44  IEnumerable<GraphSetConfiguration> graphs,
45  DestinationCollection destinations,
46  Uri link)
47  : base(configName, destinations, link)
48  {
49  this.frequency = frequency;
50  this.initialRun = initialRun;
51  this.fixedRun = fixedRun;
52  this.showUtc = showUtc;
53  this.theme = theme;
54  this.graphs = new List<GraphSetConfiguration>(graphs);
55  graphPages = new List<PeerGraphPageConfiguration>();
56  Title = title;
57  ConfigLink = link;
58  }
59 
60  private readonly bool? fixedRun;
61  private readonly int? frequency;
62  private readonly List<PeerGraphPageConfiguration> graphPages;
63  private readonly List<GraphSetConfiguration> graphs;
64  private readonly bool? initialRun;
65  private readonly DateTimeKind? showUtc;
66  private readonly PageTheme? theme;
67 
68  [NtpaIndex(11)]
69  [NtpaSetting(Symbol.KeywordPageTemplate, PageTheme.Default)]
70  public override PageTheme Theme => theme ?? PageTheme.Default;
71 
72  [NtpaIndex(12)]
73  [NtpaSetting(Symbol.KeywordPageTime, DateTimeKind.Utc)]
74  public DateTimeKind ShowUtc => showUtc ?? DateTimeKind.Utc;
75 
76  [NtpaIndex(10)]
77  [NtpaSetting(Symbol.KeywordPageTitle, Layout = Layout.Quoted)]
78  public override string Title { get; }
79 
84  [NtpaIndex(30)]
85  [NtpaSettingsCollection(Symbol.KeywordGraphSet)]
86  public IEnumerable<GraphSetConfiguration> Graphs => graphs;
87 
92  public IEnumerable<PeerGraphPageConfiguration> GraphPages => graphPages;
93 
94  [NtpaIndex(20)]
95  [NtpaSetting(Symbol.KeywordLink)]
96  public Uri ConfigLink { get; }
97 
98  [NtpaIndex(1)]
99  [NtpaSetting(Symbol.KeywordFrequency, 240)]
100  public int Frequency => frequency ?? 240;
101 
102  [NtpaIndex(2)]
103  [NtpaSetting(Symbol.KeywordInitialRun, true)]
104  public bool InitialRun => initialRun ?? true;
105 
106  [NtpaIndex(3)]
107  [NtpaSetting(Symbol.KeywordFixedRun, true)]
108  public bool FixedRun => fixedRun ?? true;
109 
115  public Uri GetLink(int peerId)
116  {
117  return WebPath.Append(Link, peerId.ToString(CultureInfo.InvariantCulture)).AppendExtension(".html");
118  }
119 
121  {
122  graphPages.Add(graphPage);
123  }
124  }
125 }
void AttachGraphPage(PeerGraphPageConfiguration graphPage)
readonly List< PeerGraphPageConfiguration > graphPages
PeerPageConfiguration(string configName, int?frequency, bool?initialRun, bool?fixedRun, DateTimeKind?showUtc, PageTheme?theme, string title, IEnumerable< GraphSetConfiguration > graphs, DestinationCollection destinations, Uri link)
Uri GetLink(int peerId)
Gets the link related to specified peer.
readonly List< GraphSetConfiguration > graphs