示例#1
0
        public void PrototypeDemo2()
        {
            var prototype = new PrototypeClass
            {
                Id   = 77,
                Info = new PrototypeInfoClass {
                    Info = "详细信息1"
                }
            };
            var copy = prototype.Copy();

            Console.WriteLine(copy);
            prototype.Info.Info = "详细信息2";
            Console.WriteLine(copy);
            copy = prototype.Copy();
            Console.WriteLine(copy);
        }
示例#2
0
        public void PrototypeDemo()
        {
            var prototype = new PrototypeClass
            {
                Id   = 66,
                Info = new PrototypeInfoClass {
                    Info = "详细信息"
                }
            };

            var shall = prototype.ShallCopy();
            var deep  = prototype.DeepCopy();

            prototype.Info.Info = "修改后的详细信息";

            Console.WriteLine($"------  Shall Copy  ------");
            Console.WriteLine(shall);

            Console.WriteLine($"------  Deep Copy  ------");
            Console.WriteLine(deep);
        }