コード例 #1
0
        public async Task SaveLastVisitedPageNumber(string threadId, int pageNumber)
        {
            FlashbackCacheList <LastReadPageInfo> data;

            if (await FileHelper.FileExistsAsync(SMARTNAVIGATIONFILE))
            {
                data = await FileHelper.ReadFileAsync <FlashbackCacheList <LastReadPageInfo> >(SMARTNAVIGATIONFILE);
            }
            else
            {
                data = new FlashbackCacheList <LastReadPageInfo>();
            }

            if (data.All(x => x.ThreadId != threadId))
            {
                data.Add(new LastReadPageInfo()
                {
                    PageNr = pageNumber, ThreadId = threadId
                });
            }
            else
            {
                data.First(x => x.ThreadId == threadId).PageNr = pageNumber;
            }

            await FileHelper.WriteFileAsync(SMARTNAVIGATIONFILE, data);
        }
コード例 #2
0
        public async Task AddToCacheList(ForumList newForumlist)
        {
            FlashbackCacheList <Dictionary <string, ForumList> > fbCache;

            var dataToAdd = new Dictionary <string, ForumList> {
                {
                    newForumlist.Id, newForumlist
                }
            };

            if (!await FileHelper.FileExistsAsync(CACHEFILE))
            {
                fbCache = new FlashbackCacheList <Dictionary <string, ForumList> >();
            }
            else
            {
                fbCache = await FileHelper.ReadFileAsync <FlashbackCacheList <Dictionary <string, ForumList> > >(CACHEFILE);
            }

            fbCache.Add(dataToAdd);

            await FileHelper.WriteFileAsync(CACHEFILE, fbCache);
        }