Ejemplo n.º 1
0
        private IAnimal CreateAnimal(PurchaseAnimalOptions animal, int age)
        {
            //See: https://docs.microsoft.com/en-us/dotnet/api/system.activator?redirectedfrom=MSDN&view=netframework-4.8
            string animalString = "ZooTycoon" + "." + animal.ToString();

            object[] arguments = new object[2] {
                age, _baseCost
            };
            System.Runtime.Remoting.ObjectHandle oh = Activator.CreateInstance("ZooTycoon", animalString, false, 0, null, arguments, null, null);
            IAnimal newAnimal = (IAnimal)oh.Unwrap();

            _zoo.Add(newAnimal);
            return(newAnimal);
        }