Release 10.0.0.16997
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / BaseHandle.cs
1 /*
2  * Copyright(c) 2021 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 System.ComponentModel;
19 using System.Runtime.CompilerServices;
20 using Tizen.NUI.Binding;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// BaseHandle is a handle to an internal Dali resource.
26     /// </summary>
27     /// <since_tizen> 3 </since_tizen>
28     public class BaseHandle : Element, global::System.IDisposable
29     {
30         /// <summary>
31         /// swigCMemOwn
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         [Obsolete("Deprecated in API9, Will be removed in API11, Please use SwigCMemOwn")]
35         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "<Pending>")]
36         protected bool swigCMemOwn;
37
38         /// <summary>
39         /// A flag to check if it is already disposed.
40         /// </summary>
41         /// <since_tizen> 3 </since_tizen>
42         [Obsolete("Deprecated in API9, Will be removed in API11, Please use Disposed")]
43         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1051:Do not declare visible instance fields", Justification = "<Pending>")]
44         protected bool disposed = false;
45
46         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
47         private global::System.Runtime.InteropServices.HandleRef swigCPtrCopy;
48         private bool registerMe;
49
50         //A Flag to check who called Dispose(). (By User or DisposeQueue)
51         private bool isDisposeQueued = false;
52
53         /// <summary>
54         /// Create an instance of BaseHandle.
55         /// </summary>
56         /// <since_tizen> 3 </since_tizen>
57         public BaseHandle() : this(Interop.BaseHandle.NewBaseHandle())
58         {
59             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
60         }
61
62         /// <summary>
63         /// Create an instance of BaseHandle.
64         /// </summary>
65         /// <param name="handle">The BaseHandle instance.</param>
66         /// <since_tizen> 3 </since_tizen>
67         public BaseHandle(BaseHandle handle) : this(Interop.BaseHandle.NewBaseHandle(BaseHandle.getCPtr(handle)))
68         {
69             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
70         }
71
72         internal BaseHandle(global::System.IntPtr cPtr, bool cMemoryOwn)
73         {
74             //to catch derived classes dali native exceptions
75             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76
77             DebugFileLogging.Instance.WriteLog($"BaseHandle.contructor with cMemeryOwn:{cMemoryOwn} START");
78
79             registerMe = swigCMemOwn = cMemoryOwn;
80             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
81             // using copy constructor to create another native handle so Registry.Unregister works fine.
82             swigCPtrCopy = new global::System.Runtime.InteropServices.HandleRef(this, Interop.BaseHandle.NewBaseHandle(swigCPtr));
83             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84
85             if (registerMe)
86             {
87                 // Register this instance of BaseHandle in the registry.
88                 Registry.Register(this);
89             }
90
91             DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{swigCPtrCopy.Handle.ToString("X8")}");
92             if (this is BaseComponents.View view)
93             {
94                   DebugFileLogging.Instance.WriteLog($"ID:{view.ID} Name:{view.Name}");
95             }
96             DebugFileLogging.Instance.WriteLog($" BaseHandle.contructor with cMemeryOwn END");
97             DebugFileLogging.Instance.WriteLog($"=============================");
98         }
99
100         internal BaseHandle(global::System.IntPtr cPtr)
101         {
102             DebugFileLogging.Instance.WriteLog($"BaseHandle.contructor START");
103
104             registerMe = swigCMemOwn = true;
105
106             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
107
108             // using copy constructor to create another native handle so Registry.Unregister works fine.
109             swigCPtrCopy = new global::System.Runtime.InteropServices.HandleRef(this, Interop.BaseHandle.NewBaseHandle(SwigCPtr));
110             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
111
112             if (registerMe)
113             {
114                 // Register this instance of BaseHandle in the registry.
115                 Registry.Register(this);
116             }
117
118             DebugFileLogging.Instance.WriteLog($"type:{GetType()} copyNativeHandle:{swigCPtrCopy.Handle.ToString("X8")}");
119             if (this is BaseComponents.View view)
120             {
121                 DebugFileLogging.Instance.WriteLog($"ID:{view.ID} Name:{view.Name}");
122             }
123             DebugFileLogging.Instance.WriteLog($"BaseHandle.contructor END");
124             DebugFileLogging.Instance.WriteLog($"=============================");
125         }
126
127         /// <summary>
128         /// Dispose.
129         /// </summary>
130         /// <since_tizen> 3 </since_tizen>
131         // following this guide: https://docs.microsoft.com/ko-kr/dotnet/fundamentals/code-analysis/quality-rules/ca1063?view=vs-2019 (CA1063)
132         ~BaseHandle() => Dispose(false);
133
134         /// <summary>
135         /// Event when a property is set.
136         /// </summary>
137         /// <since_tizen> 5 </since_tizen>
138         /// <seealso cref="BindableObject.PropertyChanged"/>
139         [Obsolete("Deprecated in API9, Will be removed in API11, Please use BindableObject.PropertyChanged instead!")]
140         public event PropertyChangedEventHandler PropertySet;
141
142         internal global::System.Runtime.InteropServices.HandleRef GetBaseHandleCPtrHandleRef
143         {
144             get
145             {
146                 return swigCPtrCopy;
147             }
148         }
149
150         /// <summary>
151         /// Returns the bool value true to indicate that an operand is true and returns false otherwise.
152         /// </summary>
153         /// <since_tizen> 3 </since_tizen>
154         public static bool operator true(BaseHandle handle)
155         {
156             // if the C# object is null, return false
157             if (BaseHandle.ReferenceEquals(handle, null))
158             {
159                 return false;
160             }
161             // returns true if the handle has a body, false otherwise
162             return handle.HasBody();
163         }
164
165         /// <summary>
166         /// Returns the bool false  to indicate that an operand is false and returns true otherwise.
167         /// </summary>
168         /// <since_tizen> 3 </since_tizen>
169         public static bool operator false(BaseHandle handle)
170         {
171             // if the C# object is null, return true
172             if (BaseHandle.ReferenceEquals(handle, null))
173             {
174                 return true;
175             }
176             return !handle.HasBody();
177         }
178
179         /// <summary>
180         /// Explicit conversion from Handle to bool.
181         /// </summary>
182         /// <since_tizen> 3 </since_tizen>
183         public static explicit operator bool(BaseHandle handle)
184         {
185             // if the C# object is null, return false
186             if (BaseHandle.ReferenceEquals(handle, null))
187             {
188                 return false;
189             }
190             // returns true if the handle has a body, false otherwise
191             return handle.HasBody();
192         }
193
194         /// <summary>
195         /// Equality operator
196         /// </summary>
197         /// <since_tizen> 3 </since_tizen>
198         public static bool operator ==(BaseHandle x, BaseHandle y)
199         {
200             // if the C# objects are the same return true
201             if (BaseHandle.ReferenceEquals(x, y))
202             {
203                 return true;
204             }
205             if (!BaseHandle.ReferenceEquals(x, null) && !BaseHandle.ReferenceEquals(y, null))
206             {
207                 // drop into native code to see if both handles point to the same body
208                 return x.IsEqual(y);
209             }
210
211             if (BaseHandle.ReferenceEquals(x, null) && !BaseHandle.ReferenceEquals(y, null))
212             {
213                 if (y.HasBody()) return false;
214                 else return true;
215             }
216             if (!BaseHandle.ReferenceEquals(x, null) && BaseHandle.ReferenceEquals(y, null))
217             {
218                 if (x.HasBody()) return false;
219                 else return true;
220             }
221
222             return false;
223         }
224
225         /// <summary>
226         /// Inequality operator. Returns Null if either operand is Null
227         /// </summary>
228         /// <since_tizen> 3 </since_tizen>
229         public static bool operator !=(BaseHandle x, BaseHandle y)
230         {
231             return !(x == y);
232         }
233
234         /// <summary>
235         /// Logical AND operator.<br />
236         /// It's possible when doing a  operator this function (opBitwiseAnd) is never called due to short circuiting.<br />
237         /// </summary>
238         /// <since_tizen> 3 </since_tizen>
239         public static BaseHandle operator &(BaseHandle x, BaseHandle y)
240         {
241             if (x == y)
242             {
243                 return x;
244             }
245             return null;
246         }
247
248         /// <summary>
249         /// Logical OR operator for ||.<br />
250         /// It's possible when doing a || this function (opBitwiseOr) is never called due to short circuiting.<br />
251         /// </summary>
252         /// <since_tizen> 3 </since_tizen>
253         public static BaseHandle operator |(BaseHandle x, BaseHandle y)
254         {
255             if (!BaseHandle.ReferenceEquals(x, null) || !BaseHandle.ReferenceEquals(y, null))
256             {
257                 if (x != null && x.HasBody())
258                 {
259                     return x;
260                 }
261                 if (y != null && y.HasBody())
262                 {
263                     return y;
264                 }
265                 return null;
266             }
267             return null;
268         }
269
270         /// <summary>
271         /// Logical ! operator
272         /// </summary>
273         /// <since_tizen> 3 </since_tizen>
274         public static bool operator !(BaseHandle x)
275         {
276             // if the C# object is null, return true
277             if (BaseHandle.ReferenceEquals(x, null))
278             {
279                 return true;
280             }
281             if (x.HasBody())
282             {
283                 return false;
284             }
285             return true;
286         }
287
288         /// <summary>
289         /// Equals
290         /// </summary>
291         /// <param name="o">The object should be compared.</param>
292         /// <returns>True if equal.</returns>
293         /// <since_tizen> 5 </since_tizen>
294         public override bool Equals(object o)
295         {
296             return base.Equals(o);
297         }
298
299         /// <summary>
300         /// Gets the hash code of this baseHandle.
301         /// </summary>
302         /// <returns>The hash code.</returns>
303         /// <since_tizen> 5 </since_tizen>
304         public override int GetHashCode()
305         {
306             return base.GetHashCode();
307         }
308
309         /// <summary>
310         /// Dispose.
311         /// </summary>
312         /// <since_tizen> 3 </since_tizen>
313         public void Dispose()
314         {
315             if (isDisposeQueued)
316             {
317                 Dispose(DisposeTypes.Implicit);
318             }
319             else
320             {
321                 Dispose(true);
322             }
323             GC.SuppressFinalize(this);
324         }
325
326         /// <summary>
327         /// Hidden API (Inhouse API).
328         /// Dispose. 
329         /// </summary>
330         /// <remarks>
331         /// Following the guide of https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose.
332         /// This will replace "protected virtual void Dispose(DisposeTypes type)" which is exactly same in functionality.
333         /// </remarks>
334         /// <param name="disposing">true in order to free managed objects</param>
335         // Protected implementation of Dispose pattern.
336         [EditorBrowsable(EditorBrowsableState.Never)]
337         protected virtual void Dispose(bool disposing)
338         {
339             if (disposed)
340             {
341                 return;
342             }
343
344             if (disposing)
345             {
346                 // TODO: dispose managed state (managed objects).
347                 // Explicit call. user calls Dispose()
348
349                 //Throw exception if Dispose() is called in separate thread.
350                 if (!Window.IsInstalled())
351                 {
352                     var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
353                     var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
354                     var me = this.GetType().FullName;
355
356                     DebugFileLogging.Instance.WriteLog("[NUI][BaseHandle] This API called from separate thread. This API must be called from MainThread. \n" +
357                         $" process:{process} thread:{thread}, disposing:{disposing}, isDisposed:{this.disposed}, isDisposeQueued:{this.isDisposeQueued}, me:{me}\n");
358
359                     throw new global::System.InvalidOperationException("[NUI][BaseHandle] This API called from separate thread. This API must be called from MainThread. \n" +
360                         $" process:{process} thread:{thread}, disposing:{disposing}, isDisposed:{this.disposed}, isDisposeQueued:{this.isDisposeQueued}, me:{me}\n");
361                 }
362
363                 if (isDisposeQueued)
364                 {
365                     DebugFileLogging.Instance.WriteLog($"should not be here! (dead code) this will be removed!");
366
367                     throw new global::System.Exception($"[NUI] should not be here! (dead code) this will be removed!");
368                     Dispose(DisposeTypes.Implicit);
369                 }
370                 else
371                 {
372                     Dispose(DisposeTypes.Explicit);
373                 }
374             }
375             else
376             {
377                 // Implicit call. user doesn't call Dispose(), so this object is added into DisposeQueue to be disposed automatically.
378                 if (!isDisposeQueued)
379                 {
380                     isDisposeQueued = true;
381                     DisposeQueue.Instance.Add(this);
382                 }
383             }
384
385             // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
386             // TODO: set large fields to null.
387         }
388
389
390         /// <summary>
391         /// Performs an action on this object with the given action name and attributes.
392         /// </summary>
393         /// <param name="actionName">The command for the action.</param>
394         /// <param name="attributes">The list of attributes for the action.</param>
395         /// <returns>The action is performed by the object or not.</returns>
396         /// <since_tizen> 3 </since_tizen>
397         public bool DoAction(string actionName, PropertyMap attributes)
398         {
399             bool ret = Interop.BaseHandle.DoAction(swigCPtrCopy, actionName, PropertyMap.getCPtr(attributes));
400             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
401             return ret;
402         }
403
404         /// <summary>
405         /// Returns the type name for the Handle.<br />
406         /// Will return an empty string if the typename does not exist. This will happen for types that
407         /// have not registered with type-registry.
408         /// </summary>
409         /// <returns>The type name. Empty string if the typename does not exist.</returns>
410         /// <since_tizen> 3 </since_tizen>
411         public string GetTypeName()
412         {
413             string ret = Interop.BaseHandle.GetTypeName(swigCPtrCopy);
414             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415             return ret;
416         }
417
418         /// <summary>
419         /// Returns the type info for the Handle.<br />
420         /// </summary>
421         /// <param name="info">The type information.</param>
422         /// <returns>True If get the type info.</returns>
423         /// <since_tizen> 3 </since_tizen>
424         public bool GetTypeInfo(Tizen.NUI.TypeInfo info)
425         {
426             bool ret = Interop.BaseHandle.GetTypeInfo(swigCPtrCopy, Tizen.NUI.TypeInfo.getCPtr(info));
427             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
428             return ret;
429         }
430
431         /// <summary>
432         /// Resets the handle.
433         /// </summary>
434         /// <since_tizen> 3 </since_tizen>
435         public void Reset()
436         {
437             Interop.BaseHandle.Reset(swigCPtrCopy);
438             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439         }
440
441         /// <summary>
442         /// To check the BaseHandle instance is equal or not.
443         /// </summary>
444         /// <param name="rhs">The baseHandle instance.</param>
445         /// <returns>True If equal.</returns>
446         /// <since_tizen> 3 </since_tizen>
447         public bool EqualTo(BaseHandle rhs)
448         {
449             bool ret = Interop.BaseHandle.EqualTo(swigCPtrCopy, BaseHandle.getCPtr(rhs));
450             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
451             return ret;
452         }
453
454         /// <summary>
455         /// To check the BaseHandle instance is equal or not.
456         /// </summary>
457         /// <param name="rhs">The baseHandle instance.</param>
458         /// <returns>True If not equal.</returns>
459         /// <since_tizen> 3 </since_tizen>
460         public bool NotEqualTo(BaseHandle rhs)
461         {
462             bool ret = Interop.BaseHandle.NotEqualTo(swigCPtrCopy, BaseHandle.getCPtr(rhs));
463             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464             return ret;
465         }
466
467         /// <summary>
468         /// To check the BaseHandle instance has body or not.
469         /// </summary>
470         /// <returns>True If the baseHandle instance has body.</returns>
471         /// <since_tizen> 3 </since_tizen>
472         public bool HasBody()
473         {
474             if (swigCPtrCopy.Handle == IntPtr.Zero)
475             {
476                 return false;
477             }
478
479             if (disposed == true)
480             {
481                 return false;
482             }
483             bool ret = Interop.BaseHandle.HasBody(swigCPtrCopy);
484             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485             return ret;
486         }
487
488         /// <summary>
489         /// To check the BaseHandle instance is equal or not.
490         /// </summary>
491         /// <param name="rhs">The baseHandle instance.</param>
492         /// <returns>True If equal.</returns>
493         /// <since_tizen> 3 </since_tizen>
494         public bool IsEqual(BaseHandle rhs)
495         {
496             if (disposed == true)
497             {
498                 return false;
499             }
500
501             bool ret = Interop.BaseHandle.IsEqual(swigCPtrCopy, BaseHandle.getCPtr(rhs));
502             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
503             return ret;
504         }
505
506         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BaseHandle obj)
507         {
508             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtrCopy;
509         }
510
511         internal void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
512         {
513             PropertySet?.Invoke(this, new PropertyChangedEventArgs(propertyName));
514         }
515
516         /// <summary>
517         /// Dispose.
518         /// </summary>
519         /// <since_tizen> 3 </since_tizen>
520         protected virtual void Dispose(DisposeTypes type)
521         {
522             if (disposed)
523             {
524                 return;
525             }
526
527             DebugFileLogging.Instance.WriteLog($"BaseHandle.Dispose({type}) START");
528
529             if (type == DisposeTypes.Explicit)
530             {
531                 //Called by User
532                 //Release your own managed resources here.
533                 //You should release all of your own disposable objects here.
534
535             }
536
537             //Release your own unmanaged resources here.
538             //You should not access any managed member here except static instance.
539             //because the execution order of Finalizes is non-deterministic.
540
541             //Unreference this instance from Registry.
542             if (registerMe)
543             {
544                 Registry.Unregister(this);
545             }
546
547             DebugFileLogging.Instance.WriteLog($"swigCMemOwn:{swigCMemOwn} type:{GetType()} copyNativeHandle:{swigCPtrCopy.Handle.ToString("X8")}");
548
549             // this is temporary test code. will be removed laster
550             {
551                 if (swigCPtr.Handle != IntPtr.Zero && swigCPtrCopy.Handle != IntPtr.Zero)
552                 {
553                     var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
554                     var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
555                     var me = this.GetType().FullName;
556                     var daliId = "unknown";
557                     var hash = this.GetType().GetHashCode();
558                     var name = "unknown";
559
560                     if (this is BaseComponents.View)
561                     {
562                         daliId = Interop.Actor.GetId(swigCPtrCopy).ToString();
563                         name = Interop.Actor.GetName(swigCPtrCopy);
564                         BaseObject tmp = new BaseObject(Interop.BaseHandle.GetBaseObject(swigCPtrCopy), false);
565                         var refCnt = tmp.ReferenceCount();
566                         tmp.Dispose();
567                         if (refCnt > 2)
568                         {
569                             DebugFileLogging.Instance.WriteLog($"[ERR] reference count is over than 2. Could be a memory leak. Need to check! \n" +
570                                 $" process:{process} thread:{thread}, isDisposed:{this.disposed}, isDisposeQueued:{this.isDisposeQueued}, me:{me} \n" +
571                                 $" disposeType:{type}, name:{name}, daliID:{daliId}, hash:{hash}, refCnt:{refCnt}");
572
573                             Log.Error("NUI", $"[ERR] reference count is over than 2. Could be a memory leak. Need to check! \n" +
574                                 $" process:{process} thread:{thread}, isDisposed:{this.disposed}, isDisposeQueued:{this.isDisposeQueued}, me:{me} \n" +
575                                 $" disposeType:{type}, name:{name}, daliID:{daliId}, hash:{hash}, refCnt:{refCnt}");
576                         }
577                     }
578                 }
579             }
580
581             if (SwigCPtr.Handle != IntPtr.Zero)
582             {
583                 if (swigCMemOwn)
584                 {
585                     swigCMemOwn = false;
586                     ReleaseSwigCPtr(SwigCPtr);
587                 }
588                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
589             }
590             else
591             {
592                 var me = this.GetType().FullName;
593                 DebugFileLogging.Instance.WriteLog($"[ERR] SwigCPtr is NULL, need to check! me:{me}");
594                 Log.Error("NUI", $"[ERR] SwigCPtr is NULL, need to check! me:{me}");
595             }
596
597             if (swigCPtrCopy.Handle != global::System.IntPtr.Zero)
598             {
599                 swigCMemOwn = false;
600                 Interop.BaseHandle.DeleteBaseHandle(swigCPtrCopy);
601                 swigCPtrCopy = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
602             }
603             else
604             {
605                 var me = this.GetType().FullName;
606                 DebugFileLogging.Instance.WriteLog($"[ERR] swigCPtrCopy is NULL, need to check! me:{me}");
607                 Log.Error("NUI", $"[ERR] swigCPtrCopy is NULL, need to check! me:{me}");
608             }
609
610             disposed = true;
611
612             if (null != Application.Current)
613             {
614                 Application.Current.XamlResourceChanged -= OnResourcesChanged;
615             }
616             DebugFileLogging.Instance.WriteLog($"BaseHandle.Dispose({type}) END");
617             DebugFileLogging.Instance.WriteLog($"=============================");
618             NUILog.Debug($"BaseHandle.Dispose({type}) END");
619             NUILog.Debug($"=============================");
620         }
621
622         /// <summary>
623         /// Release swigCPtr.
624         /// </summary>
625         /// <since_tizen> 6 </since_tizen>
626         /// This will not be public opened.
627         [EditorBrowsable(EditorBrowsableState.Never)]
628         protected virtual void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
629         {
630         }
631
632         /// <summary>
633         /// Contains event arguments for the FocusChangeRequested event.
634         /// </summary>
635         [Obsolete("Deprecated in API9; Will be removed in API11.")]
636         public class FocusRequestArgs : EventArgs
637         {
638
639             /// <summary>
640             /// Gets or sets a value that indicates the starting focus state of the element for which a focus change is requested.
641             /// </summary>
642             public bool Focus { get; set; }
643
644             /// <summary>
645             /// Gets or sets a value that indicates the ending focus state of the element for which a focus change is requested.
646             /// </summary>
647             public bool Result { get; set; }
648         }
649
650         internal global::System.Runtime.InteropServices.HandleRef SwigCPtr
651         {
652             get
653             {
654                 if (swigCPtr.Handle == IntPtr.Zero)
655                 {
656                     var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
657                     var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
658                     var me = this.GetType().FullName;
659
660                     throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " +
661                         $"OR the native dali object handle of NUI becomes null! \n" +
662                         $" process:{process} thread:{thread}, isDisposed:{this.disposed}, isDisposeQueued:{this.isDisposeQueued}, me:{me}\n");
663                 }
664                 return swigCPtr;
665             }
666         }
667
668         internal bool IsNativeHandleInvalid()
669         {
670             return swigCPtr.Handle == IntPtr.Zero;
671         }
672
673         /// <summary>
674         /// swigCMemOwn
675         /// </summary>
676         [EditorBrowsable(EditorBrowsableState.Never)]
677         protected internal bool SwigCMemOwn => swigCMemOwn;
678
679         /// <summary>
680         /// A flag to check if it is already disposed.
681         /// </summary>
682         [EditorBrowsable(EditorBrowsableState.Never)]
683         protected internal bool Disposed => disposed;
684
685         /// <summary>
686         /// A flag to check if it is disposed by DisposeQueue.
687         /// </summary>
688         [EditorBrowsable(EditorBrowsableState.Never)]
689         protected internal bool IsDisposeQueued => isDisposeQueued;
690
691     }
692 }