Ejemplo n.º 1
0
        public static OwnerCat CreateFrom(Cat cat, Owner owner)
        {
            var ownerCat = new OwnerCat {
                Cat = cat, CatId = cat.Id, Owner = owner, OwnerId = owner.Id
            };

            cat.OwnerCats.Add(ownerCat);
            owner.OwnerCats.Add(ownerCat);
            return(ownerCat);
        }
Ejemplo n.º 2
0
        static Program()
        {
            var c1 = new Cat {
                Id = 1, Name = "Cat1"
            };
            var c2 = new Cat {
                Id = 2, Name = "Cat2"
            };
            var c3 = new Cat {
                Id = 3, Name = "Cat3"
            };
            var c4 = new Cat {
                Id = 4, Name = "Cat4"
            };
            var c5 = new Cat {
                Id = 5, Name = "Cat5"
            };

            var o1 = new Owner {
                Id = 100, Name = "Owner1"
            };
            var o2 = new Owner {
                Id = 101, Name = "Owner2"
            };
            var o3 = new Owner {
                Id = 102, Name = "Owner3"
            };

            Source = new CatData
            {
                Cats      = new[] { c1, c2, c3, c4, c5 },
                Owners    = new[] { o1, o2, o3 },
                OwnerCats = new[] {
                    OwnerCat.CreateFrom(c1, o1),
                    OwnerCat.CreateFrom(c2, o1),
                    OwnerCat.CreateFrom(c3, o1),
                    OwnerCat.CreateFrom(c4, o1),
                    OwnerCat.CreateFrom(c5, o1),
                    OwnerCat.CreateFrom(c1, o2),
                    OwnerCat.CreateFrom(c2, o2),
                    OwnerCat.CreateFrom(c4, o2),
                    OwnerCat.CreateFrom(c5, o2),
                    OwnerCat.CreateFrom(c3, o3),
                }
            };

            NSJson     = NS.Serialize(Source);
            STJson     = ST.Serialize(Source);
            STUtf8Json = ST.SerializeUtf8(Source);
        }