private void ProcessNsoSet(List <IFile> list)
        {
            if (list.Count == 0)
            {
                return;
            }

            var nsos = new List <(Nso nso, IFile file)>();

            foreach (IFile file in list)
            {
                var nso = new Nso(file.AsStorage());
                nsos.Add((nso, file));
            }

            var nsoInfos = new List <NsoInfo>();

            foreach ((Nso nso, IFile file)nso in nsos)
            {
                try
                {
                    nsoInfos.Add(GetNsoInfo(nso));
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error processing {nso.nso.BuildId.ToHexString()}");
                    Console.WriteLine(ex);
                }
            }

            var set = new NsoSet();

            set.Nsos.AddRange(nsoInfos);
            NsoSets.Add(set);

            Version maxVersion = set.Nsos.Where(x => x.Version != null).Select(x => x.Version).Max();

            if (maxVersion != null)
            {
                NsoInfo maxInfo = set.Nsos.First(x => x.Version == maxVersion);

                set.Version       = maxVersion;
                set.MaxVersionNso = maxInfo;
            }

            foreach (NsoInfo info in nsoInfos)
            {
                info.Sets.Add(set);
            }
        }
        private void ProcessNso(string nsoPath)
        {
            FsClient.OpenFile(out FileHandle nsoHandle, nsoPath, OpenMode.Read).ThrowIfFailure();

            using (nsoHandle)
                using (var nsoStorage = new FileHandleStorage(nsoHandle, true))
                    using (var nsoFile = new StorageFile(nsoStorage, OpenMode.Read))
                    {
                        var     nso  = new Nso(nsoStorage);
                        NsoInfo info = GetNsoInfo((nso, nsoFile));

                        ParseNsoName(nsoPath, info);
                    }
        }
        // Import version data from the filename if needed
        private void ParseNsoName(string fileName, NsoInfo info)
        {
            if (Path.GetExtension(fileName) != ".nso")
            {
                return;
            }

            string[] splitName = Path.GetFileNameWithoutExtension(fileName).Split('-');
            if (splitName.Length != 4)
            {
                return;
            }

            string name          = splitName[0];
            string versionString = splitName[1];
            string buildType     = splitName[2];
            string id            = splitName[3];

            if (name != info.Name || id != info.ShortBuildId)
            {
                return;
            }

            string[] versionSplit = versionString.Split('_');
            if (versionSplit.Length != 3)
            {
                throw new InvalidDataException($"Unknown version string format {versionString}");
            }

            var version = new Version(int.Parse(versionSplit[0]), int.Parse(versionSplit[1]), int.Parse(versionSplit[2]));

            if (info.Version != null && info.Version <= version)
            {
                return;
            }

            info.VersionString = versionString;
            info.BuildType     = buildType;
            info.Version       = version;
        }