1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Diagnostics . CodeAnalysis ;
4+ using System . IO . Abstractions ;
5+ using System . Linq ;
6+ using AET . Modinfo . File ;
7+
8+ namespace AET . Modinfo . Spec ;
9+
10+ /// <summary>
11+ /// Represents the result when a modinfo file query was performed.
12+ /// </summary>
13+ public sealed class ModinfoFinderCollection
14+ {
15+ /// <summary>
16+ /// Returns <see langword="true"/> if this collection does contain a main modinfo file; <see langword="false"/> otherwise.
17+ /// </summary>
18+ [ MemberNotNullWhen ( true , nameof ( MainModinfo ) ) ]
19+ public bool HasMainModinfoFile => MainModinfo != null ;
20+
21+ /// <summary>
22+ /// Returns <see langword="true"/> if this collection does contain a variant modinfo files; <see langword="false"/> otherwise.
23+ /// </summary>
24+ public bool HasVariantModinfoFiles => Variants . Any ( ) ;
25+
26+ /// <summary>
27+ /// Gets the main modinfo file or <see langword="null"/> if no main modinfo file was found.
28+ /// </summary>
29+ public MainModinfoFile ? MainModinfo { get ; }
30+
31+ /// <summary>
32+ /// Gets a collection of found variant modinfo file.
33+ /// </summary>
34+ public IReadOnlyCollection < ModinfoVariantFile > Variants { get ; }
35+
36+ /// <summary>
37+ /// Gets the directory where the files were searched.
38+ /// </summary>
39+ public IDirectoryInfo Directory { get ; }
40+
41+ /// <summary>
42+ /// Initializes a new instance of the <see cref="ModinfoFinderCollection"/> of the specified directory and found modinfo files.
43+ /// </summary>
44+ /// <param name="directory">The directory that was searched.</param>
45+ /// <param name="mainModinfo">The found main modinfo file or <see langword="null"/>.</param>
46+ /// <param name="variants">A collection of variant modinfo files.</param>
47+ /// <exception cref="ArgumentNullException"><paramref name="directory"/> or <paramref name="variants"/> is <see langword="null"/>.</exception>
48+ public ModinfoFinderCollection ( IDirectoryInfo directory , MainModinfoFile ? mainModinfo , IEnumerable < ModinfoVariantFile > variants )
49+ {
50+ if ( variants == null )
51+ throw new ArgumentNullException ( nameof ( variants ) ) ;
52+ Directory = directory ?? throw new ArgumentNullException ( nameof ( directory ) ) ;
53+ MainModinfo = mainModinfo ;
54+ Variants = variants . ToList ( ) ;
55+ }
56+ }
0 commit comments