2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
19 using System.ComponentModel;
23 internal class SlotObserver : global::System.IDisposable
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26 /// <summary>swigCMemOwn.</summary>
27 /// <since_tizen> 4 </since_tizen>
28 protected bool swigCMemOwn;
30 internal SlotObserver(global::System.IntPtr cPtr, bool cMemoryOwn)
32 swigCMemOwn = cMemoryOwn;
33 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
36 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SlotObserver obj)
38 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
41 //A Flag to check who called Dispose(). (By User or DisposeQueue)
42 private bool isDisposeQueued = false;
44 /// A Flat to check if it is already disposed.
46 /// <since_tizen> 4 </since_tizen>
47 protected bool disposed = false;
52 /// <since_tizen> 3 </since_tizen>
57 isDisposeQueued = true;
58 DisposeQueue.Instance.Add(this);
65 /// <since_tizen> 4 </since_tizen>
68 //Throw excpetion if Dispose() is called in separate thread.
69 if (!Window.IsInstalled())
71 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
76 Dispose(DisposeTypes.Implicit);
80 Dispose(DisposeTypes.Explicit);
81 System.GC.SuppressFinalize(this);
88 /// <since_tizen> 4 </since_tizen>
89 protected virtual void Dispose(DisposeTypes type)
96 if (type == DisposeTypes.Explicit)
99 //Release your own managed resources here.
100 //You should release all of your own disposable objects here.
104 //Release your own unmanaged resources here.
105 //You should not access any managed member here except static instance.
106 //because the execution order of Finalizes is non-deterministic.
108 if (swigCPtr.Handle != global::System.IntPtr.Zero)
113 delete_SlotObserver(swigCPtr);
115 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
122 /// This method is called when the slot is disconnecting.
124 /// <param name="callback">The callback attached to the signal disconnected.</param>
125 /// <since_tizen> 4 </since_tizen>
126 public virtual void SlotDisconnected(SWIGTYPE_p_Dali__CallbackBase callback)
128 SlotObserver_SlotDisconnected(swigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
129 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133 [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_SlotObserver")]
134 public static extern void delete_SlotObserver(global::System.Runtime.InteropServices.HandleRef jarg1);
137 [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_SlotObserver_SlotDisconnected")]
138 public static extern void SlotObserver_SlotDisconnected(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);