Exemple #1
0
        public void Update(Pet pet)
        {
            pet.Name           = name;
            pet.Location       = loc("location", location).ToString();
            pet.Type           = loc("type", type).ToString();
            pet.Sex            = PetUtils.ParseSex(gender);
            pet.Breed          = breed;
            pet.BreedSecondary = breed_secondary;
            pet.Age            = age_actual;
            pet.Lifestyle      = lifestyle;
            pet.Training       = loc("training", training).ToString();
            pet.Status         = parseStatus();

            var actualAnimals  = animalHandling();
            var currentAnimals = pet.OtherAnimals;

            foreach (string animal in currentAnimals.Except(actualAnimals))
            {
                pet.RemoveOtherAnimal(animal);
            }
            foreach (string animal in actualAnimals.Except(currentAnimals))
            {
                pet.AddOtherAnimal(animal);
            }
        }
        private Pet Read(BinaryReader reader)
        {
            Pet p = new Pet(reader.ReadString(), reader.ReadString());

            p.Location       = reader.ReadString();
            p.Type           = reader.ReadString();
            p.Status         = (Status)reader.ReadInt32();
            p.Name           = reader.ReadString();
            p.Sex            = (Sex)reader.ReadInt32();
            p.Breed          = reader.ReadString();
            p.BreedSecondary = reader.ReadString();
            p.Age            = reader.ReadString();
            p.Lifestyle      = reader.ReadString();
            p.Training       = reader.ReadString();

            uint otherAnimalCount = reader.ReadUInt32();

            while (otherAnimalCount > 0)
            {
                p.AddOtherAnimal(reader.ReadString());
                otherAnimalCount--;
            }

            p.LastChanged = DateTime.FromBinary(reader.ReadInt64());
            return(p);
        }