[NUI.Gadget] Export NUIGadgetAssembly class for inhouse developers (#6379)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Fri, 27 Sep 2024 07:22:10 +0000 (16:22 +0900)
committerGitHub <noreply@github.com>
Fri, 27 Sep 2024 07:22:10 +0000 (16:22 +0900)
The developers want to check whether the assembly is alive or not.
This patch provides the NUIGadgetAssembly for inhouse developers.

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetAssembly.cs
src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs
src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs

index 9946fe8caada828e081553d007f3fcff3759fe28..206bf788be7c913905f5650a2f8faf8ae97894e9 100644 (file)
@@ -15,6 +15,7 @@
 */
 
 using System;
+using System.ComponentModel;
 using System.IO;
 using System.Reflection;
 using System.Runtime.Loader;
@@ -35,16 +36,21 @@ namespace Tizen.NUI
         }
     }
 
-    internal class NUIGadgetAssembly
+    /// <summary>
+    /// Represents a class that provides access to the methods and properties of the NUIGadgetAssembly.
+    /// </summary>
+    /// <since_tizen> 10 </since_tizen>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public class NUIGadgetAssembly
     {
         private static readonly object _assemblyLock = new object();
         private readonly string _assemblyPath;
         private WeakReference _assemblyRef;
         private Assembly _assembly = null;
 
-        public NUIGadgetAssembly(string assemblyPath) { _assemblyPath = assemblyPath; }
+        internal NUIGadgetAssembly(string assemblyPath) { _assemblyPath = assemblyPath; }
 
-        public void Load()
+        internal void Load()
         {
             lock (_assemblyLock)
             {
@@ -65,9 +71,9 @@ namespace Tizen.NUI
             }
         }
 
-        public bool IsLoaded { get { return _assembly != null; } }
+        internal bool IsLoaded { get { return _assembly != null; } }
 
-        public NUIGadget CreateInstance(string className)
+        internal NUIGadget CreateInstance(string className)
         {
             lock (_assemblyLock)
             {
@@ -75,7 +81,13 @@ namespace Tizen.NUI
             }
         }
 
-        public void Unload()
+        /// <summary>
+        /// Property indicating whether the weak reference to the gadget assembly is still alive.
+        /// </summary>
+        /// <since_tizen> 12 </since_tizen>
+        public bool IsAlive {  get { return _assemblyRef.IsAlive; } }
+
+        internal void Unload()
         {
             lock (_assemblyLock)
             {
index d25f5200717e847e90d9cb2976757f91858843b7..dcd551f43d3b511886a48e24ff6aa6baa41d3a83 100755 (executable)
@@ -87,7 +87,11 @@ namespace Tizen.NUI
 
         internal Assembly Assembly { get; set; }
 
-        internal NUIGadgetAssembly NUIGadgetAssembly { get; set; }
+        /// <summary>
+        /// Gets the assembly of the gadget.
+        /// </summary>
+        /// <since_tizen> 12 </since_tizen>
+        public NUIGadgetAssembly NUIGadgetAssembly { get; set; }
 
         internal static NUIGadgetInfo CreateNUIGadgetInfo(string packageId)
         {
index 05aa1746632c44b1885ac5b81778ab0063613cc8..c0289ea0bb40cc97e2d641f97c20d91393559503 100755 (executable)
@@ -193,7 +193,6 @@ namespace Tizen.NUI
                 if (info.NUIGadgetAssembly != null && info.NUIGadgetAssembly.IsLoaded)
                 {
                     info.NUIGadgetAssembly.Unload();
-                    info.NUIGadgetAssembly = null;
                 }
             }
         }
@@ -221,7 +220,7 @@ namespace Tizen.NUI
                     }
                     else
                     {
-                        if (info.NUIGadgetAssembly == null)
+                        if (info.NUIGadgetAssembly == null || !info.NUIGadgetAssembly.IsLoaded)
                         {
                             Log.Warn("NUIGadgetAssembly.Load(): " + info.ResourcePath + info.ExecutableFile + " ++");
                             info.NUIGadgetAssembly = new NUIGadgetAssembly(info.ResourcePath + info.ExecutableFile);