Beispiel #1
0
        public Page ParsePage(XElement homepageNode)
        {
            if (homepageNode == null) return null;

            var page = new Page();
            page.Id = GetValue(homepageNode, "id");
            page.Title = GetValue(homepageNode, "title");
            page.Link = GetValue(homepageNode, "link");
            page.Leaf = bool.Parse(GetValue(homepageNode, "leaf"));

            //widgets
            page.Widgets = new List<Widget>(ParseWidgets(homepageNode.Elements("widget")));

            return page;
        }
Beispiel #2
0
        public static Page ToPage(this JsonObject jo)
        {
            var id = jo.GetNamedString("id", "");
            var link = jo.GetNamedString("link", "");
            var title = jo.GetNamedString("title", "");
            var icon = jo.GetNamedString("icon", "");
            var leaf = jo.ToBooleanSafe("key");
            Page parent = null;

            if (jo.ContainsKey("parent"))
            {
                parent = jo.GetNamedObject("parent").ToPage();
            }

            var page = new Page()
                .SetId(id)
                .SetLink(link)
                .SetTitle(title)
                .SetIcon(icon)
                .SetLeaf(leaf)
                .SetParent(parent);

            var jWidgets = jo.ToWidgetsSafe();
            if (jWidgets != null)
                return page.SetWidgets(jWidgets.ToWidgets());
            return page;
        }
Beispiel #3
0
 /// <summary>
 /// Sets the parent.
 /// </summary>
 /// <param name="page">The page.</param>
 /// <param name="parent">The parent.</param>
 /// <returns></returns>
 public static Page SetParent(this Page page, Page parent)
 {
     page.Parent = parent;
     return page;
 }
Beispiel #4
0
 public static Widget SetLinkedPage(this Widget input, Page linkedPage)
 {
     input.LinkedPage = linkedPage;
     return input;
 }