[NUI] Fix build warning CA1062 (#2234)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ItemIdContainer.cs
index 021fd65..b7e47bd 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2019 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,22 +19,14 @@ using System.ComponentModel;
 
 namespace Tizen.NUI
 {
-
     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
     [EditorBrowsable(EditorBrowsableState.Never)]
-    public class ItemIdContainer : global::System.IDisposable, global::System.Collections.IEnumerable
-    , global::System.Collections.Generic.IList<uint>
+    public class ItemIdContainer : Disposable, global::System.Collections.IEnumerable,
+        global::System.Collections.Generic.IList<uint>
     {
-        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 ItemIdContainer(global::System.IntPtr cPtr, bool cMemoryOwn)
+        internal ItemIdContainer(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(ItemIdContainer obj)
@@ -42,77 +34,11 @@ namespace Tizen.NUI
             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
         }
 
-        /// <summary>A Flag to check who called Dispose(). (By User or DisposeQueue)</summary>
-        private bool isDisposeQueued = false;
-
-        /// <summary>A Flag to check if it is already disposed.</summary>
-        /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
-        protected bool disposed = false;
-
-        /// <summary>Destructor.</summary>
-        /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
-        ~ItemIdContainer()
-        {
-            if (!isDisposeQueued)
-            {
-                isDisposeQueued = true;
-                DisposeQueue.Instance.Add(this);
-            }
-        }
-
-        /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public void Dispose()
-        {
-            //Throw excpetion if Dispose() is called in separate thread.
-            if (!Window.IsInstalled())
-            {
-                throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
-            }
-
-            if (isDisposeQueued)
-            {
-                Dispose(DisposeTypes.Implicit);
-            }
-            else
-            {
-                Dispose(DisposeTypes.Explicit);
-                System.GC.SuppressFinalize(this);
-            }
-        }
-
-        /// 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 virtual void Dispose(DisposeTypes type)
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
         {
-            if (disposed)
-            {
-                return;
-            }
-
-            if (type == DisposeTypes.Explicit)
-            {
-                //Called by User
-                //Release your own managed resources here.
-                //You should release all of your own disposable objects here.
-
-            }
-
-            //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.ItemIdContainer.delete_ItemIdContainer(swigCPtr);
-                }
-                swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
-            }
-
-            disposed = true;
+            Interop.ItemIdContainer.delete_ItemIdContainer(swigCPtr);
         }
 
         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
@@ -120,7 +46,7 @@ namespace Tizen.NUI
         public ItemIdContainer(global::System.Collections.ICollection c) : this()
         {
             if (c == null)
-                throw new global::System.ArgumentNullException("c");
+                throw new global::System.ArgumentNullException(nameof(c));
             foreach (uint element in c)
             {
                 this.Add(element);
@@ -216,15 +142,15 @@ namespace Tizen.NUI
         public void CopyTo(int index, uint[] array, int arrayIndex, int count)
         {
             if (array == null)
-                throw new global::System.ArgumentNullException("array");
+                throw new global::System.ArgumentNullException(nameof(array));
             if (index < 0)
-                throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
+                throw new global::System.ArgumentOutOfRangeException(nameof(index), "Value is less than zero");
             if (arrayIndex < 0)
-                throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
+                throw new global::System.ArgumentOutOfRangeException(nameof(arrayIndex), "Value is less than zero");
             if (count < 0)
-                throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
+                throw new global::System.ArgumentOutOfRangeException(nameof(count), "Value is less than zero");
             if (array.Rank > 1)
-                throw new global::System.ArgumentException("Multi dimensional array.", "array");
+                throw new global::System.ArgumentException("Multi dimensional array.", nameof(array));
             if (index + count > this.Count || arrayIndex + count > array.Length)
                 throw new global::System.ArgumentException("Number of elements to copy is too large.");
             for (int i = 0; i < count; i++)
@@ -270,7 +196,7 @@ namespace Tizen.NUI
                 collectionRef = collection;
                 currentIndex = -1;
                 currentObject = null;
-                currentSize = collectionRef.Count;
+                currentSize = collectionRef?.Count ?? 0;
             }
 
             // Type-safe iterator Current
@@ -534,7 +460,5 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
-
     }
-
 }