|
|
|
@ -0,0 +1,64 @@ |
|
|
|
|
using System; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Text; |
|
|
|
|
|
|
|
|
|
namespace XamarinStudy.Models |
|
|
|
|
{ |
|
|
|
|
internal class Toy |
|
|
|
|
{ |
|
|
|
|
public enum TOY_CATEGORY { Robot, Car, Plane, Figure, Block } |
|
|
|
|
|
|
|
|
|
public string Name { get; set; } |
|
|
|
|
public int Price { get; set; } |
|
|
|
|
public int Count { get; set; } |
|
|
|
|
public string Image { get => $"{this.Name}.png"; } |
|
|
|
|
public bool Checked { get; set; } |
|
|
|
|
public TOY_CATEGORY Category { get; set; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
class KindOf<K, T> : List<T> |
|
|
|
|
{ |
|
|
|
|
public K Title { get; set; } |
|
|
|
|
public KindOf(K title, IEnumerable<T> list) |
|
|
|
|
{ |
|
|
|
|
this.Title = title; |
|
|
|
|
this.AddRange(list); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal class ToyRepository |
|
|
|
|
{ |
|
|
|
|
public static List<Toy> ToyList { get; private set; } |
|
|
|
|
public static List<KindOf<string, Toy>>ToyListKindOf { get; set; } |
|
|
|
|
|
|
|
|
|
static ToyRepository() |
|
|
|
|
{ |
|
|
|
|
ToyList = new List<Toy>() |
|
|
|
|
{ |
|
|
|
|
new Toy() {Name = "Robot1", Price = 10000, Category = Toy.TOY_CATEGORY.Robot }, |
|
|
|
|
new Toy() {Name = "Robot2", Price = 80000, Category = Toy.TOY_CATEGORY.Robot }, |
|
|
|
|
new Toy() {Name = "Robot3", Price = 90000, Category = Toy.TOY_CATEGORY.Robot }, |
|
|
|
|
|
|
|
|
|
new Toy() {Name = "Car1", Price = 1000, Category = Toy.TOY_CATEGORY.Car }, |
|
|
|
|
new Toy() {Name = "Car2", Price = 60000, Category = Toy.TOY_CATEGORY.Car }, |
|
|
|
|
new Toy() {Name = "Car3", Price = 70000, Category = Toy.TOY_CATEGORY.Car }, |
|
|
|
|
|
|
|
|
|
new Toy() {Name = "Plane1", Price = 120000, Category = Toy.TOY_CATEGORY.Plane }, |
|
|
|
|
new Toy() {Name = "Plane2", Price = 60000, Category = Toy.TOY_CATEGORY.Plane }, |
|
|
|
|
new Toy() {Name = "Plane3", Price = 50000, Category = Toy.TOY_CATEGORY.Plane }, |
|
|
|
|
|
|
|
|
|
new Toy() {Name = "Figure1", Price = 120000, Category = Toy.TOY_CATEGORY.Figure }, |
|
|
|
|
new Toy() {Name = "Figure2", Price = 60000, Category = Toy.TOY_CATEGORY.Figure }, |
|
|
|
|
new Toy() {Name = "Figure3", Price = 50000, Category = Toy.TOY_CATEGORY.Figure }, |
|
|
|
|
|
|
|
|
|
new Toy() {Name = "Block1", Price = 20000, Category = Toy.TOY_CATEGORY.Block }, |
|
|
|
|
new Toy() {Name = "Block2", Price = 25000, Category = Toy.TOY_CATEGORY.Block }, |
|
|
|
|
new Toy() {Name = "Block3", Price = 32000, Category = Toy.TOY_CATEGORY.Block }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// Category로 그룹화, 그룹 내 Key = Category, |
|
|
|
|
ToyListKindOf = ToyList.GroupBy(t => t.Category.ToString()).Select(g => new KindOf<string, Toy>(g.Key, g)).ToList(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |