Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
design_pattern [2015/10/29 16:56] – 만듦 ledyxdesign_pattern [2017/10/27 01:16] (current) – 삭제 ledyx
Line 1: Line 1:
-= Design Pattern = 
  
-{{tag>DesignPattern}} 
- 
-== Prototype == 
-<sxh csharp> 
-using System.Collections.Generic; 
- 
-namespace PrototypePattern.framework 
-{ 
-    public interface ICopyable 
-    { 
-        ICopyable createClone(); 
-    } 
- 
-    public class CloneManager 
-    { 
-        private static volatile CloneManager uniqueInstance = null; 
- 
-        protected CloneManager() 
-        { 
-        } 
- 
-        public static CloneManager Instance 
-        { 
-            get 
-            { 
-                if (uniqueInstance == null) 
-                { 
-                    lock (typeof(CloneManager)) 
-                    { 
-                        if (uniqueInstance == null) 
-                            uniqueInstance = new CloneManager(); 
-                    } 
-                } 
- 
-                return uniqueInstance; 
-            } 
-        } 
- 
- 
- 
- 
-        private Dictionary<PrototypeID, ICopyable> showcase = new Dictionary<PrototypeID, ICopyable>(); 
- 
-        /// <summary> 
-        /// 등록 
-        /// </summary> 
-        /// <param name="id"></param> 
-        /// <param name="prototype"></param> 
-        public void Register(PrototypeID id, ICopyable prototype) 
-        { 
-            showcase.Add(id, prototype); //새 객체 Add 
-        } 
- 
-        /// <summary> 
-        /// 생성 및 가져오기 
-        /// </summary> 
-        /// <param name="prototypeID"></param> 
-        /// <returns></returns> 
-        public ICopyable Create(PrototypeID prototypeID) 
-        { 
-            return (ICopyable)showcase[prototypeID]; 
-        } 
- 
-        /// <summary> 
-        /// 삭제 
-        /// </summary> 
-        /// <param name="prototypeID"></param> 
-        public void Remove(PrototypeID prototypeID) 
-        { 
-            showcase.Remove(prototypeID); 
-        } 
- 
-        /// <summary> 
-        /// 재생성 
-        /// </summary> 
-        /// <param name="prototypeID"></param> 
-        /// <returns></returns> 
-        public ICopyable Recreate(PrototypeID prototypeID) 
-        { 
-            Remove(prototypeID); 
-            return Create(prototypeID); 
-        } 
- 
-        /// <summary> 
-        /// 덮어쓰기 
-        /// </summary> 
-        /// <param name="prototypeID"></param> 
-        /// <param name="prototype"></param> 
-        public void OverWrite(PrototypeID prototypeID, ICopyable prototype) 
-        { 
-            Remove(prototypeID); 
-            Register(prototypeID, prototype); 
-        } 
-    } 
- 
-    public enum PrototypeID 
-    { 
-        Original, 
-        Copy, 
-        Edit 
-    } 
-} 
-</sxh> 
design_pattern.1446137763.txt.gz · Last modified: 2021/02/07 03:15 (external edit)