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.
22 /// Signal connection class for PropertyNotification
24 /// <since_tizen> 4 </since_tizen>
25 public class PropertyNotifySignal : global::System.IDisposable
30 /// <since_tizen> 4 </since_tizen>
31 protected bool swigCMemOwn;
33 /// A Flat to check if it is already disposed.
35 /// <since_tizen> 4 </since_tizen>
36 protected bool disposed = false;
38 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
40 //A Flag to check who called Dispose(). (By User or DisposeQueue)
41 private bool isDisposeQueued = false;
46 /// <since_tizen> 4 </since_tizen>
47 public PropertyNotifySignal() : this(NDalicPINVOKE.new_PropertyNotifySignal(), true)
49 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52 internal PropertyNotifySignal(global::System.IntPtr cPtr, bool cMemoryOwn)
54 swigCMemOwn = cMemoryOwn;
55 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
61 /// <since_tizen> 3 </since_tizen>
62 ~PropertyNotifySignal()
66 isDisposeQueued = true;
67 DisposeQueue.Instance.Add(this);
74 /// <since_tizen> 4 </since_tizen>
77 //Throw excpetion if Dispose() is called in separate thread.
78 if (!Window.IsInstalled())
80 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
85 Dispose(DisposeTypes.Implicit);
89 Dispose(DisposeTypes.Explicit);
90 System.GC.SuppressFinalize(this);
95 /// Queries whether there are any connected slots.
97 /// <returns>True if there are any slots connected to the signal.</returns>
98 /// <since_tizen> 4 </since_tizen>
101 bool ret = NDalicPINVOKE.PropertyNotifySignal_Empty(swigCPtr);
102 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
107 /// Queries the number of slots.
109 /// <returns>The number of slots connected to this signal</returns>
110 /// <since_tizen> 4 </since_tizen>
111 public uint GetConnectionCount()
113 uint ret = NDalicPINVOKE.PropertyNotifySignal_GetConnectionCount(swigCPtr);
114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 /// Connects a function.
121 /// <param name="func">The function to connect</param>
122 /// <since_tizen> 4 </since_tizen>
123 public void Connect(System.Delegate func)
125 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
127 NDalicPINVOKE.PropertyNotifySignal_Connect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133 /// Disconnects a function.
135 /// <param name="func">The function to disconnect.</param>
136 /// <since_tizen> 4 </since_tizen>
137 public void Disconnect(System.Delegate func)
139 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
141 NDalicPINVOKE.PropertyNotifySignal_Disconnect(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip));
142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147 /// Emits a signal with 1 parameter.
149 /// <param name="arg">The first value to pass to callbacks.</param>
150 /// <since_tizen> 4 </since_tizen>
151 public void Emit(PropertyNotification arg)
153 NDalicPINVOKE.PropertyNotifySignal_Emit(swigCPtr, PropertyNotification.getCPtr(arg));
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotifySignal obj)
159 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
165 /// <param name="type">The dispose type.</param>
166 /// <since_tizen> 4 </since_tizen>
167 protected virtual void Dispose(DisposeTypes type)
174 if (type == DisposeTypes.Explicit)
177 //Release your own managed resources here.
178 //You should release all of your own disposable objects here.
182 //Release your own unmanaged resources here.
183 //You should not access any managed member here except static instance.
184 //because the execution order of Finalizes is non-deterministic.
186 if (swigCPtr.Handle != global::System.IntPtr.Zero)
191 NDalicPINVOKE.delete_PropertyNotifySignal(swigCPtr);
193 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);