NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender Class Reference
Inheritance diagram for Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender:
Collaboration diagram for Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender:

Public Member Functions

 DefaultPeerInfoRender (Uri webPath, TimeServer server, string name)
 
override string Render ()
 
override string RenderFooter ()
 
override string RenderHead ()
 
- Public Member Functions inherited from Ntp.Analyzer.Render.HtmlObjectRender
void Add (IHtmlObject child)
 

Private Member Functions

string GetPoolMemberLink ()
 
string GetProviderLink ()
 
string GetServerAccess ()
 
string GetServiceArea ()
 
string GetStratumText ()
 

Private Attributes

const string Na = " "
 
readonly string name
 
readonly TimeServer server
 

Additional Inherited Members

- Public Attributes inherited from Ntp.Analyzer.Render.HtmlObjectRender
IEnumerable< IHtmlObjectChildren => children.ToArray()
 
- Protected Member Functions inherited from Ntp.Analyzer.Render.HtmlObjectRender
 HtmlObjectRender (Uri webPath)
 
- Properties inherited from Ntp.Analyzer.Render.HtmlObjectRender
Uri WebPath [get]
 
- Properties inherited from Ntp.Analyzer.Render.IHtmlObject
IEnumerable< IHtmlObjectChildren [get]
 
Uri WebPath [get]
 

Detailed Description

Definition at line 29 of file DefaultPeerInfoRender.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.DefaultPeerInfoRender ( Uri  webPath,
TimeServer  server,
string  name 
)
inline

Definition at line 31 of file DefaultPeerInfoRender.cs.

32  : base(webPath)
33  {
34  this.server = server;
35  this.name = name;
36  }

Member Function Documentation

string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.GetPoolMemberLink ( )
inlineprivate

Definition at line 179 of file DefaultPeerInfoRender.cs.

