Exemple #1
0
        private static BreedDataGroup CreateBreedGroup(JsonObject obj)
        {
            BreedDataGroup group = new BreedDataGroup();

            foreach (var key in obj.Keys)
            {
                IJsonValue val;
                if (!obj.TryGetValue(key, out val))
                {
                    continue;
                }

                switch (key)
                {
                case "key":
                    group.UniqueId = val.GetString();
                    break;

                case "title":
                    group.Title = val.GetString();
                    break;

                case "shortTitle":
                    group.ShortTitle = val.GetString();
                    break;

                case "description":
                    group.Description = val.GetString();
                    break;

                case "backgroundImage":
                    group.SetImage(val.GetString());
                    break;

                case "groupImage":
                    group.SetGroupImage(val.GetString());
                    break;
                }
            }

            _breedDataSource.AllGroups.Add(group);
            return(group);
        }
Exemple #2
0
        private static void CreateBreedsAndBreedGroups(JsonArray array)
        {
            foreach (var item in array)
            {
                var            obj   = item.GetObject();
                BreedDataItem  breed = new BreedDataItem();
                BreedDataGroup group = null;

                foreach (var key in obj.Keys)
                {
                    IJsonValue val;
                    if (!obj.TryGetValue(key, out val))
                    {
                        continue;
                    }

                    switch (key)
                    {
                    case "key":
                        breed.UniqueId = val.GetNumber().ToString();
                        break;

                    case "title":
                        breed.Title = val.GetString();
                        break;

                    case "shortTitle":
                        breed.ShortTitle = val.GetString();
                        break;

                    case "description":
                        breed.Description = val.GetString();
                        break;

                    case "breed_details":
                        var breed_details = val.GetArray();
                        var list          = (from i in breed_details select i.GetString()).ToList();
                        breed.Breed_details = new ObservableCollection <string>(list);
                        break;

                    case "backgroundImage":
                        breed.SetImage(val.GetString());
                        break;

                    case "tileImage":
                        breed.SetTileImage(val.GetString());
                        break;

                    case "group":
                        var breedGroup = val.GetObject();

                        IJsonValue groupKey;
                        if (!breedGroup.TryGetValue("key", out groupKey))
                        {
                            continue;
                        }

                        group = _breedDataSource.AllGroups.FirstOrDefault(c => c.UniqueId.Equals(groupKey.GetString()));

                        if (group == null)
                        {
                            group = CreateBreedGroup(breedGroup);
                        }

                        breed.Group = group;
                        break;
                    }
                }

                if (group != null)
                {
                    group.Items.Add(breed);
                }
            }
        }
Exemple #3
0
 public BreedDataItem(String uniqueId, String title, String shortTitle, String imagePath, String description, ObservableCollection <string> breed_details, BreedDataGroup group)
     : base(uniqueId, title, shortTitle, imagePath)
 {
     this._description   = description;
     this._breed_details = breed_details;
     this._group         = group;
 }