Пример #1
0
        //public List<MenuItem> Items { get; set; }

        public static MenuSection ParseJson(JToken ejson)
        {
            MenuSection e = new MenuSection();

            e.SectionId = Json.TryGetJsonProperty(ejson, "sectionId");
            e.Name      = Json.TryGetJsonProperty(ejson, "name");

            var entries = ejson["entries"];

            if (entries != null)
            {
                var items = entries["items"];
                if (items != null)
                {
                    //var li = new List<MenuItem>();
                    foreach (var item in items)
                    {
                        var es = MenuItem.ParseJson(item);
                        if (es != null)
                        {
                            /*li.*/
                            e.Add(es);
                        }
                    }
                    //e.Items = li;
                }
            }

            return(e);
        }
Пример #2
0
        public static Menu ParseJson(JToken ejson, string venueId)
        {
            Menu e = new Menu();

            e.ParentVenueId = venueId;

            e.MenuId      = Json.TryGetJsonProperty(ejson, "menuId");
            e.Name        = Json.TryGetJsonProperty(ejson, "name");
            e.Description = Json.TryGetJsonProperty(ejson, "description");
            if (e.Description != null && e.Description.Length == 0)
            {
                e.Description = null;
            }

            e.LocalUri = new Uri(string.Format(CultureInfo.InvariantCulture,
                                               "/JeffWilcox.FourthAndMayor.Place;component/VenueMenu.xaml?venueid={0}&menuid={1}",
                                               System.Net.HttpUtility.UrlEncode(e.ParentVenueId),
                                               System.Net.HttpUtility.UrlEncode(e.MenuId)
                                               ), UriKind.Relative);

            var entries = ejson["entries"];

            if (entries != null)
            {
                var items = entries["items"];
                if (items != null)
                {
                    var li = new List <MenuSection>();
                    foreach (var item in items)
                    {
                        var es = MenuSection.ParseJson(item);
                        if (es != null)
                        {
                            li.Add(es);
                        }
                    }
                    e.Sections = li;
                }
            }

            return(e);
        }