From 5b99d1e9e3744091d9371cb70576cfd4b68e0ac2 Mon Sep 17 00:00:00 2001 From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Fri, 28 Apr 2023 13:07:31 +0900 Subject: [PATCH] Add Assembly property to NUIGadgetInfo (#5228) Signed-off-by: Hwankyu Jhun --- src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs | 3 +++ src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs b/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs index 173f056..6a959cb 100755 --- a/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs +++ b/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; +using System.Reflection; using System.Runtime.InteropServices; using Tizen.Applications; @@ -107,6 +108,8 @@ namespace Tizen.NUI internal string ResourceClassName { get; set; } + internal Assembly Assembly { get; set; } + internal static NUIGadgetInfo CreateNUIGadgetInfo(string packageId) { Interop.PackageManagerInfo.ErrorCode errorCode = Interop.PackageManagerInfo.PackageInfoGet(packageId, out IntPtr handle); diff --git a/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs b/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs index b9270c1..af302ba 100755 --- a/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs +++ b/src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs @@ -139,19 +139,21 @@ namespace Tizen.NUI throw new ArgumentException("Failed to find NUIGadgetInfo. resource type: " + resourceType); } - Assembly assembly = null; try { - Log.Warn("NUIGadgetAssembly.Load(): " + info.ResourcePath + info.ExecutableFile + " ++"); - assembly = Assembly.Load(File.ReadAllBytes(info.ResourcePath + info.ExecutableFile)); - Log.Warn("NUIGadgetAssembly.Load(): " + info.ResourcePath + info.ExecutableFile + " --"); + if (info.Assembly == null) + { + Log.Warn("NUIGadgetAssembly.Load(): " + info.ResourcePath + info.ExecutableFile + " ++"); + info.Assembly = Assembly.Load(File.ReadAllBytes(info.ResourcePath + info.ExecutableFile)); + Log.Warn("NUIGadgetAssembly.Load(): " + info.ResourcePath + info.ExecutableFile + " --"); + } } catch (FileLoadException e) { throw new InvalidOperationException(e.Message); } - NUIGadget gadget = assembly.CreateInstance(className, true) as NUIGadget; + NUIGadget gadget = info.Assembly.CreateInstance(className, true) as NUIGadget; if (gadget == null) { throw new InvalidOperationException("Failed to create instance. className: " + className); -- 2.7.4