Apply Dispose pattern to NUI.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Degree.cs
1 //------------------------------------------------------------------------------
2 // <auto-generated />
3 //
4 // This file was automatically generated by SWIG (http://www.swig.org).
5 // Version 3.0.9
6 //
7 // Do not make changes to this file unless you know what you are doing--modify
8 // the SWIG interface file instead.
9 //------------------------------------------------------------------------------
10
11 namespace Tizen.NUI
12 {
13
14     /// <summary>
15     /// An angle in degrees.<br>
16     /// This reduces ambiguity when using methods which accept angles in degrees or radians.<br>
17     /// </summary>
18     public class Degree : global::System.IDisposable
19     {
20         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
21         protected bool swigCMemOwn;
22
23         internal Degree(global::System.IntPtr cPtr, bool cMemoryOwn)
24         {
25             swigCMemOwn = cMemoryOwn;
26             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
27         }
28
29         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Degree obj)
30         {
31             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
32         }
33
34         //NUI Dispose Pattern written by Jinwoo Nam(jjw.nam) 
35
36         //A Flag to check who called Dispose(). (By User or DisposeQueue)
37         private bool isDisposeQueued = false;
38         //A Flat to check if it is already disposed.
39         protected bool disposed = false;
40         
41         ~Degree()
42         {
43             if(!isDisposeQueued)
44             {
45                 isDisposeQueued = true;
46                 DisposeQueue.Instance.Add(this);
47             }
48         }
49         public void Dispose()
50         {
51             //Throw excpetion if Dispose() is called in separate thread.
52             if (!Window.IsInstalled())
53             {
54                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
55             }
56
57             if (isDisposeQueued)
58             {
59                 Dispose(DisposeTypes.Implicit);
60             }
61             else
62             {
63                 Dispose(DisposeTypes.Explicit);
64                 System.GC.SuppressFinalize(this);
65             }
66         }
67
68         protected virtual void Dispose(DisposeTypes type)
69         {
70             if (disposed)
71             {
72                 return;
73             }
74
75             if(type == DisposeTypes.Explicit)
76             {
77                 //Called by User
78                 //Release your own managed resources here.
79                 //You should release all of your own disposable objects here.
80             }
81
82             //Release your own unmanaged resources here.
83             //You should not access any managed member here except static instance.
84             //because the execution order of Finalizes is non-deterministic.
85
86             if (swigCPtr.Handle != global::System.IntPtr.Zero)
87             {
88                 if (swigCMemOwn)
89                 {
90                     swigCMemOwn = false;
91                     NDalicPINVOKE.delete_Degree(swigCPtr);
92                 }
93                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
94             }
95             disposed = true;
96         }
97
98         /// <summary>
99         /// Constructor.
100         /// </summary>
101         public Degree() : this(NDalicPINVOKE.new_Degree__SWIG_0(), true)
102         {
103             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104         }
105
106         /// <summary>
107         /// Creates an angle in degrees.
108         /// </summary>
109         /// <param name="value">The initial value in degrees</param>
110         public Degree(float value) : this(NDalicPINVOKE.new_Degree__SWIG_1(value), true)
111         {
112             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113         }
114
115         /// <summary>
116         /// Creates an angle in degrees from a Radian.
117         /// </summary>
118         /// <param name="value">The initial value in Radians</param>
119         public Degree(Radian value) : this(NDalicPINVOKE.new_Degree__SWIG_2(Radian.getCPtr(value)), true)
120         {
121             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122         }
123
124         public float degree
125         {
126             set
127             {
128                 NDalicPINVOKE.Degree_degree_set(swigCPtr, value);
129                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130             }
131             get
132             {
133                 float ret = NDalicPINVOKE.Degree_degree_get(swigCPtr);
134                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135                 return ret;
136             }
137         }
138
139     }
140
141 }