internal ChallengePreview(ICtfChallenge challenge, TimeSpan elapsed, EnumDisplayConverter enumCv, int?score, bool?solved) { this.Id = challenge.Id; this.Title = challenge.Title; this.CategoryId = challenge.Category.Id; this.Difficulty = enumCv.Convert(challenge.Difficulty); this.Description = challenge.Description; if (challenge.Hints != null) { this.Hints = challenge.Hints .Where(x => x.ReleaseTime <= elapsed) .Select(x => x.Contents) .ToList(); } if (challenge.Attachments != null) { this.Attachments = challenge.Attachments .Select(x => new ChallengeAttachmentPreview(x)) .ToList(); } if (challenge.Endpoint != null) { this.Endpoint = EndpointToString(challenge.Endpoint); } this.Score = score ?? challenge.BaseScore; this.IsSolved = solved; }
internal ChallengeCategoryPreview( ICtfChallengeCategory category, TimeSpan elapsed, EnumDisplayConverter enumCv, IReadOnlyDictionary <string, int> scores, HashSet <string> solveIds) { this.Id = category.Id; this.Name = category.Name; this.Challenges = category.Challenges .Select(x => scores != null && scores.TryGetValue(x.Id, out var score) ? new ChallengePreview(x, elapsed, enumCv, score, solveIds?.Contains(x.Id)) : new ChallengePreview(x, elapsed, enumCv, null, solveIds?.Contains(x.Id))) .ToList(); }
internal ChallengeCategoryPreview(ICtfChallengeCategory category, TimeSpan elapsed, EnumDisplayConverter enumCv, IReadOnlyDictionary <string, int> scores) : this(category, elapsed, enumCv, scores, null) { }
internal ChallengeCategoryPreview(ICtfChallengeCategory category, TimeSpan elapsed, EnumDisplayConverter enumCv) : this(category, elapsed, enumCv, null) { }
internal ChallengePreview(ICtfChallenge challenge, TimeSpan elapsed, EnumDisplayConverter enumCv) : this(challenge, elapsed, enumCv, null) { }
/// <summary> /// Creates a new repository. /// </summary> /// <param name="enumCv">Enum display value converter to use for converting display values.</param> public ChallengePreviewRepository(EnumDisplayConverter enumCv) { this.EnumDisplayConverter = enumCv; }