Пример #1
0
        /// <summary>
        /// Gets the label information detail of the account provider.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns> All the labels information for the given account provider.</returns>
        /// <privilege>http://tizen.org/privilege/account.read</privilege>
        /// <feature>http://tizen.org/feature/account</feature>
        /// <exception cref="InvalidOperationException">In case of any DB error.</exception>
        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        public Dictionary <string, string> GetLabels()
        {
            Dictionary <string, string> labels = new Dictionary <string, string>();

            Interop.AccountProvider.LabelCallback callback = (string applicationId, string label, string locale, IntPtr userData) =>
            {
                labels.Add(locale, label);
                return(true);
            };

            AccountError err = (AccountError)Interop.AccountProvider.GetAccountProviderLabels(Handle, callback, IntPtr.Zero);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to GetAccountProviderLabels");
            }

            return(labels);
        }
Пример #2
0
        /// <summary>
        /// Gets the specific label information detail of the account provider.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="appId">
        /// The application ID to search.
        /// </param>
        /// <returns> All the labels information for the given application ID.</returns>
        /// <privilege>http://tizen.org/privilege/account.read</privilege>
        /// <feature>http://tizen.org/feature/account</feature>
        /// <exception cref="InvalidOperationException">In case of any DB error or record not found for given the application ID.</exception>
        /// <exception cref="ArgumentException"> In case of an invalid parameter.</exception>
        /// <exception cref="UnauthorizedAccessException"> In case of privilege not defined.</exception>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        public static Dictionary <string, string> GetLabelsByAppId(string appId)
        {
            AccountErrorFactory.CheckAccountFeature();

            Dictionary <string, string> labels = new Dictionary <string, string>();

            Interop.AccountProvider.LabelCallback callback = (string applicationId, string label, string locale, IntPtr userData) =>
            {
                labels.Add(locale, label);
                return(true);
            };

            AccountError err = (AccountError)Interop.AccountProvider.GetLablesByAppId(callback, appId, IntPtr.Zero);

            if (err != AccountError.None)
            {
                throw AccountErrorFactory.CreateException(err, "Failed to GetLablesByAppId");
            }

            return(labels);
        }