[NUI] Refactor dispose pattern to reduce duplication (#1112)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ItemContainer.cs
index 0a0835a..62b555b 100755 (executable)
@@ -25,16 +25,9 @@ namespace Tizen.NUI
     public class ItemContainer : Disposable, global::System.Collections.IEnumerable,
         global::System.Collections.Generic.IEnumerable<Item>
     {
-        private global::System.Runtime.InteropServices.HandleRef swigCPtr;
 
-        /// <summary>swigCMemOwn.</summary>
-        /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
-        protected bool swigCMemOwn;
-
-        internal ItemContainer(global::System.IntPtr cPtr, bool cMemoryOwn)
+        internal ItemContainer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
-            swigCMemOwn = cMemoryOwn;
-            swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
         }
 
         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ItemContainer obj)
@@ -42,30 +35,11 @@ namespace Tizen.NUI
             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
         }
 
-        /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
+        /// This will be public opened.
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected override void Dispose(DisposeTypes type)
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
         {
-            if (disposed)
-            {
-                return;
-            }
-
-            //Release your own unmanaged resources here.
-            //You should not access any managed member here except static instance.
-            //because the execution order of Finalizes is non-deterministic.
-
-            if (swigCPtr.Handle != global::System.IntPtr.Zero)
-            {
-                if (swigCMemOwn)
-                {
-                    swigCMemOwn = false;
-                    Interop.ItemContainer.delete_ItemContainer(swigCPtr);
-                }
-                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-            }
-
-            base.Dispose(type);
+            Interop.ItemContainer.delete_ItemContainer(swigCPtr);
         }
 
         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.