コード例 #1
0
ファイル: TvCore.cs プロジェクト: ldj-droid/FoxIPTV
        /// <summary>Load the favorite data from the user storage location</summary>
        private static void FavoritesLoad()
        {
            var favoriteChannelsFilePath = Path.Combine(UserStoragePath, ChannelFavoritesFilename);

            if (!File.Exists(favoriteChannelsFilePath))
            {
                return;
            }

            LogInfo($"[TVCore] FavoritesLoad(): Loading channelIndex favorites file: {favoriteChannelsFilePath}");

            var rawJson = File.ReadAllText(favoriteChannelsFilePath);

            if (string.IsNullOrWhiteSpace(rawJson))
            {
                return;
            }

            ChannelFavorites.Clear();

            try
            {
                ChannelFavorites.AddRange(JsonConvert.DeserializeObject <List <string> >(rawJson));
            }
            catch (Exception e)
            {
                LogError($"[TVCore] FavoritesLoad(): Error parsing channelIndex favorites file... {e.Message}");
                return;
            }

            LogDebug($"[TVCore] FavoritesLoad(): Loaded {ChannelFavorites.Count} channelIndex favorites");
        }