Пример #1
0
        public void DeepDogWithReflection()
        {
            PrototypeAnimalDog dog = new PrototypeAnimalDog
            {
                Details = new AdditionalDetails
                {
                    Height = 777,
                    Weight = 888
                },
                Name    = "Doggo",
                Barcode = "333"
            };

            PrototypeAnimalDog doggoWithReflection = (PrototypeAnimalDog)dog.CloneProcedure();

            dog.Details.Height = 111;
            dog.Details.Weight = 222;
            dog.Name           = "first_dogi";
            dog.Barcode        = "ciap ciap";

            Console.WriteLine("\n--------------------------------\n  Deep Dog With Reflection\n Original animal stats:");
            Console.WriteLine($"\nName: {dog.Name}\n Barcode: {dog.Barcode}\n Charisma {dog.Details.Height}\n Details.Height: {dog.Details.Weight}\n DeeperData {dog.Details.DeeperData.Data} ");

            Console.WriteLine("\nCopy of animal to save on disk:");
            Console.WriteLine($"\nName: {doggoWithReflection.Name}\n Barcode: {doggoWithReflection.Barcode}\n Details.Height: {doggoWithReflection.Details.Height}\n Details.Weight " +
                              $"{doggoWithReflection.Details.Weight}\n Details.DeeperData.Data: { doggoWithReflection.Details.DeeperData.Data} ");
        }
Пример #2
0
        public void DeepDogSerializable()
        {
            PrototypeAnimalDog dog = new PrototypeAnimalDog
            {
                Details = new AdditionalDetails
                {
                    Height = 777,
                    Weight = 888
                },
                Name    = "Doggo",
                Barcode = "333"
            };

            PrototypeAnimalDog c3 = new PrototypeAnimalDog();

            c3                          = dog.DeepCopy();
            dog.Name                    = "NEEEEWW DOGOO";
            dog.Barcode                 = "wuuf";
            dog.Details.Height          = 456;
            dog.Details.Height          = 789;
            dog.Details.DeeperData.Data = "new data 3 level";

            Console.WriteLine("\n--------------------------------\nChanged Data\n Original animal stats:");
            Console.WriteLine($"\nName: {dog.Name}\n Barcode: {dog.Barcode}\n Height {dog.Details.Height}\n Weight {dog.Details.Weight}\n DeeperData  { dog.Details.DeeperData.Data} ");

            Console.WriteLine("\nCopy of animal to save on disk:");
            Console.WriteLine($"\nName: {c3.Name}\n Barcode: {c3.Barcode}\n Height {c3.Details.Height}\n Weight { c3.Details.Weight}\n DeeperData { c3.Details.DeeperData.Data} ");
        }