2 * Copyright(c) 2018 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 ActivatedSignalType : global::System.IDisposable
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 /// <since_tizen> 3 </since_tizen>
30 protected bool swigCMemOwn;
32 internal ActivatedSignalType(global::System.IntPtr cPtr, bool cMemoryOwn)
34 swigCMemOwn = cMemoryOwn;
35 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ActivatedSignalType obj)
40 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43 //A Flag to check who called Dispose(). (By User or DisposeQueue)
44 private bool isDisposeQueued = false;
46 /// A Flat to check if it is already disposed.
48 /// <since_tizen> 3 </since_tizen>
49 protected bool disposed = false;
54 /// <since_tizen> 3 </since_tizen>
55 ~ActivatedSignalType()
59 isDisposeQueued = true;
60 DisposeQueue.Instance.Add(this);
67 /// <since_tizen> 3 </since_tizen>
70 //Throw excpetion if Dispose() is called in separate thread.
71 if (!Window.IsInstalled())
73 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
78 Dispose(DisposeTypes.Implicit);
82 Dispose(DisposeTypes.Explicit);
83 System.GC.SuppressFinalize(this);
90 /// <since_tizen> 3 </since_tizen>
91 protected virtual void Dispose(DisposeTypes type)
98 if (type == DisposeTypes.Explicit)
101 //Release your own managed resources here.
102 //You should release all of your own disposable objects here.
106 //Release your own unmanaged resources here.
107 //You should not access any managed member here except static instance.
108 //because the execution order of Finalizes is non-deterministic.
110 if (swigCPtr.Handle != global::System.IntPtr.Zero)
115 Interop.ActivatedSignalType.delete_ActivatedSignalType(swigCPtr);
117 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
124 /// Queries whether there are any connected slots.
126 /// <returns>True if there are any slots connected to the signal</returns>
127 /// <since_tizen> 3 </since_tizen>
130 bool ret = Interop.ActivatedSignalType.ActivatedSignalType_Empty(swigCPtr);
131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 /// Queries the number of slots.
138 /// <returns>The number of slots connected to this signal</returns>
139 /// <since_tizen> 3 </since_tizen>
140 public uint GetConnectionCount()
142 uint ret = Interop.ActivatedSignalType.ActivatedSignalType_GetConnectionCount(swigCPtr);
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148 /// Connects a function.
150 /// <param name="func">The function to connect</param>
151 /// <since_tizen> 3 </since_tizen>
152 public void Connect(System.Delegate func)
154 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
156 Interop.ActivatedSignalType.ActivatedSignalType_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 /// Disconnects a function.
164 /// <param name="func">The function to disconnect</param>
165 /// <since_tizen> 3 </since_tizen>
166 public void Disconnect(System.Delegate func)
168 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
170 Interop.ActivatedSignalType.ActivatedSignalType_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176 /// Emits the signal.
178 /// <param name="arg">The first value to pass to callbacks</param>
179 /// <since_tizen> 5 </since_tizen>
180 public void Emit(InputMethodContext arg)
182 Interop.ActivatedSignalType.ActivatedSignalType_Emit(swigCPtr, InputMethodContext.getCPtr(arg));
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189 /// <since_tizen> 3 </since_tizen>
190 public ActivatedSignalType() : this(Interop.ActivatedSignalType.new_ActivatedSignalType(), true)
192 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();