From: Kichan Kwon Date: Fri, 25 Aug 2017 05:47:49 +0000 (+0900) Subject: [Information] Rename RuntimeInformation.GetStatus to TryGetValue X-Git-Tag: preview1-00199~3^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c75d2641f76f795273b07693fd4d6312a8006b76;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Information] Rename RuntimeInformation.GetStatus to TryGetValue - Cornerstone for integrating the get function of runtime-info and system-info Change-Id: I876ebf171ff3b93c181e02a54095cde8c381ec05 Signed-off-by: Kichan Kwon --- diff --git a/src/Tizen.System.Information/RuntimeInfo/RuntimeInformation.cs b/src/Tizen.System.Information/RuntimeInfo/RuntimeInformation.cs index 12601cff3..c4ef6c635 100755 --- a/src/Tizen.System.Information/RuntimeInfo/RuntimeInformation.cs +++ b/src/Tizen.System.Information/RuntimeInfo/RuntimeInformation.cs @@ -63,41 +63,6 @@ namespace Tizen.System [RuntimeInformationKey.AudioJackConnector] = typeof(int) }; - [EditorBrowsable(EditorBrowsableState.Never)] - internal static object GetStatus(RuntimeInformationKey key) - { - Type value; - if (!s_keyDataTypeMapping.TryGetValue(key, out value)) - { - InformationErrorFactory.ThrowException(InformationError.InvalidParameter); - } - - if (s_keyDataTypeMapping[key] == typeof(int)) - { - int status; - InformationError ret = Interop.RuntimeInfo.GetValue(TvProductHelper.ConvertKeyIfTvProduct(key), out status); - if (ret != InformationError.None) - { - Log.Error(InformationErrorFactory.LogTag, "Interop failed to get value for key {0}", key.ToString()); - InformationErrorFactory.ThrowException(ret); - } - - return status; - } - else - { - bool status; - InformationError ret = Interop.RuntimeInfo.GetValue(TvProductHelper.ConvertKeyIfTvProduct(key), out status); - if (ret != InformationError.None) - { - Log.Error(InformationErrorFactory.LogTag, "Interop failed to get value for key {0}", key.ToString()); - InformationErrorFactory.ThrowException(ret); - } - - return status; - } - } - /// /// Validates the data type of the status represented by the runtime key. /// Note that this is a generic method. @@ -122,16 +87,48 @@ namespace Tizen.System /// Gets the status of runtime key. /// Note that this is a generic method. /// - /// 3 + /// 4 /// The generic type to return. /// The runtime information key for which the current should be read. - /// The current status of the given key.. - /// Thrown when the is invalid. - /// Thrown when I/O error occurs while reading from the system. - /// Thrown when the feature related is not supported. - public static T GetStatus(RuntimeInformationKey key) + /// The value of the given feature. + /// Returns true on success, otherwise false. + public static bool TryGetValue(RuntimeInformationKey key, out T value) { - return (T)GetStatus(key); + Type type; + value = default(T); + + if (!s_keyDataTypeMapping.TryGetValue(key, out type)) + { + Log.Error(InformationErrorFactory.LogTag, "Invalid key"); + return false; + } + + if (type == typeof(bool)) + { + InformationError ret = Interop.RuntimeInfo.GetValue(TvProductHelper.ConvertKeyIfTvProduct(key), out bool val); + + if (ret != InformationError.None) + { + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get value for key {0}", key.ToString()); + return false; + } + + value = (T)(object)val; + } + else if(type == typeof(int)) + { + InformationError ret = Interop.RuntimeInfo.GetValue(TvProductHelper.ConvertKeyIfTvProduct(key), out int val); + + if (ret != InformationError.None) + { + Log.Error(InformationErrorFactory.LogTag, "Interop failed to get value for key {0}", key.ToString()); + return false; + } + + value = (T)(object)val; + } + + return true; } [EditorBrowsable(EditorBrowsableState.Never)] @@ -210,7 +207,7 @@ namespace Tizen.System } /// - /// Unegisters a change event callback for given key. + /// Unregisters a change event callback for given key. /// /// 4 /// The runtime information key which wants to unregister callback.