X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.Applications.Common%2FTizen.Applications%2FAppControl.cs;h=3bd02e21ef69778701eb93b34c0f1a3d3a5ec45b;hb=5efb856c61ace8ba2303355fd31c86254b4d1a91;hp=a0e1f8870094b16c8f429d1bddd67b3f1b812665;hpb=7c99bee978f7700d4132e18b1a85b86d7bd08ad2;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs index a0e1f88..3bd02e2 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs @@ -16,8 +16,10 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Runtime.InteropServices; +using System.Threading.Tasks; namespace Tizen.Applications { @@ -40,12 +42,14 @@ namespace Tizen.Applications /// } /// /// + /// 3 public class AppControl { private const string LogTag = "Tizen.Applications"; - private static Dictionary s_replyNativeCallbackMaps = new Dictionary(); - private static int s_replyNativeCallbackId = 0; + private static Dictionary s_resultNativeCallbackMaps = new Dictionary(); + private static Dictionary s_replyCallbackMaps = new Dictionary(); + private static int s_reaustId = 0; private readonly SafeAppControlHandle _handle; @@ -55,11 +59,13 @@ namespace Tizen.Applications private string _category = null; private string _applicationId = null; private ExtraDataCollection _extraData = null; + private string _componentId = null; /// /// Initializes the instance of the AppControl class. /// /// Thrown when failed to create the AppControl handle. + /// 3 public AppControl() { Interop.AppControl.ErrorCode err = Interop.AppControl.Create(out _handle); @@ -74,6 +80,7 @@ namespace Tizen.Applications /// /// The flag value to receive an additional launch result event on the launch request. /// Thrown when failed to create the AppControl handle. + /// 3 public AppControl(bool enableAppStartedResultEvent) { Interop.AppControl.ErrorCode err = Interop.AppControl.Create(out _handle); @@ -96,17 +103,39 @@ namespace Tizen.Applications /// Initializes the instance of the AppControl class with the SafeAppControlHandle. /// /// + /// 3 public AppControl(SafeAppControlHandle handle) { if (handle == null) { - throw new ArgumentNullException("handle"); + throw new ArgumentNullException(nameof(handle)); } - Interop.AppControl.ErrorCode err = Interop.AppControl.DangerousClone(out _handle, handle.DangerousGetHandle()); - if (err != Interop.AppControl.ErrorCode.None) + if (handle.IsInvalid) { - throw new InvalidOperationException("Failed to clone the appcontrol handle. Err = " + err); + throw new ArgumentNullException(nameof(handle), "handle is invalid"); + } + + bool mustRelease = false; + try + { + handle.DangerousAddRef(ref mustRelease); + Interop.AppControl.ErrorCode err = Interop.AppControl.DangerousClone(out _handle, handle.DangerousGetHandle()); + if (err != Interop.AppControl.ErrorCode.None) + { + throw new InvalidOperationException("Failed to clone the appcontrol handle. Err = " + err); + } + } + catch (ObjectDisposedException e) + { + throw new ArgumentNullException(nameof(handle), e.Message); + } + finally + { + if (mustRelease) + { + handle.DangerousRelease(); + } } } @@ -119,11 +148,28 @@ namespace Tizen.Applications } } - #region Public Properties + private static Interop.AppControl.ReplyCallback s_replyNativeCallback = (launchHandle, replyHandle, result, userData) => + { + int requestId = (int)userData; + lock (s_replyCallbackMaps) + { + if (s_replyCallbackMaps.ContainsKey(requestId)) + { + s_replyCallbackMaps[requestId](new AppControl(launchHandle), new AppControl(replyHandle), (AppControlReplyResult)result); + if (result != Interop.AppControl.AppStartedStatus) + { + s_replyCallbackMaps.Remove(requestId); + } + } + } + }; + +#region Public Properties /// /// Gets the SafeAppControlHandle instance. /// + /// 3 public SafeAppControlHandle SafeAppControlHandle { get @@ -148,6 +194,7 @@ namespace Tizen.Applications /// Log.Debug(LogTag, "Operation: " + appControl.Operation); /// /// + /// 3 public string Operation { get @@ -189,6 +236,7 @@ namespace Tizen.Applications /// Log.Debug(LogTag, "Mime: " + appControl.Mime); /// /// + /// 3 public string Mime { get @@ -245,7 +293,10 @@ namespace Tizen.Applications /// } /// /// + /// 3 +#pragma warning disable CA1056 public string Uri +#pragma warning restore CA1056 { get { @@ -279,6 +330,7 @@ namespace Tizen.Applications /// /// (if the category is null for setter, it clears the previous value.) /// + /// 3 public string Category { get @@ -320,6 +372,7 @@ namespace Tizen.Applications /// Log.Debug(LogTag, "ApplicationId: " + appControl.ApplicationId); /// /// + /// 3 public string ApplicationId { get @@ -366,6 +419,7 @@ namespace Tizen.Applications /// appControl.LaunchMode = AppControlLaunchMode.Group; /// /// + /// 3 public AppControlLaunchMode LaunchMode { get @@ -401,6 +455,7 @@ namespace Tizen.Applications /// ... /// /// + /// 3 public ExtraDataCollection ExtraData { get @@ -411,7 +466,53 @@ namespace Tizen.Applications } } - #endregion // Public Properties + /// + /// Gets and sets the component ID to explicitly launch a component. + /// + /// + /// (if the component ID is null for setter, it clears the previous value.) + /// From Tizen 5.5, a new application model is supported that is component-based application. + /// This property is for launching component-based application. If it's not set, the main component of component-based application will be launched. + /// If the target app is not component-based application, setting property is meaningless. + /// + /// + /// + /// AppControl appControl = new AppControl(); + /// appControl.ApplicationId = "org.tizen.component-based-app"; // component-based application + /// appControl.ComponentId = "org.tizen.frame-component"; + /// AppControl.SendLaunchRequest(appControl); + /// + /// + /// 6 + public string ComponentId + { + get + { + if (String.IsNullOrEmpty(_componentId)) + { + Interop.AppControl.ErrorCode err = Interop.AppControl.GetComponentId(_handle, out _componentId); + if (err != Interop.AppControl.ErrorCode.None) + { + Log.Warn(LogTag, "Failed to get the component id from the AppControl. Err = " + err); + } + } + return _componentId; + } + set + { + Interop.AppControl.ErrorCode err = Interop.AppControl.SetComponentId(_handle, value); + if (err == Interop.AppControl.ErrorCode.None) + { + _componentId = value; + } + else + { + Log.Warn(LogTag, "Failed to set the component id to the AppControl. Err = " + err); + } + } + } + +#endregion // Public Properties /// /// Retrieves all applications that can be launched to handle the given app_control request. @@ -421,7 +522,7 @@ namespace Tizen.Applications /// Thrown when failed because of an invalid parameter. /// /// - /// IEnumerable applicationIds = AppControl.GetMatchedApplicationIds(control); + /// IEnumerable<string> applicationIds = AppControl.GetMatchedApplicationIds(control); /// if (applicationIds != null) /// { /// foreach (string id in applicationIds) @@ -431,11 +532,12 @@ namespace Tizen.Applications /// } /// /// + /// 3 public static IEnumerable GetMatchedApplicationIds(AppControl control) { if (control == null) { - throw new ArgumentNullException("control"); + throw new ArgumentNullException(nameof(control)); } List ids = new List(); @@ -465,7 +567,7 @@ namespace Tizen.Applications /// /// The operation is mandatory information for the launch request. /// If the operation is not specified, AppControlOperations.Default is used by default. - /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application. \n + /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.
/// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform. /// Also, implicit launch requests are NOT delivered to service applications since 2.4. /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent. @@ -482,18 +584,50 @@ namespace Tizen.Applications /// AppControl.SendLaunchRequest(appControl); /// /// + /// 3 public static void SendLaunchRequest(AppControl launchRequest) { SendLaunchRequest(launchRequest, null); } /// + /// Sends the launch request with setting timeout. + /// + /// + /// The operation is mandatory information for the launch request. + /// If the operation is not specified, AppControlOperations.Default is used by default. + /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.
+ /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent.
+ /// It can set receiving timeout interval using timeout parameter. + /// If there is an error that is not related to timeout, the error is returned immediately regardless of the timeout value. + ///
+ /// The AppControl. + /// The timeout in milliseconds, the timeout range is 5000 to 30000. + /// Thrown when failed because of a null argument. + /// Thrown when failed because of an invalid operation. + /// Thrown when failed because of timeout. + /// http://tizen.org/privilege/appmanager.launch + /// + /// + /// AppControl appControl = new AppControl(); + /// appControl.ApplicationId = "org.tizen.calculator"; + /// AppControl.SendLaunchRequest(appControl, 10000); + /// + /// + /// 7.5 + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SendLaunchRequest(AppControl launchRequest, uint timeout) + { + SendLaunchRequest(launchRequest, timeout, null); + } + + /// /// Sends the launch request. /// /// /// The operation is mandatory information for the launch request. /// If the operation is not specified, AppControlOperations.Default is used by default. - /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application. \n + /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.
/// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform. /// Also, implicit launch requests are NOT delivered to service applications since 2.4. /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent. @@ -517,11 +651,12 @@ namespace Tizen.Applications /// }); /// /// + /// 3 public static void SendLaunchRequest(AppControl launchRequest, AppControlReplyCallback replyAfterLaunching) { if (launchRequest == null) { - throw new ArgumentNullException("launchRequest"); + throw new ArgumentNullException(nameof(launchRequest)); } Interop.AppControl.ErrorCode err; @@ -529,26 +664,12 @@ namespace Tizen.Applications if (replyAfterLaunching != null) { int id = 0; - lock (s_replyNativeCallbackMaps) + lock (s_replyCallbackMaps) { - id = s_replyNativeCallbackId++; - s_replyNativeCallbackMaps[id] = (launchRequestHandle, replyRequestHandle, result, userData) => - { - if (replyAfterLaunching != null) - { - Log.Debug(LogTag, "Reply Callback is launched"); - replyAfterLaunching(new AppControl(launchRequestHandle), new AppControl(replyRequestHandle), (AppControlReplyResult)result); - if (result != Interop.AppControl.AppStartedStatus) - { - lock (s_replyNativeCallbackMaps) - { - s_replyNativeCallbackMaps.Remove(id); - } - } - } - }; + id = s_reaustId++; + s_replyCallbackMaps[id] = replyAfterLaunching; } - err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, s_replyNativeCallbackMaps[id], IntPtr.Zero); + err = Interop.AppControl.SendLaunchRequest(launchRequest._handle, s_replyNativeCallback, (IntPtr)id); } else { @@ -566,7 +687,89 @@ namespace Tizen.Applications case Interop.AppControl.ErrorCode.OutOfMemory: throw new Exceptions.OutOfMemoryException("Out-of-memory"); case Interop.AppControl.ErrorCode.AppNotFound: - throw new Exceptions.AppNotFoundException("App not found"); + throw new Exceptions.AppNotFoundException("App(" + launchRequest.ApplicationId + ") not found. Operation(" + launchRequest.Operation + ")"); + case Interop.AppControl.ErrorCode.LaunchRejected: + throw new Exceptions.LaunchRejectedException("Launch rejected"); + case Interop.AppControl.ErrorCode.LaunchFailed: + throw new Exceptions.LaunchFailedException("Launch failed"); + case Interop.AppControl.ErrorCode.PermissionDenied: + throw new Exceptions.PermissionDeniedException("Permission denied"); + + default: + throw new Exceptions.LaunchRejectedException("Launch rejected"); + } + } + } + + /// + /// Sends the launch request with setting timeout + /// + /// + /// The operation is mandatory information for the launch request. + /// If the operation is not specified, AppControlOperations.Default is used by default. + /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.
+ /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent.
+ /// It can set receiving timeout interval using timeout parameter. + /// If there is an error that is not related to timeout, the error is returned immediately regardless of the timeout value. + ///
+ /// The AppControl. + /// The timeout in milliseconds, the timeout range is 5000 to 30000. + /// The callback function to be called when the reply is delivered. + /// Thrown when failed because of the argument is invalid. + /// Thrown when the application to run is not found. + /// Thrown when the request failed to launch the application. + /// Thrown when the launch request is rejected. + /// Thrown when the memory is insufficient. + /// Thrown when the permission is denied. + /// Thrown when failed because of timeout. The timeout interval is set by timeout parameter. + /// http://tizen.org/privilege/appmanager.launch + /// + /// + /// AppControl appControl = new AppControl(); + /// appControl.ApplicationId = "org.tizen.calculator"; + /// AppControl.SendLaunchRequest(appControl, 10000, (launchRequest, replyRequest, result) => { + /// // ... + /// }); + /// + /// + /// 7.5 + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SendLaunchRequest(AppControl launchRequest, uint timeout, AppControlReplyCallback replyAfterLaunching) + { + if (launchRequest == null) + { + throw new ArgumentNullException(nameof(launchRequest)); + } + + Interop.AppControl.ErrorCode err; + + if (replyAfterLaunching != null) + { + int id = 0; + lock (s_replyCallbackMaps) + { + id = s_reaustId++; + s_replyCallbackMaps[id] = replyAfterLaunching; + } + err = Interop.AppControl.SendLaunchRequestWithTimeout(launchRequest._handle, timeout, s_replyNativeCallback, (IntPtr)id); + } + else + { + err = Interop.AppControl.SendLaunchRequestWithTimeout(launchRequest._handle, timeout, null, IntPtr.Zero); + } + + if (err != Interop.AppControl.ErrorCode.None) + { + switch (err) + { + case Interop.AppControl.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid Arguments"); + case Interop.AppControl.ErrorCode.TimedOut: + throw new TimeoutException("Timed out"); + case Interop.AppControl.ErrorCode.OutOfMemory: + throw new Exceptions.OutOfMemoryException("Out-of-memory"); + case Interop.AppControl.ErrorCode.AppNotFound: + throw new Exceptions.AppNotFoundException("App(" + launchRequest.ApplicationId + ") not found. Operation(" + launchRequest.Operation + ")"); case Interop.AppControl.ErrorCode.LaunchRejected: throw new Exceptions.LaunchRejectedException("Launch rejected"); case Interop.AppControl.ErrorCode.LaunchFailed: @@ -600,11 +803,12 @@ namespace Tizen.Applications /// AppControl.SendTerminateRequest(terminateRequest); /// /// + /// 3 public static void SendTerminateRequest(AppControl terminateRequest) { if (terminateRequest == null) { - throw new ArgumentNullException("terminateRequest"); + throw new ArgumentNullException(nameof(terminateRequest)); } Interop.AppControl.ErrorCode err; @@ -625,9 +829,244 @@ namespace Tizen.Applications } /// + /// Sends the launch request asynchronously. + /// + /// + /// The operation is mandatory information for the launch request. + /// If the operation is not specified, AppControlOperations.Default is used by default. + /// If the operation is AppControlOperations.Default, the application ID is mandatory to explicitly launch the application.
+ /// Since Tizen 2.4, the launch request of the service application over out of packages is restricted by the platform. + /// Also, implicit launch requests are NOT delivered to service applications since 2.4. + /// To launch a service application, an explicit launch request with the application ID given by property ApplicationId MUST be sent. + ///
+ /// The AppControl. + /// The callback function to be called when the reply is delivered. + /// A task with the result of the launch request. + /// Thrown when failed because of the argument is invalid. + /// Thrown when the application to run is not found. + /// Thrown when the launch request is rejected. + /// http://tizen.org/privilege/appmanager.launch + /// 6 + public static Task SendLaunchRequestAsync(AppControl launchRequest, AppControlReplyCallback replyAfterLaunching) + { + if (launchRequest == null) + { + throw new ArgumentNullException(nameof(launchRequest)); + } + + var task = new TaskCompletionSource(); + Interop.AppControl.ErrorCode err; + int requestId = 0; + + lock (s_resultNativeCallbackMaps) + { + requestId = s_reaustId++; + s_resultNativeCallbackMaps[requestId] = (handle, result, userData) => + { + task.SetResult((AppControlResult)result); + lock (s_resultNativeCallbackMaps) + { + s_resultNativeCallbackMaps.Remove((int)userData); + } + }; + } + + if (replyAfterLaunching != null) + { + lock (s_replyCallbackMaps) + { + s_replyCallbackMaps[requestId] = replyAfterLaunching; + } + err = Interop.AppControl.SendLaunchRequestAsync(launchRequest.SafeAppControlHandle, s_resultNativeCallbackMaps[requestId], s_replyNativeCallback, (IntPtr)requestId); + } + else + { + err = Interop.AppControl.SendLaunchRequestAsync(launchRequest.SafeAppControlHandle, s_resultNativeCallbackMaps[requestId], null, (IntPtr)requestId); + } + + if (err != Interop.AppControl.ErrorCode.None) + { + switch (err) + { + case Interop.AppControl.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid Arguments"); + case Interop.AppControl.ErrorCode.AppNotFound: + throw new Exceptions.AppNotFoundException("App(" + launchRequest.ApplicationId + ") not found. Operation(" + launchRequest.Operation + ")"); + case Interop.AppControl.ErrorCode.LaunchRejected: + throw new Exceptions.LaunchRejectedException("Launch rejected"); + case Interop.AppControl.ErrorCode.PermissionDenied: + throw new Exceptions.PermissionDeniedException("Permission denied"); + + default: + throw new Exceptions.LaunchRejectedException("Launch rejected"); + } + } + + return task.Task; + } + + /// + /// Sets the auto restart. + /// + /// + /// The functionality of this method only applies to the caller application. + /// The auto restart cannot be applied to other applications. The application ID set in the AppControl is ignored. + /// This method is only available for platform level signed applications. + /// + /// The AppControl. + /// Thrown when the argument is null. + /// Thrown when the argument is invalid. + /// Thrown when the permission is denied. + /// Thrown when the memory is insufficient. + /// Thrown when the memory is insufficient. + [EditorBrowsable(EditorBrowsableState.Never)] + public static void SetAutoRestart(AppControl appControl) + { + if (appControl == null) + { + throw new ArgumentNullException(nameof(appControl)); + } + + Interop.AppControl.ErrorCode err = Interop.AppControl.SetAutoRestart(appControl.SafeAppControlHandle); + if (err != Interop.AppControl.ErrorCode.None) + { + switch (err) + { + case Interop.AppControl.ErrorCode.InvalidParameter: + throw new ArgumentException("Invalid arguments"); + case Interop.AppControl.ErrorCode.PermissionDenied: + throw new Exceptions.PermissionDeniedException("Permission denied"); + case Interop.AppControl.ErrorCode.OutOfMemory: + throw new Exceptions.OutOfMemoryException("Out of memory"); + default: + throw new InvalidOperationException("err = " + err); + } + } + } + + /// + /// Unsets the auto restart. + /// + /// + /// The functionality of this method only applies to the caller application. + /// This method is only available for platform level signed applications. + /// + /// Thrown when the permission is denied. + /// Thrown when the memory is insufficient. + /// Thrown when the memory is insufficient. + [EditorBrowsable(EditorBrowsableState.Never)] + public static void UnsetAutoRestart() + { + Interop.AppControl.ErrorCode err = Interop.AppControl.UnsetAutoRestart(); + if (err != Interop.AppControl.ErrorCode.None) + { + switch (err) + { + case Interop.AppControl.ErrorCode.PermissionDenied: + throw new Exceptions.PermissionDeniedException("Permission denied"); + case Interop.AppControl.ErrorCode.OutOfMemory: + throw new Exceptions.OutOfMemoryException("Out of memory"); + default: + throw new InvalidOperationException("err = " + err); + } + } + } + + /// + /// Gets all default applications. + /// + /// ApplicationIds. + /// Thrown when failed because of an invalid operation. + /// + /// + /// IEnumerable<string> applicationIds = AppControl.GetDefaultApplicationIds(); + /// if (applicationIds != null) + /// { + /// foreach (string id in applicationIds) + /// { + /// // ... + /// } + /// } + /// + /// + /// 11 + [EditorBrowsable(EditorBrowsableState.Never)] + public static IEnumerable GetDefaultApplicationIds() + { + List ids = new List(); + Interop.AppControl.DefaultApplicationCallback callback = (applicationId, userData) => + { + if (applicationId == null) + { + return false; + } + + ids.Add(applicationId); + return true; + }; + + Interop.AppControl.ErrorCode err = Interop.AppControl.ForeachDefaultApplication(callback, IntPtr.Zero); + if (err != Interop.AppControl.ErrorCode.None) + { + throw new InvalidOperationException("Failed to get default application Ids. err = " + err); + } + + return ids; + } + + /// + /// Sets the window position. + /// + /// The window position object. + /// Thrown when the argument is null. + /// Thrown when the argument is invalid. + /// Thrown when the invalid operation error occurs. + /// 11 + public void SetWindowPosition(WindowPosition windowPosition) + { + if (windowPosition == null) + { + throw new ArgumentNullException(nameof(windowPosition)); + } + + Interop.AppControl.ErrorCode err = Interop.AppControl.SetWindowPosition(this.SafeAppControlHandle, windowPosition.PositionX, windowPosition.PositionY, windowPosition.Width, windowPosition.Height); + if (err != Interop.AppControl.ErrorCode.None) + { + if (err == Interop.AppControl.ErrorCode.InvalidParameter) + { + throw new ArgumentException("Invalid arguments"); + } + else + { + throw new InvalidOperationException("err = " + err); + } + } + } + + /// + /// Gets the window position. + /// + /// The window position. + /// Thrown when the invalid operation error occurs. + /// 11 + public WindowPosition GetWindowPosition() + { + Interop.AppControl.ErrorCode err = Interop.AppControl.GetWindowPosition(this.SafeAppControlHandle, out int x, out int y, out int w, out int h); + if (err != Interop.AppControl.ErrorCode.None) + { + throw new InvalidOperationException("err = " + err); + } + + return new WindowPosition(x, y, w, h); + } + + /// /// Class for extra data. /// + /// 3 +#pragma warning disable CA1034 public class ExtraDataCollection +#pragma warning restore CA1034 { private readonly SafeAppControlHandle _handle; @@ -652,15 +1091,16 @@ namespace Tizen.Applications /// appControl.ExtraData.Add("myKey", "myValue"); /// /// + /// 3 public void Add(string key, string value) { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } if (string.IsNullOrEmpty(value)) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(value)); } Interop.AppControl.ErrorCode err = Interop.AppControl.AddExtraData(_handle, key, value); if (err != Interop.AppControl.ErrorCode.None) @@ -694,15 +1134,16 @@ namespace Tizen.Applications /// appControl.ExtraData.Add("myKey", myValues); /// /// + /// 3 public void Add(string key, IEnumerable value) { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(value)); } string[] valueArray = value.ToArray(); Interop.AppControl.ErrorCode err = Interop.AppControl.AddExtraDataArray(_handle, key, valueArray, valueArray.Length); @@ -732,9 +1173,10 @@ namespace Tizen.Applications /// /// /// AppControl appControl = new AppControl(); - /// string myValue = appControl.ExtraData.Get("myKey"); + /// string myValue = appControl.ExtraData.Get<string>("myKey"); /// /// + /// 3 public T Get(string key) { object ret = Get(key); @@ -759,6 +1201,7 @@ namespace Tizen.Applications /// } /// /// + /// 3 public object Get(string key) { if (IsCollection(key)) @@ -779,7 +1222,7 @@ namespace Tizen.Applications /// /// /// AppControl appControl = new AppControl(); - /// IEnumerable keys = appControl.GetKeys(); + /// IEnumerable<string> keys = appControl.GetKeys(); /// if (keys != null) /// { /// foreach (string key in keys) @@ -789,6 +1232,7 @@ namespace Tizen.Applications /// } /// /// + /// 3 public IEnumerable GetKeys() { List keys = new List(); @@ -832,11 +1276,12 @@ namespace Tizen.Applications /// } /// /// + /// 3 public bool TryGet(string key, out string value) { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } Interop.AppControl.GetExtraData(_handle, key, out value); if (value != null) @@ -862,7 +1307,7 @@ namespace Tizen.Applications /// /// /// AppControl appControl = new AppControl(); - /// IEnumerable myValue = null; + /// IEnumerable<string> myValue = null; /// bool result = appControl.ExtraData.TryGet("myKey", out myValue); /// if (result) /// { @@ -873,11 +1318,12 @@ namespace Tizen.Applications /// } /// /// + /// 3 public bool TryGet(string key, out IEnumerable value) { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } IntPtr valuePtr = IntPtr.Zero; int len = -1; @@ -889,9 +1335,9 @@ namespace Tizen.Applications { IntPtr charArr = Marshal.ReadIntPtr(valuePtr, IntPtr.Size * i); stringList.Add(Marshal.PtrToStringAnsi(charArr)); - Interop.Libc.Free(charArr); + _ = Interop.Libc.Free(charArr); } - Interop.Libc.Free(valuePtr); + _ = Interop.Libc.Free(valuePtr); value = stringList; return true; } @@ -915,11 +1361,12 @@ namespace Tizen.Applications /// appControl.ExtraData.Remove("myKey"); /// /// + /// 3 public void Remove(string key) { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } Interop.AppControl.ErrorCode err = Interop.AppControl.RemoveExtraData(_handle, key); if (err != Interop.AppControl.ErrorCode.None) @@ -949,6 +1396,7 @@ namespace Tizen.Applications /// int numberOfKeys = appControl.ExtraData.Count(); /// /// + /// 3 public int Count() { return GetKeys().Count(); @@ -967,11 +1415,12 @@ namespace Tizen.Applications /// bool result = appControl.ExtraData.IsCollection("myKey"); /// /// + /// 3 public bool IsCollection(string key) { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } bool isArray = false; Interop.AppControl.ErrorCode err = Interop.AppControl.IsExtraDataArray(_handle, key, out isArray); @@ -986,7 +1435,7 @@ namespace Tizen.Applications { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } string value = string.Empty; Interop.AppControl.ErrorCode err = Interop.AppControl.GetExtraData(_handle, key, out value); @@ -1013,7 +1462,7 @@ namespace Tizen.Applications { if (string.IsNullOrEmpty(key)) { - throw new ArgumentNullException("key"); + throw new ArgumentNullException(nameof(key)); } IntPtr valuePtr = IntPtr.Zero; int len = -1; @@ -1042,9 +1491,9 @@ namespace Tizen.Applications { IntPtr charArr = Marshal.ReadIntPtr(valuePtr, IntPtr.Size * i); valueArray.Add(Marshal.PtrToStringAnsi(charArr)); - Interop.Libc.Free(charArr); + _ = Interop.Libc.Free(charArr); } - Interop.Libc.Free(valuePtr); + _ = Interop.Libc.Free(valuePtr); } return valueArray; }