The gadget mount path will be changed to the 'bin/.res_mount'.
If it's applied, the NUIGadgetManager can remount the resources.
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
private readonly string _assemblyPath;
private WeakReference _assemblyRef;
private Assembly _assembly = null;
+ private bool _loaded = false;
internal NUIGadgetAssembly(string assemblyPath) { _assemblyPath = assemblyPath; }
{
lock (_assemblyLock)
{
- if (_assembly != null)
+ if (_loaded)
{
return;
}
Log.Warn("Load(): " + _assemblyPath + " ++");
NUIGadgetAssemblyLoadContext context = new NUIGadgetAssemblyLoadContext();
_assemblyRef = new WeakReference(context);
- using (FileStream stream = new FileStream(_assemblyPath, FileMode.Open, FileAccess.Read))
- {
- _assembly = context.LoadFromStream(stream);
- }
+ string directoryPath = SystemIO.Path.GetDirectoryName(_assemblyPath);
+ string fileName = SystemIO.Path.GetFileNameWithoutExtension(_assemblyPath);
+ string nativeImagePath = directoryPath + "/.native_image/" + fileName + ".ni.dll";
+ Log.Debug("NativeImagePath=" + nativeImagePath + ", AssemblyPath=" + _assemblyPath);
+ _assembly = context.LoadFromNativeImagePath(nativeImagePath, _assemblyPath);
Log.Warn("Load(): " + _assemblyPath + " --");
+ _loaded = true;
}
}
- internal bool IsLoaded { get { return _assembly != null; } }
+ internal bool IsLoaded { get { return _loaded; } }
internal NUIGadget CreateInstance(string className)
{
{
lock (_assemblyLock)
{
- if (_assembly == null)
+ if (!_loaded)
{
return;
}
(_assemblyRef.Target as NUIGadgetAssemblyLoadContext).Unload();
}
- _assembly = null;
+ _loaded = false;
Log.Warn("Unload(): " + _assemblyPath + " --");
}
}
}
/// <summary>
- /// Gets the allowed resource path of the gadget.
+ /// Gets the gadget resource path of the gadget.
/// </summary>
/// <since_tizen> 12 </since_tizen>
- public string AllowedResourcePath
+ public string GadgetResourcePath
{
get; private set;
}
Log.Warn("Failed to destroy package info. error = " + errorCode);
}
- info.ResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.ApplicationInfo.ExecutablePath) + "/";
- info.AllowedResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.DirectoryInfo.Resource) + "/mount/allowed/" + info.ResourceType + "/";
- if (!Directory.Exists(info.AllowedResourcePath))
+ info.ResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.ApplicationInfo.ExecutablePath) + "/.res_mount/";
+ if (!Directory.Exists(info.ResourcePath))
{
- info.AllowedResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.DirectoryInfo.Resource) + "/mount/allowed/";
+ info.ResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.ApplicationInfo.ExecutablePath) + "/";
+ }
+
+ info.GadgetResourcePath = info.ResourcePath + info.ResourceType + "/";
+ if (!Directory.Exists(info.GadgetResourcePath))
+ {
+ info.GadgetResourcePath = info.ResourcePath;
}
return info;
}
{
if (info.NUIGadgetAssembly == null || !info.NUIGadgetAssembly.IsLoaded)
{
- Log.Warn("NUIGadgetAssembly.Load(): " + info.AllowedResourcePath + info.ExecutableFile + " ++");
- info.NUIGadgetAssembly = new NUIGadgetAssembly(info.AllowedResourcePath + info.ExecutableFile);
+ Log.Warn("NUIGadgetAssembly.Load(): " + info.GadgetResourcePath + info.ExecutableFile + " ++");
+ info.NUIGadgetAssembly = new NUIGadgetAssembly(info.GadgetResourcePath + info.ExecutableFile);
info.NUIGadgetAssembly.Load();
- Log.Warn("NUIGadgetAssembly.Load(): " + info.AllowedResourcePath + info.ExecutableFile + " --");
+ Log.Warn("NUIGadgetAssembly.Load(): " + info.GadgetResourcePath + info.ExecutableFile + " --");
}
}
}