Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
chanwoochoi authored Sep 27, 2024
2 parents 22fe93e + 2487cd7 commit ef609eb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
24 changes: 18 additions & 6 deletions src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

using System;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
Expand All @@ -35,16 +36,21 @@ protected override Assembly Load(AssemblyName name)
}
}

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)
{
Expand All @@ -65,17 +71,23 @@ public void Load()
}
}

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)
{
return (NUIGadget)_assembly?.CreateInstance(className);
}
}

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)
{
Expand Down
6 changes: 5 additions & 1 deletion src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public string ResourcePath

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)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ private static void Unload(NUIGadgetInfo info)
if (info.NUIGadgetAssembly != null && info.NUIGadgetAssembly.IsLoaded)
{
info.NUIGadgetAssembly.Unload();
info.NUIGadgetAssembly = null;
}
}
}
Expand Down Expand Up @@ -221,7 +220,7 @@ private static void Load(NUIGadgetInfo info, bool useDefaultContext)
}
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);
Expand Down

0 comments on commit ef609eb

Please sign in to comment.