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

Public Member Functions

 BootstrapMenuRender (Uri webPath, MenuConfiguration menu, ILinkable page)
 
override string Render ()
 
override string RenderFooter ()
 
override string RenderHead ()
 
- Public Member Functions inherited from Ntp.Analyzer.Render.HtmlObjectRender
void Add (IHtmlObject child)
 

Private Attributes

readonly MenuConfiguration menu
 
readonly ILinkable page
 

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 30 of file BootstrapMenuRender.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Render.BootstrapMenuRender.BootstrapMenuRender ( Uri  webPath,
MenuConfiguration  menu,
ILinkable  page 
)
inline

Definition at line 32 of file BootstrapMenuRender.cs.

33  : base(webPath)
34  {
35  this.menu = menu;
36  this.page = page;
37  }

Member Function Documentation

override string Ntp.Analyzer.Render.BootstrapMenuRender.Render ( )
inline

Implements Ntp.Analyzer.Render.IHtmlObject.

Definition at line 42 of file BootstrapMenuRender.cs.

References b.

43  {
44  var b = new StringBuilder();
45 
46  b.AppendLine(@" <div class=""navbar navbar-inverse navbar-fixed-top"">");
47  b.AppendLine(@" <div class=""container"">");
48  b.AppendLine(@" <div class=""navbar-header"">");
49  b.AppendLine(
50  @" <button type=""button"" class=""navbar-toggle"" data-toggle=""collapse"" data-target="".navbar-collapse"">");
51  b.AppendLine(@" <span class=""icon-bar""></span>");
52  b.AppendLine(@" <span class=""icon-bar""></span>");
53  b.AppendLine(@" <span class=""icon-bar""></span>");
54  b.AppendLine(@" </button>");
55 
56  var headItem =
57  menu.MenuItems.SingleOrDefault(i => i is HeadMenuItemConfiguration) as HeadMenuItemConfiguration;
58 
59  if (headItem != null)
60  {
61  b.AppendLine(
62  $@" <a class=""navbar-brand"" href=""{headItem.Link.ToHtmlString()}"">{headItem.Caption}</a>");
63  }
64 
65  b.AppendLine(@" </div>");
66  b.AppendLine(@" <div class=""navbar-collapse collapse"">");
67  b.AppendLine(@" <ul class=""nav navbar-nav"">");
68 
69  foreach (var item in menu.MenuItems.Where(i => !(i is HeadMenuItemConfiguration)))
70  {
71  string active = item.Page == page ? @" class=""active""" : string.Empty;
72 
74  {
75  b.AppendLine(
76  $@" <li{active}><a href=""{item.Link.ToHtmlString()}"">{item.Caption}</a></li>");
77  }
78  else if (item is DropdownItemConfiguration)
79  {
80  b.AppendLine(@" <li class=""dropdown"">");
81  b.AppendLine(
82  @" <a href=""#"" class=""dropdown-toggle"" data-toggle=""dropdown"">Peers <b class=""caret""></b></a>");
83  b.AppendLine(@" <ul class=""dropdown-menu"">");
84 
85  var dropdownItem = item as DropdownItemConfiguration;
86 
87  foreach (var subItem in dropdownItem.MenuItems)
88  {
89  if (subItem is LinkMenuItemConfiguration || subItem is PageMenuItemConfiguration)
90  {
91  b.AppendLine(
92  $@" <li><a href=""{subItem.Link.ToHtmlString()}"">{subItem.Caption}</a></li>");
93  }
94  else if (subItem is SpacerMenuItemConfiguration)
95  {
96  b.AppendLine(@" <li class=""divider""></li>");
97  }
98  else if (subItem is HeaderMenuItemConfiguration)
99  {
100  b.AppendLine($@" <li class=""dropdown-header"">{subItem.Caption}</li>");
101  }
102  else
103  {
104  throw new NotSupportedException("Unknown item type.");
105  }
106  }
107 
108  b.AppendLine(@" </ul>");
109  }
110  else
111  {
112  throw new NotSupportedException("Unknown item type.");
113  }
114  }
115 
116  b.AppendLine(@" </ul>");
117  b.AppendLine(@" </div>");
118  b.AppendLine(@" </div>");
119  b.AppendLine(@" </div>");
120 
121  return b.ToString();
122  }
IEnumerable< MenuItemConfiguration > MenuItems
var b
Definition: bootstrap.min.js:6
override string Ntp.Analyzer.Render.BootstrapMenuRender.RenderFooter ( )
inlinevirtual

Implements Ntp.Analyzer.Render.HtmlObjectRender.

Definition at line 124 of file BootstrapMenuRender.cs.

125  {
126  return string.Empty;
127  }
override string Ntp.Analyzer.Render.BootstrapMenuRender.RenderHead ( )
inlinevirtual

Implements Ntp.Analyzer.Render.HtmlObjectRender.

Definition at line 129 of file BootstrapMenuRender.cs.

130  {
131  return string.Empty;
132  }

Member Data Documentation

readonly MenuConfiguration Ntp.Analyzer.Render.BootstrapMenuRender.menu
private

Definition at line 39 of file BootstrapMenuRender.cs.

readonly ILinkable Ntp.Analyzer.Render.BootstrapMenuRender.page
private

Definition at line 40 of file BootstrapMenuRender.cs.


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