180  {
181  if (!server.IsPoolMember)
182  return "Server is not a pool member";
183 
184  var builder = new StringBuilder();
185  builder.Append(@"<a href=""http://www.pool.ntp.org/scores/");
186  builder.Append(server.Address);
187  builder.Append(@""">pool.ntp.org</a>");
188  return builder.ToString();
189  }
abstract IPAddress Address
Definition: TimeServer.cs:44
string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.GetProviderLink ( )
inlineprivate

Definition at line 191 of file DefaultPeerInfoRender.cs.

192  {
193  if (server.ProviderPage == null)
194  return "Not found";
195 
196  var builder = new StringBuilder();
197  builder.Append(@"<a href=""");
198  builder.Append(server.ProviderUrl);
199  builder.Append(@""">");
200  builder.Append(server.ProviderPage);
201  builder.Append("</a>");
202  return builder.ToString();
203  }
abstract string ProviderPage
Definition: TimeServer.cs:78
string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.GetServerAccess ( )
inlineprivate

Definition at line 155 of file DefaultPeerInfoRender.cs.

156  {
157  switch (server.AccessPolicy)
158  {
159  case "OpenAccess":
160  return "Open access";
161  default:
162  return "Unknown";
163  }
164  }
abstract string AccessPolicy
Definition: TimeServer.cs:64
string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.GetServiceArea ( )
inlineprivate

Definition at line 166 of file DefaultPeerInfoRender.cs.

167  {
168  string description = server.ServiceArea.Trim();
169 
170  if (description == string.Empty)
171  return string.Empty;
172 
173  string firstLetter = description.Substring(0, 1);
174  string rest = description.Substring(1);
175 
176  return firstLetter.ToUpper() + rest;
177  }
string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.GetStratumText ( )
inlineprivate

Definition at line 132 of file DefaultPeerInfoRender.cs.

133  {
134  switch (server.Stratum)
135  {
136  case 1:
137  return "one";
138  case 2:
139  return "two";
140  case 3:
141  return "three";
142  case 4:
143  return "four";
144  case 5:
145  return "five";
146  case 6:
147  return "six";
148  case 7:
149  return "seven";
150  default:
151  return "Unknown";
152  }
153  }
override string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.Render ( )
inline

Implements Ntp.Analyzer.Render.IHtmlObject.

Definition at line 42 of file DefaultPeerInfoRender.cs.

43  {
44  var builder = new StringBuilder();
45 
46  builder.AppendLine("<table>");
47  builder.AppendLine(@"<col class=""fst""><col class=""sec""><col class=""thd""><col class=""frt"">");
48  builder.AppendLine("<tbody>");
49 
50  builder.AppendLine("<tr>");
51  builder.Append(@" <td>Server location</td><td colspan=""3"">");
52  builder.Append(server != null ? server.Location : Na);
53  builder.AppendLine("</td>");
54  builder.AppendLine("</tr>");
55 
56  builder.AppendLine("<tr>");
57  builder.Append(@" <td>Synchronization</td><td colspan=""3"">");
58  builder.Append(server != null ? server.Server : Na);
59  builder.AppendLine("</td>");
60  builder.AppendLine("</tr>");
61 
62  builder.AppendLine("<tr>");
63  builder.Append(" <td>IP address</td><td>");
64  builder.Append(server?.Address?.ToString() ?? string.Empty);
65  builder.AppendLine("</td>");
66  builder.Append(" <td>Access policy</td><td>");
67  builder.Append(server != null ? GetServerAccess() : Na);
68  builder.AppendLine("</td>");
69  builder.AppendLine("</tr>");
70 
71  builder.AppendLine("<tr>");
72  builder.Append(" <td>IPv6 address</td><td>");
73  builder.Append(server != null ? server.V6Address ?? "N/A" : Na);
74  builder.AppendLine("</td>");
75  builder.Append(" <td>Service area</td><td>");
76  builder.Append(server != null ? GetServiceArea() : Na);
77  builder.AppendLine("</td>");
78  builder.AppendLine("</tr>");
79 
80  builder.AppendLine("<tr>");
81  builder.Append(@" <td>Pool member info</td><td>");
82  builder.Append(server != null ? GetPoolMemberLink() : Na);
83  builder.AppendLine("</td>");
84  builder.Append(" <td>Provider page</td><td>");
85  builder.Append(server != null ? GetProviderLink() : Na);
86  builder.AppendLine("</td>");
87  builder.AppendLine("</tr>");
88 
89  builder.AppendLine("<tr>");
90  builder.Append("<td>Description updated</td><td>");
91  builder.Append(server?.Updated.ToLongDateString() ?? Na);
92  builder.AppendLine("</td>");
93  if (server != null && server.Id <= 10000)
94  {
95  builder.Append(
96  @" <td>Additional info</td><td><a href=""http://support.ntp.org/bin/view/Servers/PublicTimeServer");
97  builder.Append(server.Id.ToString(CultureInfo.InvariantCulture).PadLeft(6, '0'));
98  builder.AppendLine(@""">support.ntp.org</a></td>");
99  }
100  else
101  {
102  builder.Append($@" <td>Additional info</td><td>{Na}</td>");
103  }
104  builder.AppendLine("</tr>");
105 
106  builder.AppendLine("</tbody>");
107  builder.AppendLine("</table>");
108 
109  return builder.ToString();
110  }
override string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.RenderFooter ( )
inlinevirtual

Implements Ntp.Analyzer.Render.HtmlObjectRender.

Definition at line 112 of file DefaultPeerInfoRender.cs.

113  {
114  return string.Empty;
115  }
override string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.RenderHead ( )
inlinevirtual

Implements Ntp.Analyzer.Render.HtmlObjectRender.

Definition at line 117 of file DefaultPeerInfoRender.cs.

118  {
119  var builder = new StringBuilder();
120 
121  builder.Append("<h2>");
122  builder.Append(server != null ? server.Name : name);
123  builder.Append("</h2>&nbsp;&nbsp;&nbsp;&nbsp;<h4>Stratum ");
124  builder.Append(server != null ? GetStratumText() : Na);
125  builder.AppendLine(" server</h4>");
126 
127  return builder.ToString();
128  }

Member Data Documentation

const string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.Na = "&nbsp;"
private

Definition at line 38 of file DefaultPeerInfoRender.cs.

readonly string Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.name
private

Definition at line 39 of file DefaultPeerInfoRender.cs.

readonly TimeServer Ntp.Analyzer.Render.Peer.DefaultPeerInfoRender.server
private

Definition at line 40 of file DefaultPeerInfoRender.cs.


The documentation for this class was generated from the following file: