*/
using System;
+using System.Collections.Generic;
+using System.IO;
using System.Runtime.InteropServices;
using Tizen;
using Tizen.Applications;
InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
IoError = Tizen.Internals.Errors.ErrorCode.IoError,
+ NoSuchTheme = Tizen.Internals.Errors.ErrorCode.NoSuchFile,
+ KeyNotAvailable = Tizen.Internals.Errors.ErrorCode.KeyNotAvailable,
}
internal static class ThemeManagerErrorFactory
return new ArgumentException(errMessage);
case Interop.ThemeManager.ErrorCode.PermissionDenied:
return new UnauthorizedAccessException(errMessage);
+ case Interop.ThemeManager.ErrorCode.NoSuchTheme:
+ return new FileNotFoundException(errMessage);
+ case Interop.ThemeManager.ErrorCode.KeyNotAvailable:
+ return new KeyNotFoundException(errMessage);
case Interop.ThemeManager.ErrorCode.IoError:
default:
return new InvalidOperationException(errMessage);
[DllImport(Libraries.ThemeManager, EntryPoint = "theme_get_bool")]
internal static extern ErrorCode GetBool(IntPtr handle, string key, out bool val);
+ [DllImport(Libraries.ThemeManager, EntryPoint = "theme_is_key_exist")]
+ internal static extern ErrorCode IsKeyExist(IntPtr handle, string key, out bool val);
+
[DllImport(Libraries.ThemeManager, EntryPoint = "theme_clone")]
internal static extern ErrorCode ThemeClone(IntPtr handle, out IntPtr cloned);
managedArray[iterator] = Marshal.PtrToStringAnsi(IntPtrArray[iterator]);
}
}
+
+ /// <summary>
+ /// Check the given key is exist or not.
+ /// </summary>
+ /// <param name="key">The string key to find information.</param>
+ /// <since_tizen> 9 </since_tizen>
+ /// <exception cref="ArgumentException">Thrown when failed because of an invalid argument.</exception>
+ public bool HasKey(string key)
+ {
+ bool val;
+ var err = Interop.ThemeManager.IsKeyExist(_handle, key, out val);
+ if (err != Interop.ThemeManager.ErrorCode.None)
+ {
+ throw Interop.ThemeManager.ThemeManagerErrorFactory.GetException(err, "Failed to check existence of the key");
+ }
+
+ return val;
+ }
+
/// <summary>
/// Releases all resources used by the Theme class.
/// </summary>