[NUI] Reduce code duplication - refactor dispose codes (#1010)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Extents.cs
1 /*
2 * Copyright (c) 2017 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;
18 using Tizen.NUI.Binding;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     /// Extents class describing the a collection of uint16_t.
24     /// </summary>
25     /// <since_tizen> 4 </since_tizen>
26     [TypeConverter(typeof(ExtentsTypeConverter))]
27     public class Extents : Disposable
28     {
29
30         /// <summary>
31         /// Extents class
32         /// </summary>
33         /// <since_tizen> 4 </since_tizen>
34         protected bool swigCMemOwn;
35
36         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
37
38         /// <summary>
39         /// Constructor.
40         /// </summary>
41         /// <since_tizen> 4 </since_tizen>
42         public Extents() : this(Interop.Extents.new_Extents__SWIG_0(), true)
43         {
44             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45         }
46
47         /// <summary>
48         /// Constructor.
49         /// </summary>
50         /// <param name="copy">A reference to the copied Extents.</param>
51         /// <since_tizen> 4 </since_tizen>
52         public Extents(Extents copy) : this(Interop.Extents.new_Extents__SWIG_1(Extents.getCPtr(copy)), true)
53         {
54             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55         }
56
57         /// <summary>
58         /// Constructor.
59         /// <param name="start">Start extent.</param>
60         /// <param name="end">End extent.</param>
61         /// <param name="top">Top extent.</param>
62         /// <param name="bottom">Bottom extent.</param>
63         /// </summary>
64         /// <since_tizen> 4 </since_tizen>
65         public Extents(ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.new_Extents__SWIG_2(start, end, top, bottom), true)
66         {
67             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68         }
69
70         internal Extents(global::System.IntPtr cPtr, bool cMemoryOwn)
71         {
72             swigCMemOwn = cMemoryOwn;
73             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
74         }
75
76         /// <summary>
77         /// The Start extent.
78         /// </summary>
79         /// <since_tizen> 4 </since_tizen>
80         public ushort Start
81         {
82             set
83             {
84                 Interop.Extents.Extents_start_set(swigCPtr, value);
85                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86             }
87             get
88             {
89                 ushort ret = Interop.Extents.Extents_start_get(swigCPtr);
90                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91                 return ret;
92             }
93         }
94
95         /// <summary>
96         /// The End extend.
97         /// </summary>
98         /// <since_tizen> 4 </since_tizen>
99         public ushort End
100         {
101             set
102             {
103                 Interop.Extents.Extents_end_set(swigCPtr, value);
104                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105             }
106             get
107             {
108                 ushort ret = Interop.Extents.Extents_end_get(swigCPtr);
109                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110                 return ret;
111             }
112         }
113
114         /// <summary>
115         /// The Top extend.
116         /// </summary>
117         /// <since_tizen> 4 </since_tizen>
118         public ushort Top
119         {
120             set
121             {
122                 Interop.Extents.Extents_top_set(swigCPtr, value);
123                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124             }
125             get
126             {
127                 ushort ret = Interop.Extents.Extents_top_get(swigCPtr);
128                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129                 return ret;
130             }
131         }
132
133         /// <summary>
134         /// The Bottom Extend.
135         /// </summary>
136         /// <since_tizen> 4 </since_tizen>
137         public ushort Bottom
138         {
139             set
140             {
141                 Interop.Extents.Extents_bottom_set(swigCPtr, value);
142                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143             }
144             get
145             {
146                 ushort ret = Interop.Extents.Extents_bottom_get(swigCPtr);
147                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148                 return ret;
149             }
150         }
151
152         /// <summary>
153         /// Equality operator.
154         /// </summary>
155         /// <param name="rhs">The Extents to test against.</param>
156         /// <returns>True if the extents are not equal.</returns>
157         /// <since_tizen> 4 </since_tizen>
158         public bool EqualTo(Extents rhs)
159         {
160             bool ret = Interop.Extents.Extents_EqualTo(swigCPtr, Extents.getCPtr(rhs));
161             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162             return ret;
163         }
164
165         /// <summary>
166         /// Inequality operator.
167         /// </summary>
168         /// <param name="rhs">The Extents to test against.</param>
169         /// <returns>True if the extents are not equal.</returns>
170         /// <since_tizen> 4 </since_tizen>
171         public bool NotEqualTo(Extents rhs)
172         {
173             bool ret = Interop.Extents.Extents_NotEqualTo(swigCPtr, Extents.getCPtr(rhs));
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175             return ret;
176         }
177
178         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Extents obj)
179         {
180             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
181         }
182
183         internal Extents Assign(SWIGTYPE_p_uint16_t array)
184         {
185             Extents ret = new Extents(Interop.Extents.Extents_Assign__SWIG_1(swigCPtr, SWIGTYPE_p_uint16_t.getCPtr(array)), false);
186             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187             return ret;
188         }
189
190         internal Extents Assign(Extents copy)
191         {
192             Extents ret = new Extents(Interop.Extents.Extents_Assign__SWIG_0(swigCPtr, Extents.getCPtr(copy)), false);
193             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194             return ret;
195         }
196
197         /// <summary>
198         /// To make a Extents instance be disposed.
199         /// </summary>
200         /// <param name="type">Extents type</param>
201         /// <since_tizen> 4 </since_tizen>
202         protected override void Dispose(DisposeTypes type)
203         {
204             if (disposed)
205             {
206                 return;
207             }
208
209             //Release your own unmanaged resources here.
210             //You should not access any managed member here except static instance.
211             //because the execution order of Finalizes is non-deterministic.
212
213             if (swigCPtr.Handle != global::System.IntPtr.Zero)
214             {
215                 if (swigCMemOwn)
216                 {
217                     swigCMemOwn = false;
218                     Interop.Extents.delete_Extents(swigCPtr);
219                 }
220                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
221             }
222             base.Dispose(type);
223         }
224     }
225 }