/// <summary> /// Заполнить данные в объекте поста. /// </summary> /// <param name="post">Объект поста.</param> /// <param name="linkSerialization">Сервис сериализации ссылок.</param> /// <param name="posterName">Имя постера.</param> internal void FillPostData(PostModelStorePost post, ILinkSerializationService linkSerialization, string posterName) { if (post == null) { throw new ArgumentNullException(nameof(post)); } if (linkSerialization == null) { throw new ArgumentNullException(nameof(linkSerialization)); } if (Country?.ImageLink != null) { post.Country = new PostModelStorePost.CountryFlag() { ImageLink = linkSerialization.Deserialize(Country.ImageLink) }; } if (Icon?.ImageLink != null) { post.Icon = new PostModelStorePost.PostIcon() { ImageLink = linkSerialization.Deserialize(Icon.ImageLink), Description = Icon.Description }; } if (Poster != null || posterName != null) { post.Poster = new PostModelStorePost.PosterInfo() { Name = posterName, Tripcode = Poster?.Tripcode, NameColor = Poster?.NameColor, NameColorStr = Poster?.NameColorStr }; } post.UniqueId = UniqueId; post.Email = Email; post.Hash = Hash; }
/// <summary> /// Установить дополнительную информацию. /// </summary> /// <param name="extended">Дополнительная информация.</param> /// <param name="reference">Ссылка.</param> /// <param name="serializationService">Сервис сериализации ссылок.</param> public static void SetExtendedInfoFor(BoardExtendedInfo extended, BoardReference reference, ILinkSerializationService serializationService) { if (reference == null) { throw new ArgumentNullException(nameof(reference)); } if (serializationService == null) { throw new ArgumentNullException(nameof(serializationService)); } if (extended == null) { reference.LikesEnabled = false; reference.Icons = null; reference.PostingCapabilities = null; reference.SageEnabled = false; reference.ThreadTagsEnabled = false; reference.TripCodesEnabled = false; } else { reference.LikesEnabled = extended.LikesEnabled; reference.SageEnabled = extended.SageEnabled; reference.ThreadTagsEnabled = extended.ThreadTagsEnabled; reference.TripCodesEnabled = extended.TripCodesEnabled; reference.Icons = extended.Icons?.Select(i => new BoardIcon() { Id = i?.Id, Name = i?.Name, MediaLink = i?.MediaLink != null ? serializationService.Deserialize(i.MediaLink) : null })?.OfType <IBoardIcon>()?.ToList(); if (extended.PostingCapabilities != null) { foreach (var c in extended.PostingCapabilities.OfType <BoardPostingIconCapability>()) { c.UpdateInterface(); } } reference.PostingCapabilities = extended.PostingCapabilities?.OfType <IPostingCapability>()?.ToList(); } }