/// <summary>
        /// Load the saved favorites from a file in isolated storage.
        /// Perform culture conversion if needed
        /// </summary>
        /// <returns>Deserialized object</returns>
        internal static FavoriteCollection LoadFromFile()
        {
            IsolatedStorage <FavoriteCollection> f = new IsolatedStorage <FavoriteCollection>();
            FavoriteCollection loadedFile          = f.LoadFromFile(FavoriteData.FavoriteFileName);

            if (loadedFile == null)
            {
                loadedFile = new FavoriteCollection();
            }

            /* In the case where the favorites were stored in one language, but we have
             * switched to another language, check to see if the first item category matches
             * the current locale. If it does, then break out. Othewise, convert all of the
             * unit information into the current locale
             */
            foreach (FavoriteData d in loadedFile)
            {
                if (string.Compare(d.Category,
                                   Resources.Strings.ResourceManager.GetString(d.CategoryResource),
                                   StringComparison.OrdinalIgnoreCase) == 0)
                {
                    break;
                }
                d.Category       = Resources.Strings.ResourceManager.GetString(d.CategoryResource);
                d.SourceUnitName = Resources.Strings.ResourceManager.GetString(d.SourceUnitNameResource);
                d.TargetUnitName = Resources.Strings.ResourceManager.GetString(d.TargetUnitNameResource);
                d.LabelName      = string.Format(CultureInfo.CurrentCulture,
                                                 UnitConverter.Resources.Strings.FavoriteItemLabel,
                                                 d.SourceUnitName, d.TargetUnitName);
            }
            return(loadedFile);
        }
        /// <summary>
        /// Saves file on a thread pool thread
        /// </summary>
        /// <param name="data">Data to save</param>
        /// <param name="completed">Delegate to call on completed</param>
        /// <param name="handleException">Exception handler delegate</param>
        internal static void BeginSaveToFile(
            FavoriteCollection data,
            Action completed,
            Action <Exception> handleException)
        {
            IsolatedStorage <FavoriteCollection> f = new IsolatedStorage <FavoriteCollection>();

            f.BeginSave(FavoriteData.FavoriteFileName, data, completed, handleException);
        }
        /// <summary>
        /// Save object to a file
        /// </summary>
        /// <param name="data">Object to save</param>
        internal static void SaveToFile(FavoriteCollection data)
        {
            IsolatedStorage <FavoriteCollection> f = new IsolatedStorage <FavoriteCollection>();

            f.SaveToFile(FavoriteData.FavoriteFileName, data);
        }