原型模式

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace DesignPattern.CreationalPattern
 8 {
 9     #region 原型模式要点
10 
11     //定义:给出原型对象指明所要创建的对象类型,通过浅复制的方式创建更多同类型对象;
12     //
13     //使用场景:当需要创建多个相同的类型实例时,为了节省内存减少资源消耗,可以通过浅复制的方式返回该对象本身;
14 
15     #endregion
16 
17     public abstract class PrototypePattern
18     {
19         public abstract PrototypePattern GetClone();
20     }
21 
22     public class ConcretePrototype : PrototypePattern
23     {
24         public override PrototypePattern GetClone()
25         {
26             return (PrototypePattern)this.MemberwiseClone();
27         }
28     }
29 
30 }

 

posted on 2021-06-25 11:47  HowieGo  阅读(33)  评论(0)    收藏  举报

导航