private IEnumerable <CnmtContainer> BuildCnmtContainers(PartitionFileSystemItemBase partitionItem) { // Find all Cnmt (kind of manifest containing contents information such a base title, a patch, etc.) var cnmtItems = partitionItem.FindAllCnmtItems().ToArray(); if (cnmtItems.Length <= 0) { var message = LocalizationManager.Instance.Current.Keys.LoadingError_NoCnmtFound; partitionItem.Errors.Add(message); _logger.LogError(message); } foreach (var cnmtItem in cnmtItems) { var cnmtContainer = new CnmtContainer(cnmtItem); foreach (var cnmtContentEntry in cnmtItem.Cnmt.ContentEntries) { var ncaId = cnmtContentEntry.NcaId.ToStrId(); var parentPartitionFileSystemItem = cnmtItem.ContainerSectionItem.ParentItem.ParentItem; var ncaItem = parentPartitionFileSystemItem.FindNcaItem(ncaId); if (ncaItem == null) { if (cnmtContentEntry.Type == ContentType.DeltaFragment) { _logger.LogWarning(LocalizationManager.Instance.Current.Keys.LoadingError_NcaFileMissing.SafeFormat(ncaId, cnmtContentEntry.Type)); } else { var message = LocalizationManager.Instance.Current.Keys.LoadingError_NcaFileMissing.SafeFormat(ncaId, cnmtContentEntry.Type); parentPartitionFileSystemItem.Errors.Add(message); _logger.LogError(message); } continue; } if (cnmtContentEntry.Type == ContentType.Control) { var nacpItem = ncaItem.FindNacpItem(); if (nacpItem == null) { var message = LocalizationManager.Instance.Current.Keys.LoadingError_NacpFileMissing.SafeFormat(NacpItem.NacpFileName); ncaItem.Errors.Add(message); _logger.LogError(message); } else { cnmtContainer.NacpContainer = LoadContentDetails(nacpItem); } } } yield return(cnmtContainer); } }
public CnmtContainerViewModel(CnmtContainer cnmtContainer, int containerNumber, IServiceProvider serviceProvider) { _containerNumber = containerNumber; _cnmtContainer = cnmtContainer ?? throw new ArgumentNullException(nameof(cnmtContainer)); ServiceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); SaveSelectedImageCommand = serviceProvider.GetRequiredService <ISaveTitleImageCommand>(); CopySelectedImageCommand = serviceProvider.GetRequiredService <ICopyImageCommand>(); var nacpContainer = _cnmtContainer.NacpContainer; if (nacpContainer != null) { var titleInfoViewModels = nacpContainer.Titles.Select(titleInfo => new TitleInfoViewModel(titleInfo, serviceProvider)); foreach (var titleInfoViewModel in titleInfoViewModels) { Titles.Add(titleInfoViewModel); } } SelectedTitle = Titles?.FirstOrDefault(); }