/// <summary>
 /// Парсить данные каталога.
 /// </summary>
 /// <param name="data">Данные.</param>
 /// <param name="link">Ссылка.</param>
 /// <returns>Результат.</returns>
 public CatalogTree ParseCatalogTree(CatalogEntity data, BoardLinkBase link)
 {
     var result = new CatalogTree()
     {
         Link = link,
         Posts = (data.Threads ?? new BoardPost2[0]).Select(p => Parse(p, new ThreadLink()
         {
             Engine = CoreConstants.Engine.Makaba,
             Board = data.Board,
             Thread = p.Number.TryParseWithDefault()
         }, true)).ToList(),
         Extensions = new List<PostTreeCollectionExtension>(),
         ParentLink = new BoardLink()
         {
             Engine = CoreConstants.Engine.Makaba,
             Board = data.Board
         }
     };
     for (int i = 0; i < result.Posts.Count; i++)
     {
         result.Posts[i].Counter = i + 1;
         result.Posts[i].Flags |= PostFlags.ThreadPreview;
         result.Posts[i].Flags |= PostFlags.ThreadPreviewOpPost;
     }
     return result;
 }
예제 #2
0
 /// <summary>
 /// Сохранить каталог.
 /// </summary>
 /// <param name="data">Данные.</param>
 /// <returns>Каталог.</returns>
 public async Task SaveCatalog(CatalogTree data)
 {
     var fileName = string.Format(CacheConsts.CacheFileTemplates[CacheConsts.Catalog], Services.GetServiceOrThrow<ILinkHashService>().GetLinkHash(data.Link));
     var file = await GetCacheFile(fileName);
     var folder = await GetCacheFolder();
     await WriteCacheXmlObject(file, folder, data, true);
 }