internal void BeforeSerialize(IModuleProvider moduleProvider) { var linkSerialization = moduleProvider.QueryModule <ILinkSerializationService>() ?? throw new ModuleNotFoundException(typeof(ILinkSerializationService)); Contracts = new MakabaEntittyInfoModelContracts() { BoardInfo = moduleProvider.ValidateBeforeSerialize <IPostDocument, PostDocument, PostDocumentExternalContract>(BoardInfo), HasBannerSize = BannerSize != null, BannerWidth = BannerSize != null ? BannerSize.Value.Width : 0, BannerHeight = BannerSize != null ? BannerSize.Value.Height : 0, BannerImageLink = linkSerialization.Serialize(BannerImageLink), BannerBoardLink = linkSerialization.Serialize(BannerBoardLink), Icons = Icons?.Select(i => i != null ? new BoardIconContract() { Id = i.Id, Name = i.Name, MediaLink = linkSerialization.Serialize(i.MediaLink) } : null)?.ToList(), Pages = Pages?.ToList(), NewsItems = NewsItems?.Select(i => i != null ? new MakabaBoardPostCollectionInfoNewsItemContract() { Date = i.Date, NewsLink = linkSerialization.Serialize(i.NewsLink), Title = i.Title } : null)?.ToList(), AdvertisementItems = AdvertisementItems?.Select(i => i != null ? new MakabaBoardPostCollectionInfoBoardsAdvertisementItemContract() { Info = i.Info, Name = i.Name, BoardLink = linkSerialization.Serialize(i.BoardLink) } : null)?.ToList(), AdvertisementBannerLink = linkSerialization.Serialize(AdvertisementBannerLink), AdvertisementClickLink = linkSerialization.Serialize(AdvertisementClickLink), Flags = Flags?.ToList() }; }