[NUI] Fixing the emtpy finalizers(CA1821)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PropertyArray.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// An array of property values.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class PropertyArray : Disposable
26     {
27
28         /// <summary>
29         /// The constructor.
30         /// </summary>
31         /// <since_tizen> 3 </since_tizen>
32         public PropertyArray() : this(Interop.Property.NewPropertyArray(), true)
33         {
34             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
35         }
36
37         internal PropertyArray(PropertyArray other) : this(Interop.Property.NewPropertyArray(PropertyArray.getCPtr(other)), true)
38         {
39             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
40         }
41
42         internal PropertyArray(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
43         {
44         }
45
46         /// <summary>
47         /// The operator to access an element.
48         /// </summary>
49         /// <param name="index">The element index to access. No bounds checking is performed.</param>
50         /// <returns>The reference to the element.</returns>
51         /// <since_tizen> 3 </since_tizen>
52         public PropertyValue this[uint index]
53         {
54             get
55             {
56                 return ValueOfIndex(index);
57             }
58         }
59
60         /// <summary>
61         /// Retrieves the number of elements in the array.
62         /// </summary>
63         /// <returns>The number of elements in the array.</returns>
64         /// <since_tizen> 3 </since_tizen>
65         public uint Size()
66         {
67             uint ret = Interop.Property.ArraySize(SwigCPtr);
68             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
69             return ret;
70         }
71
72         /// <summary>
73         /// Retrieves the number of elements in the array.
74         /// </summary>
75         /// <returns>The number of elements in the array.</returns>
76         /// <since_tizen> 3 </since_tizen>
77         public uint Count()
78         {
79             uint ret = Interop.Property.ArrayCount(SwigCPtr);
80             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81             return ret;
82         }
83
84         /// <summary>
85         /// Returns whether the array is empty.
86         /// </summary>
87         /// <returns>Returns true if empty, false otherwise.</returns>
88         /// <since_tizen> 3 </since_tizen>
89         public bool Empty()
90         {
91             bool ret = Interop.Property.ArrayEmpty(SwigCPtr);
92             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93             return ret;
94         }
95
96         /// <summary>
97         /// Clears the array.
98         /// </summary>
99         /// <since_tizen> 3 </since_tizen>
100         public void Clear()
101         {
102             Interop.Property.ArrayClear(SwigCPtr);
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104         }
105
106         /// <summary>
107         /// Increases the capacity of the array.
108         /// </summary>
109         /// <param name="size">The size to reserve.</param>
110         /// <since_tizen> 3 </since_tizen>
111         public void Reserve(uint size)
112         {
113             Interop.Property.ArrayReserve(SwigCPtr, size);
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115         }
116
117         /// <summary>
118         /// Resizes to size.
119         /// </summary>
120         /// <param name="size">The size to resize</param>
121         /// <since_tizen> 3 </since_tizen>
122         public void Resize(uint size)
123         {
124             Interop.Property.ArrayResize(SwigCPtr, size);
125             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126         }
127
128         /// <summary>
129         /// Retrieves the capacity of the array.
130         /// </summary>
131         /// <returns>The allocated capacity of the array.</returns>
132         /// <since_tizen> 3 </since_tizen>
133         public uint Capacity()
134         {
135             uint ret = Interop.Property.ArrayCapacity(SwigCPtr);
136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137             return ret;
138         }
139
140         /// <summary>
141         /// Adds an element to the array.
142         /// </summary>
143         /// <param name="value">The value to add at the end of the array.</param>
144         /// <since_tizen> 3 </since_tizen>
145         public void PushBack(PropertyValue value)
146         {
147             Interop.Property.ArrayPushBack(SwigCPtr, PropertyValue.getCPtr(value));
148             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149         }
150
151         /// <summary>
152         /// Adds an keyvalue to the array.
153         /// This function should be first
154         /// </summary>
155         /// <param name="value">The value to add at the end of the array.</param>
156         /// <exception cref="global::System.ArgumentNullException"> Thrown when value is null. </exception>
157         public PropertyArray Add(KeyValue value)
158         {
159             if (null == value)
160             {
161                 throw new global::System.ArgumentNullException(nameof(value));
162             }
163             PropertyArray ret = new PropertyArray(Interop.Property.ArrayAdd(SwigCPtr, PropertyValue.getCPtr(value.TrueValue)), false);
164             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165             return ret;
166         }
167
168         /// <summary>
169         /// Adds an element to the array.
170         /// </summary>
171         /// <param name="value">The value to add at the end of the array.</param>
172         /// <since_tizen> 3 </since_tizen>
173         public PropertyArray Add(PropertyValue value)
174         {
175             PropertyArray ret = new PropertyArray(Interop.Property.ArrayAdd(SwigCPtr, PropertyValue.getCPtr(value)), false);
176             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177             return ret;
178         }
179
180         /// <summary>
181         /// Accesses an element.
182         /// </summary>
183         /// <param name="index">The element index to access. No bounds checking is performed.</param>
184         /// <returns>The reference to the element.</returns>
185         /// <since_tizen> 3 </since_tizen>
186         public PropertyValue GetElementAt(uint index)
187         {
188             PropertyValue ret = new PropertyValue(Interop.Property.ArrayGetElementAt(SwigCPtr, index), false);
189             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190             return ret;
191         }
192
193         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyArray obj)
194         {
195             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
196         }
197
198         /// This will not be public opened.
199         [EditorBrowsable(EditorBrowsableState.Never)]
200         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
201         {
202             Interop.Property.DeletePropertyArray(swigCPtr);
203         }
204
205         /// <summary>
206         /// Retrieves the value of elements in the array.
207         /// </summary>
208         /// <param name="index">The element index to retrieve.</param>
209         /// <returns>The reference to the element.</returns>
210         private PropertyValue ValueOfIndex(uint index)
211         {
212             PropertyValue ret = new PropertyValue(Interop.Property.ArrayValueOfIndex(SwigCPtr, index), false);
213             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214             return ret;
215         }
216     }
217 }