private Widget ParseWidget(Sitemap aSitemap, XElement aRoot) { var type = aRoot.Element("type").Value; var label = aRoot.Element("label").Value; var icon = aRoot.Element("icon").Value; var widget = new Widget(type, label, icon); if (widget.Type == Widget.WidgetType.Image) widget.Url = new Uri(new UriBuilder(aSitemap.Link.Scheme, aSitemap.Link.Host, aSitemap.Link.Port).Uri, aRoot.Element("url").Value); if (widget.Type == Widget.WidgetType.Chart) { widget.Period = aRoot.Element("period").Value; widget.Refresh = int.Parse(aRoot.Element("refresh").Value); } if (widget.Type == Widget.WidgetType.Setpoint) { widget.MinValue = double.Parse( aRoot.Element("minValue").Value,System.Globalization.NumberFormatInfo.InvariantInfo); widget.MaxValue = double.Parse( aRoot.Element("maxValue").Value,System.Globalization.NumberFormatInfo.InvariantInfo); widget.Step = double.Parse( aRoot.Element("step").Value,System.Globalization.NumberFormatInfo.InvariantInfo); } if (widget.Type == Widget.WidgetType.Video) widget.Url = new Uri(new UriBuilder(aSitemap.Link.Scheme, aSitemap.Link.Host, aSitemap.Link.Port).Uri, aRoot.Element("url").Value); if (widget.Type == Widget.WidgetType.Webview) widget.Url = new Uri(new UriBuilder(aSitemap.Link.Scheme, aSitemap.Link.Host, aSitemap.Link.Port).Uri, aRoot.Element("url").Value); if (widget.Type == Widget.WidgetType.Switch || widget.Type == Widget.WidgetType.Selection) { var mappings = aRoot.Elements("mapping"); foreach(var mapping in mappings) { var map_command = mapping.Element("command").Value; var map_label = mapping.Element("label").Value; widget.Mappings[map_label] = map_command; } } foreach (var child in aRoot.Elements("widget")) { widget.mWidgets.Add(ParseWidget(aSitemap, child)); } var item = aRoot.Element("item"); if (item != null) { widget.Item = ParseItem(aSitemap, item); } var linkedPage = aRoot.Element("linkedPage"); if (linkedPage != null) { widget.LinkedPage = ParsePage(aSitemap, linkedPage); } return widget; }
private void ParseSitemaps(XElement aRoot) { Sitemaps.Clear(); foreach (var sitemap in aRoot.Elements("sitemap")) { var name = sitemap.Element("name").Value; var link = sitemap.Element("link").Value; var homepage = sitemap.Element("homepage").Element("link").Value; Sitemaps[name] = new Sitemap(name, new Uri(link), new Uri(homepage)); } }
private Item ParseItem(Sitemap aSitemap, XElement aRoot) { var type = aRoot.Element("type").Value; var name = aRoot.Element("name").Value; var state = aRoot.Element("state").Value; var link = aRoot.Element("link").Value; Item item; if (!Items.TryGetValue(name, out item)) { item = new Item(this, type, name, state, link); } aSitemap.mItems[name] = item; Items[name] = item; return(item); }
private Page ParsePage(Sitemap aSitemap, XElement aRoot) { var page = new Page(this); var id = aRoot.Element("id").Value; var title = aRoot.Element("title").Value; var link = aRoot.Element("link").Value; page.Id = id; page.Title = title; page.Link = new Uri(link); foreach (var widget in aRoot.Elements("widget")) { page.mWidgets.Add(ParseWidget(aSitemap, widget)); } aSitemap.mPages[id] = page; Pages[id] = page; return(page); }
public void GetSitemap(Sitemap aSitemap, Action <REST, RESTResult> aCallback) { QuerySite(aSitemap.Link.AbsoluteUri, aCallback); }
private Widget ParseWidget(Sitemap aSitemap, XElement aRoot) { var type = aRoot.Element("type").Value; var label = aRoot.Element("label").Value; var icon = aRoot.Element("icon").Value; var widget = new Widget(type, label, icon); if (widget.Type == Widget.WidgetType.Image) { widget.Url = new Uri(new UriBuilder(aSitemap.Link.Scheme, aSitemap.Link.Host, aSitemap.Link.Port).Uri, aRoot.Element("url").Value); } if (widget.Type == Widget.WidgetType.Chart) { widget.Period = aRoot.Element("period").Value; widget.Refresh = int.Parse(aRoot.Element("refresh").Value); } if (widget.Type == Widget.WidgetType.Setpoint) { widget.MinValue = double.Parse(aRoot.Element("minValue").Value, System.Globalization.NumberFormatInfo.InvariantInfo); widget.MaxValue = double.Parse(aRoot.Element("maxValue").Value, System.Globalization.NumberFormatInfo.InvariantInfo); widget.Step = double.Parse(aRoot.Element("step").Value, System.Globalization.NumberFormatInfo.InvariantInfo); } if (widget.Type == Widget.WidgetType.Video) { widget.Url = new Uri(new UriBuilder(aSitemap.Link.Scheme, aSitemap.Link.Host, aSitemap.Link.Port).Uri, aRoot.Element("url").Value); } if (widget.Type == Widget.WidgetType.Webview) { widget.Url = new Uri(new UriBuilder(aSitemap.Link.Scheme, aSitemap.Link.Host, aSitemap.Link.Port).Uri, aRoot.Element("url").Value); } if (widget.Type == Widget.WidgetType.Switch || widget.Type == Widget.WidgetType.Selection) { var mappings = aRoot.Elements("mapping"); foreach (var mapping in mappings) { var map_command = mapping.Element("command").Value; var map_label = mapping.Element("label").Value; widget.Mappings[map_label] = map_command; } } foreach (var child in aRoot.Elements("widget")) { widget.mWidgets.Add(ParseWidget(aSitemap, child)); } var item = aRoot.Element("item"); if (item != null) { widget.Item = ParseItem(aSitemap, item); } var linkedPage = aRoot.Element("linkedPage"); if (linkedPage != null) { widget.LinkedPage = ParsePage(aSitemap, linkedPage); } return(widget); }
public void GetSitemap(Sitemap aSitemap, Action<REST, RESTResult> aCallback) { QuerySite(aSitemap.Link.AbsoluteUri, aCallback); }
private Item ParseItem(Sitemap aSitemap, XElement aRoot) { var type = aRoot.Element("type").Value; var name = aRoot.Element("name").Value; var state = aRoot.Element("state").Value; var link = aRoot.Element("link").Value; Item item; if (!Items.TryGetValue(name, out item)) item = new Item(this, type, name, state, link); aSitemap.mItems[name] = item; Items[name] = item; return item; }
private Page ParsePage(Sitemap aSitemap, XElement aRoot) { var page = new Page(this); var id = aRoot.Element("id").Value; var title = aRoot.Element("title").Value; var link = aRoot.Element("link").Value; page.Id = id; page.Title = title; page.Link = new Uri(link); foreach (var widget in aRoot.Elements("widget")) { page.mWidgets.Add(ParseWidget(aSitemap, widget)); } aSitemap.mPages[id] = page; Pages[id] = page; return page; }
private void ParseSitemaps(XElement aRoot) { Sitemaps.Clear(); foreach (var sitemap in aRoot.Elements("sitemap")) { var name = sitemap.Element("name").Value; var link = sitemap.Element("link").Value; var homepage = sitemap.Element("homepage").Element("link").Value; Sitemaps[name] = new Sitemap(name, new Uri(link), new Uri(homepage)); } }