Beispiel #1
0
        private static void TestXmlSrialization()
        {
            SerializationExperiment exp = new SerializationExperiment();
            Monastery mon = exp.GetObject();

            string xml = exp.Serialize(mon);
            Console.WriteLine(xml);

            mon = exp.Deserialize<Monastery>(xml);

            Console.WriteLine(mon != null ? "Success." : "Failure.");
        }
        public Monastery GetObject()
        {
            if (monastery == null)
            {
                monastery = new Monastery();

                monastery.Churches.Add(new Building()
                {
                    Name = "Храм Христа Спасителя", FloorsCount = new ItemInt(2), InUsage = true
                });
                monastery.Churches.Add(new Building()
                {
                    Name = "Троицкий собор", IsBroken = new BoolExpression(false), FloorsCount = new ItemInt(3)
                });
                monastery.Churches.Add(new Building()
                {
                    Name = "Предтеченский скит", IsBroken = new BoolExpression(true), FloorsCount = new ItemInt(1)
                });
                monastery.LivingHouses.Add(new Building()
                {
                    Name = "Архиерейский корпус", IsBroken = new BoolExpression(false), FloorsCount = new ItemInt(3)
                });
                monastery.LivingHouses.Add(new Building()
                {
                    Name = "Трапезный корпус", IsBroken = new BoolExpression(false), FloorsCount = new ItemInt(3)
                });
                monastery.LivingHouses.Add(new Building()
                {
                    Name = "Гостиница", IsBroken = new BoolExpression(true), FloorsCount = new ItemInt(2)
                });
                monastery.WorkHouses.Add(new Building()
                {
                    Name = "Сапожня", IsBroken = new BoolExpression(true), FloorsCount = new ItemInt(2)
                });
                monastery.WorkHouses.Add(new Building()
                {
                    Name = "Коровник", FloorsCount = new ItemInt(1), InUsage = true
                });
            }

            return(monastery);
        }
Beispiel #3
0
 public Monastery(Monastery another) : base(another)
 {
 }