using System;
using System.Collections.Generic;
using System.ComponentModel;
-using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Tizen.Applications;
+using SystemIO = System.IO;
+
namespace Tizen.NUI
{
/// <summary>
private const string MetadataUIGadgetDll = "http://tizen.org/metadata/ui-gadget/dll";
private const string MetadataUIGadgetResourceDll = "http://tizen.org/metadata/ui-gadget/resource/dll";
private const string MetadataUIGadgetResourceClassName = "http://tizen.org/metadata/ui-gadget/resource/class-name";
- private string _resourcePath = string.Empty;
internal NUIGadgetInfo(string packageId)
{
PackageId = packageId;
Log.Warn("PackageId: " + PackageId);
- AllowedPath = Application.Current.DirectoryInfo.Resource + "mount/allowed/";
- Log.Warn("AllowedPath: " + AllowedPath);
- GlobalPath = Application.Current.DirectoryInfo.Resource + "mount/global/";
- Log.Warn("GlobalPath: " + GlobalPath);
}
- private string AllowedPath { get; set; }
-
- private string GlobalPath { get; set; }
-
/// <summary>
/// Gets the package ID of the gadget.
/// </summary>
/// <since_tizen> 10 </since_tizen>
public string ResourcePath
{
- get
- {
- if (!string.IsNullOrEmpty(_resourcePath))
- return _resourcePath;
-
- if (File.Exists(GlobalPath + ExecutableFile))
- {
- _resourcePath = GlobalPath;
- }
- else if (File.Exists(AllowedPath + ExecutableFile))
- {
- _resourcePath = AllowedPath;
- }
-
- return _resourcePath;
- }
+ get; private set;
}
/// <summary>
Log.Warn("Failed to destroy package info. error = " + errorCode);
}
+ info.ResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.ApplicationInfo.ExecutablePath) + "/";
return info;
}
}
using System.Runtime.InteropServices;
using System.Reflection;
+using SystemIO = System.IO;
+
namespace Tizen.NUI
{
/// <summary>
static NUIGadgetManager()
{
- IntPtr resPkgIds = Interop.Libc.GetEnviornmentVariable("RES_PKGIDS");
- if (resPkgIds != IntPtr.Zero)
+ IntPtr gadgetPkgIds = Interop.Libc.GetEnviornmentVariable("GADGET_PKGIDS");
+ if (gadgetPkgIds != IntPtr.Zero)
{
- string packages = Marshal.PtrToStringAnsi(resPkgIds);
+ string packages = Marshal.PtrToStringAnsi(gadgetPkgIds);
if (string.IsNullOrEmpty(packages))
{
Log.Warn("There is no resource packages");
{
_gadgetInfos.Add(info.ResourceType, info);
}
+ else
+ {
+ Log.Error("Failed to create NUIGadgetInfo. package=" + packageId);
+ }
}
}
}
{
throw new InvalidOperationException(e.Message);
}
+ catch (BadImageFormatException e)
+ {
+ throw new InvalidOperationException(e.Message);
+ }
}
private static void Load(NUIGadgetInfo info)
{
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 + " --");
+ Log.Warn("Assembly.Load(): " + info.ResourcePath + info.ExecutableFile + " ++");
+ info.Assembly = Assembly.Load(SystemIO.Path.GetFileNameWithoutExtension(info.ExecutableFile));
+ Log.Warn("Assembly.Load(): " + info.ResourcePath + info.ExecutableFile + " --");
}
}
}
{
throw new InvalidOperationException(e.Message);
}
+ catch (BadImageFormatException e)
+ {
+ throw new InvalidOperationException(e.Message);
+ }
NUIGadget gadget = info.Assembly.CreateInstance(className, true) as NUIGadget;
if (gadget == null)