mirror of
https://github.com/SabreTools/SabreTools.Serialization.git
synced 2026-07-08 18:06:41 +00:00
Use newer "is not null" syntax
This commit is contained in:
@@ -142,7 +142,7 @@ namespace InfoPrint.Features
|
||||
if (Hash)
|
||||
{
|
||||
var hashBuilder = PrintHashInfo(file);
|
||||
if (hashBuilder != null)
|
||||
if (hashBuilder is not null)
|
||||
{
|
||||
// Create the output data
|
||||
string hashData = hashBuilder.ToString();
|
||||
@@ -243,29 +243,29 @@ namespace InfoPrint.Features
|
||||
|
||||
// Output subset of available hashes
|
||||
var builder = new StringBuilder();
|
||||
if (hashes.TryGetValue(HashType.CRC16, out string? crc16) && crc16 != null)
|
||||
if (hashes.TryGetValue(HashType.CRC16, out string? crc16) && crc16 is not null)
|
||||
builder.AppendLine($"CRC-16 checksum: {crc16}");
|
||||
if (hashes.TryGetValue(HashType.CRC32, out string? crc32) && crc32 != null)
|
||||
if (hashes.TryGetValue(HashType.CRC32, out string? crc32) && crc32 is not null)
|
||||
builder.AppendLine($"CRC-32 checksum: {crc32}");
|
||||
if (hashes.TryGetValue(HashType.CRC64, out string? crc64) && crc64 != null)
|
||||
if (hashes.TryGetValue(HashType.CRC64, out string? crc64) && crc64 is not null)
|
||||
builder.AppendLine($"CRC-64 checksum: {crc64}");
|
||||
if (hashes.TryGetValue(HashType.MD2, out string? md2) && md2 != null)
|
||||
if (hashes.TryGetValue(HashType.MD2, out string? md2) && md2 is not null)
|
||||
builder.AppendLine($"MD2 hash: {md2}");
|
||||
if (hashes.TryGetValue(HashType.MD4, out string? md4) && md4 != null)
|
||||
if (hashes.TryGetValue(HashType.MD4, out string? md4) && md4 is not null)
|
||||
builder.AppendLine($"MD4 hash: {md4}");
|
||||
if (hashes.TryGetValue(HashType.MD5, out string? md5) && md5 != null)
|
||||
if (hashes.TryGetValue(HashType.MD5, out string? md5) && md5 is not null)
|
||||
builder.AppendLine($"MD5 hash: {md5}");
|
||||
if (hashes.TryGetValue(HashType.RIPEMD128, out string? ripemd128) && ripemd128 != null)
|
||||
if (hashes.TryGetValue(HashType.RIPEMD128, out string? ripemd128) && ripemd128 is not null)
|
||||
builder.AppendLine($"RIPEMD-128 hash: {ripemd128}");
|
||||
if (hashes.TryGetValue(HashType.RIPEMD160, out string? ripemd160) && ripemd160 != null)
|
||||
if (hashes.TryGetValue(HashType.RIPEMD160, out string? ripemd160) && ripemd160 is not null)
|
||||
builder.AppendLine($"RIPEMD-160 hash: {ripemd160}");
|
||||
if (hashes.TryGetValue(HashType.SHA1, out string? sha1) && sha1 != null)
|
||||
if (hashes.TryGetValue(HashType.SHA1, out string? sha1) && sha1 is not null)
|
||||
builder.AppendLine($"SHA-1 hash: {sha1}");
|
||||
if (hashes.TryGetValue(HashType.SHA256, out string? sha256) && sha256 != null)
|
||||
if (hashes.TryGetValue(HashType.SHA256, out string? sha256) && sha256 is not null)
|
||||
builder.AppendLine($"SHA-256 hash: {sha256}");
|
||||
if (hashes.TryGetValue(HashType.SHA384, out string? sha384) && sha384 != null)
|
||||
if (hashes.TryGetValue(HashType.SHA384, out string? sha384) && sha384 is not null)
|
||||
builder.AppendLine($"SHA-384 hash: {sha384}");
|
||||
if (hashes.TryGetValue(HashType.SHA512, out string? sha512) && sha512 != null)
|
||||
if (hashes.TryGetValue(HashType.SHA512, out string? sha512) && sha512 is not null)
|
||||
builder.AppendLine($"SHA-512 hash: {sha512}");
|
||||
|
||||
return builder;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(),
|
||||
};
|
||||
|
||||
if (item?.File != null && item.File.Length > 0)
|
||||
if (item?.File is not null && item.File.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(item.File, ConvertMachineToInternalModel);
|
||||
@@ -45,7 +45,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var machine = new Data.Models.Metadata.Machine();
|
||||
|
||||
var rom = ConvertToInternalModel(item);
|
||||
if (rom != null)
|
||||
if (rom is not null)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = new Data.Models.Metadata.Rom[] { rom };
|
||||
|
||||
return machine;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var metadataFile = header != null ? ConvertHeaderFromInternalModel(header) : new MetadataFile();
|
||||
var metadataFile = header is not null ? ConvertHeaderFromInternalModel(header) : new MetadataFile();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
var items = new List<Row>();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj),
|
||||
};
|
||||
|
||||
if (obj?.Row != null && obj.Row.Length > 0)
|
||||
if (obj?.Row is not null && obj.Row.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(obj.Row, ConvertMachineToInternalModel);
|
||||
|
||||
@@ -18,18 +18,18 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var metadataFile = new MetadataFile();
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
metadataFile.ClrMamePro = ConvertHeaderFromInternalModel(header);
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
{
|
||||
metadataFile.Game
|
||||
= Array.ConvertAll(machines, m => ConvertMachineFromInternalModel(m, game));
|
||||
}
|
||||
|
||||
var info = obj.Read<Data.Models.Metadata.InfoSource>(Data.Models.Metadata.MetadataFile.InfoSourceKey);
|
||||
if (info != null)
|
||||
if (info is not null)
|
||||
metadataFile.Info = ConvertInfoSourceFromInternalModel(info);
|
||||
|
||||
return metadataFile;
|
||||
@@ -78,55 +78,55 @@ namespace SabreTools.Serialization.CrossModel
|
||||
gameBase.SampleOf = item.ReadString(Data.Models.Metadata.Machine.SampleOfKey);
|
||||
|
||||
var releases = item.Read<Data.Models.Metadata.Release[]>(Data.Models.Metadata.Machine.ReleaseKey);
|
||||
if (releases != null && releases.Length > 0)
|
||||
if (releases is not null && releases.Length > 0)
|
||||
gameBase.Release = Array.ConvertAll(releases, ConvertFromInternalModel);
|
||||
|
||||
var biosSets = item.Read<Data.Models.Metadata.BiosSet[]>(Data.Models.Metadata.Machine.BiosSetKey);
|
||||
if (biosSets != null && biosSets.Length > 0)
|
||||
if (biosSets is not null && biosSets.Length > 0)
|
||||
gameBase.BiosSet = Array.ConvertAll(biosSets, ConvertFromInternalModel);
|
||||
|
||||
var roms = item.Read<Data.Models.Metadata.Rom[]>(Data.Models.Metadata.Machine.RomKey);
|
||||
if (roms != null && roms.Length > 0)
|
||||
if (roms is not null && roms.Length > 0)
|
||||
gameBase.Rom = Array.ConvertAll(roms, ConvertFromInternalModel);
|
||||
|
||||
var disks = item.Read<Data.Models.Metadata.Disk[]>(Data.Models.Metadata.Machine.DiskKey);
|
||||
if (disks != null && disks.Length > 0)
|
||||
if (disks is not null && disks.Length > 0)
|
||||
gameBase.Disk = Array.ConvertAll(disks, ConvertFromInternalModel);
|
||||
|
||||
var medias = item.Read<Data.Models.Metadata.Media[]>(Data.Models.Metadata.Machine.MediaKey);
|
||||
if (medias != null && medias.Length > 0)
|
||||
if (medias is not null && medias.Length > 0)
|
||||
gameBase.Media = Array.ConvertAll(medias, ConvertFromInternalModel);
|
||||
|
||||
var samples = item.Read<Data.Models.Metadata.Sample[]>(Data.Models.Metadata.Machine.SampleKey);
|
||||
if (samples != null && samples.Length > 0)
|
||||
if (samples is not null && samples.Length > 0)
|
||||
gameBase.Sample = Array.ConvertAll(samples, ConvertFromInternalModel);
|
||||
|
||||
var archives = item.Read<Data.Models.Metadata.Archive[]>(Data.Models.Metadata.Machine.ArchiveKey);
|
||||
if (archives != null && archives.Length > 0)
|
||||
if (archives is not null && archives.Length > 0)
|
||||
gameBase.Archive = Array.ConvertAll(archives, ConvertFromInternalModel);
|
||||
|
||||
var chips = item.Read<Data.Models.Metadata.Chip[]>(Data.Models.Metadata.Machine.ChipKey);
|
||||
if (chips != null && chips.Length > 0)
|
||||
if (chips is not null && chips.Length > 0)
|
||||
gameBase.Chip = Array.ConvertAll(chips, ConvertFromInternalModel);
|
||||
|
||||
var videos = item.Read<Data.Models.Metadata.Video[]>(Data.Models.Metadata.Machine.VideoKey);
|
||||
if (videos != null && videos.Length > 0)
|
||||
if (videos is not null && videos.Length > 0)
|
||||
gameBase.Video = Array.ConvertAll(videos, ConvertFromInternalModel);
|
||||
|
||||
var sound = item.Read<Data.Models.Metadata.Sound>(Data.Models.Metadata.Machine.SoundKey);
|
||||
if (sound != null)
|
||||
if (sound is not null)
|
||||
gameBase.Sound = ConvertFromInternalModel(sound);
|
||||
|
||||
var input = item.Read<Data.Models.Metadata.Input>(Data.Models.Metadata.Machine.InputKey);
|
||||
if (input != null)
|
||||
if (input is not null)
|
||||
gameBase.Input = ConvertFromInternalModel(input);
|
||||
|
||||
var dipSwitches = item.Read<Data.Models.Metadata.DipSwitch[]>(Data.Models.Metadata.Machine.DipSwitchKey);
|
||||
if (dipSwitches != null && dipSwitches.Length > 0)
|
||||
if (dipSwitches is not null && dipSwitches.Length > 0)
|
||||
gameBase.DipSwitch = Array.ConvertAll(dipSwitches, ConvertFromInternalModel);
|
||||
|
||||
var driver = item.Read<Data.Models.Metadata.Driver>(Data.Models.Metadata.Machine.DriverKey);
|
||||
if (driver != null)
|
||||
if (driver is not null)
|
||||
gameBase.Driver = ConvertFromInternalModel(driver);
|
||||
|
||||
return gameBase;
|
||||
@@ -357,7 +357,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var info = new Info();
|
||||
|
||||
var sources = item.Read<string[]>(Data.Models.Metadata.InfoSource.SourceKey);
|
||||
if (sources != null && sources.Length > 0)
|
||||
if (sources is not null && sources.Length > 0)
|
||||
info.Source = [.. sources];
|
||||
|
||||
return info;
|
||||
|
||||
@@ -13,16 +13,16 @@ namespace SabreTools.Serialization.CrossModel
|
||||
|
||||
var metadataFile = new Data.Models.Metadata.MetadataFile();
|
||||
|
||||
if (obj?.ClrMamePro != null)
|
||||
if (obj?.ClrMamePro is not null)
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj.ClrMamePro);
|
||||
|
||||
if (obj?.Game != null && obj.Game.Length > 0)
|
||||
if (obj?.Game is not null && obj.Game.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(obj.Game, ConvertMachineToInternalModel);
|
||||
}
|
||||
|
||||
if (obj?.Info != null)
|
||||
if (obj?.Info is not null)
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.InfoSourceKey] = ConvertInfoSourceToInternalModel(obj.Info);
|
||||
|
||||
return metadataFile;
|
||||
@@ -74,73 +74,73 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Machine.SampleOfKey] = item.SampleOf,
|
||||
};
|
||||
|
||||
if (item.Release != null && item.Release.Length > 0)
|
||||
if (item.Release is not null && item.Release.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.ReleaseKey]
|
||||
= Array.ConvertAll(item.Release, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.BiosSet != null && item.BiosSet.Length > 0)
|
||||
if (item.BiosSet is not null && item.BiosSet.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.BiosSetKey]
|
||||
= Array.ConvertAll(item.BiosSet, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Rom != null && item.Rom.Length > 0)
|
||||
if (item.Rom is not null && item.Rom.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.RomKey]
|
||||
= Array.ConvertAll(item.Rom, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Disk != null && item.Disk.Length > 0)
|
||||
if (item.Disk is not null && item.Disk.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.DiskKey]
|
||||
= Array.ConvertAll(item.Disk, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Media != null && item.Media.Length > 0)
|
||||
if (item.Media is not null && item.Media.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.MediaKey]
|
||||
= Array.ConvertAll(item.Media, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Sample != null && item.Sample.Length > 0)
|
||||
if (item.Sample is not null && item.Sample.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.SampleKey]
|
||||
= Array.ConvertAll(item.Sample, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Archive != null && item.Archive.Length > 0)
|
||||
if (item.Archive is not null && item.Archive.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.ArchiveKey]
|
||||
= Array.ConvertAll(item.Archive, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Chip != null && item.Chip.Length > 0)
|
||||
if (item.Chip is not null && item.Chip.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.ChipKey]
|
||||
= Array.ConvertAll(item.Chip, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Video != null)
|
||||
if (item.Video is not null)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.VideoKey]
|
||||
= Array.ConvertAll(item.Video, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Sound != null)
|
||||
if (item.Sound is not null)
|
||||
machine[Data.Models.Metadata.Machine.SoundKey] = ConvertToInternalModel(item.Sound);
|
||||
|
||||
if (item.Input != null)
|
||||
if (item.Input is not null)
|
||||
machine[Data.Models.Metadata.Machine.InputKey] = ConvertToInternalModel(item.Input);
|
||||
|
||||
if (item.DipSwitch != null && item.DipSwitch.Length > 0)
|
||||
if (item.DipSwitch is not null && item.DipSwitch.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.DipSwitchKey]
|
||||
= Array.ConvertAll(item.DipSwitch, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Driver != null)
|
||||
if (item.Driver is not null)
|
||||
machine[Data.Models.Metadata.Machine.DriverKey] = ConvertToInternalModel(item.Driver);
|
||||
|
||||
return machine;
|
||||
@@ -371,7 +371,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var infoSource = new Data.Models.Metadata.InfoSource();
|
||||
|
||||
var sources = item.Source;
|
||||
if (sources != null && sources.Length > 0)
|
||||
if (sources is not null && sources.Length > 0)
|
||||
{
|
||||
string[] sourcesCopy = [.. sources];
|
||||
infoSource[Data.Models.Metadata.InfoSource.SourceKey] = sourcesCopy;
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var metadataFile = new MetadataFile();
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
metadataFile.DosCenter = ConvertHeaderFromInternalModel(header);
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
metadataFile.Game = Array.ConvertAll(machines, ConvertMachineFromInternalModel);
|
||||
|
||||
return metadataFile;
|
||||
@@ -53,7 +53,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var roms = item.Read<Data.Models.Metadata.Rom[]>(Data.Models.Metadata.Machine.RomKey);
|
||||
if (roms != null && roms.Length > 0)
|
||||
if (roms is not null && roms.Length > 0)
|
||||
game.File = Array.ConvertAll(roms, ConvertFromInternalModel);
|
||||
|
||||
return game;
|
||||
|
||||
@@ -13,10 +13,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
|
||||
var metadataFile = new Data.Models.Metadata.MetadataFile();
|
||||
|
||||
if (obj?.DosCenter != null)
|
||||
if (obj?.DosCenter is not null)
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj.DosCenter);
|
||||
|
||||
if (obj?.Game != null && obj.Game.Length > 0)
|
||||
if (obj?.Game is not null && obj.Game.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(obj.Game, ConvertMachineToInternalModel);
|
||||
@@ -53,7 +53,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Machine.NameKey] = item.Name,
|
||||
};
|
||||
|
||||
if (item.File != null && item.File.Length > 0)
|
||||
if (item.File is not null && item.File.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.RomKey]
|
||||
= Array.ConvertAll(item.File, ConvertToInternalModel);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(),
|
||||
};
|
||||
|
||||
if (obj?.Row != null && obj.Row.Length > 0)
|
||||
if (obj?.Row is not null && obj.Row.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(obj.Row, ConvertMachineToInternalModel);
|
||||
|
||||
@@ -38,27 +38,27 @@ namespace SabreTools.Serialization.CrossModel
|
||||
|
||||
foreach (var hashfile in hashfiles)
|
||||
{
|
||||
if (hashfile.SFV != null && hashfile.SFV.Length > 0)
|
||||
if (hashfile.SFV is not null && hashfile.SFV.Length > 0)
|
||||
sfvs.AddRange(hashfile.SFV);
|
||||
if (hashfile.MD2 != null && hashfile.MD2.Length > 0)
|
||||
if (hashfile.MD2 is not null && hashfile.MD2.Length > 0)
|
||||
md2s.AddRange(hashfile.MD2);
|
||||
if (hashfile.MD4 != null && hashfile.MD4.Length > 0)
|
||||
if (hashfile.MD4 is not null && hashfile.MD4.Length > 0)
|
||||
md4s.AddRange(hashfile.MD4);
|
||||
if (hashfile.MD5 != null && hashfile.MD5.Length > 0)
|
||||
if (hashfile.MD5 is not null && hashfile.MD5.Length > 0)
|
||||
md5s.AddRange(hashfile.MD5);
|
||||
if (hashfile.RIPEMD128 != null && hashfile.RIPEMD128.Length > 0)
|
||||
if (hashfile.RIPEMD128 is not null && hashfile.RIPEMD128.Length > 0)
|
||||
ripemd128s.AddRange(hashfile.RIPEMD128);
|
||||
if (hashfile.RIPEMD160 != null && hashfile.RIPEMD160.Length > 0)
|
||||
if (hashfile.RIPEMD160 is not null && hashfile.RIPEMD160.Length > 0)
|
||||
ripemd160s.AddRange(hashfile.RIPEMD160);
|
||||
if (hashfile.SHA1 != null && hashfile.SHA1.Length > 0)
|
||||
if (hashfile.SHA1 is not null && hashfile.SHA1.Length > 0)
|
||||
sha1s.AddRange(hashfile.SHA1);
|
||||
if (hashfile.SHA256 != null && hashfile.SHA256.Length > 0)
|
||||
if (hashfile.SHA256 is not null && hashfile.SHA256.Length > 0)
|
||||
sha256s.AddRange(hashfile.SHA256);
|
||||
if (hashfile.SHA384 != null && hashfile.SHA384.Length > 0)
|
||||
if (hashfile.SHA384 is not null && hashfile.SHA384.Length > 0)
|
||||
sha384s.AddRange(hashfile.SHA384);
|
||||
if (hashfile.SHA512 != null && hashfile.SHA512.Length > 0)
|
||||
if (hashfile.SHA512 is not null && hashfile.SHA512.Length > 0)
|
||||
sha512s.AddRange(hashfile.SHA512);
|
||||
if (hashfile.SpamSum != null && hashfile.SpamSum.Length > 0)
|
||||
if (hashfile.SpamSum is not null && hashfile.SpamSum.Length > 0)
|
||||
spamsums.AddRange(hashfile.SpamSum);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,27 +41,27 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var machine = new Data.Models.Metadata.Machine();
|
||||
|
||||
if (item.SFV != null && item.SFV.Length > 0)
|
||||
if (item.SFV is not null && item.SFV.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SFV, ConvertToInternalModel);
|
||||
else if (item.MD2 != null && item.MD2.Length > 0)
|
||||
else if (item.MD2 is not null && item.MD2.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.MD2, ConvertToInternalModel);
|
||||
else if (item.MD4 != null && item.MD4.Length > 0)
|
||||
else if (item.MD4 is not null && item.MD4.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.MD4, ConvertToInternalModel);
|
||||
else if (item.MD5 != null && item.MD5.Length > 0)
|
||||
else if (item.MD5 is not null && item.MD5.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.MD5, ConvertToInternalModel);
|
||||
else if (item.RIPEMD128 != null && item.RIPEMD128.Length > 0)
|
||||
else if (item.RIPEMD128 is not null && item.RIPEMD128.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.RIPEMD128, ConvertToInternalModel);
|
||||
else if (item.RIPEMD160 != null && item.RIPEMD160.Length > 0)
|
||||
else if (item.RIPEMD160 is not null && item.RIPEMD160.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.RIPEMD160, ConvertToInternalModel);
|
||||
else if (item.SHA1 != null && item.SHA1.Length > 0)
|
||||
else if (item.SHA1 is not null && item.SHA1.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA1, ConvertToInternalModel);
|
||||
else if (item.SHA256 != null && item.SHA256.Length > 0)
|
||||
else if (item.SHA256 is not null && item.SHA256.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA256, ConvertToInternalModel);
|
||||
else if (item.SHA384 != null && item.SHA384.Length > 0)
|
||||
else if (item.SHA384 is not null && item.SHA384.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA384, ConvertToInternalModel);
|
||||
else if (item.SHA512 != null && item.SHA512.Length > 0)
|
||||
else if (item.SHA512 is not null && item.SHA512.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SHA512, ConvertToInternalModel);
|
||||
else if (item.SpamSum != null && item.SpamSum.Length > 0)
|
||||
else if (item.SpamSum is not null && item.SpamSum.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.SpamSum, ConvertToInternalModel);
|
||||
|
||||
return machine;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var metadataFile = new MetadataFile();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
metadataFile.Set = Array.ConvertAll(machines, ConvertMachineFromInternalModel);
|
||||
|
||||
return metadataFile;
|
||||
@@ -35,13 +35,13 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var rowItems = new List<Row>();
|
||||
|
||||
var roms = item.Read<Data.Models.Metadata.Rom[]>(Data.Models.Metadata.Machine.RomKey);
|
||||
if (roms != null)
|
||||
if (roms is not null)
|
||||
{
|
||||
rowItems.AddRange(Array.ConvertAll(roms, ConvertFromInternalModel));
|
||||
}
|
||||
|
||||
var disks = item.Read<Data.Models.Metadata.Disk[]>(Data.Models.Metadata.Machine.DiskKey);
|
||||
if (disks != null)
|
||||
if (disks is not null)
|
||||
rowItems.AddRange(Array.ConvertAll(disks, ConvertFromInternalModel));
|
||||
|
||||
set.Row = [.. rowItems];
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(),
|
||||
};
|
||||
|
||||
if (obj?.Set != null && obj.Set.Length > 0)
|
||||
if (obj?.Set is not null && obj.Set.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(obj.Set, ConvertMachineToInternalModel);
|
||||
@@ -54,7 +54,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
machine[Data.Models.Metadata.Machine.NameKey] = item.Driver;
|
||||
}
|
||||
|
||||
if (item.Row != null && item.Row.Length > 0)
|
||||
if (item.Row is not null && item.Row.Length > 0)
|
||||
{
|
||||
var disks = new List<Data.Models.Metadata.Disk>();
|
||||
var roms = new List<Data.Models.Metadata.Rom>();
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var mame = header != null ? ConvertMameFromInternalModel(header) : new Mame();
|
||||
var mame = header is not null ? ConvertMameFromInternalModel(header) : new Mame();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
mame.Game = Array.ConvertAll(machines, ConvertMachineFromInternalModel);
|
||||
|
||||
return mame;
|
||||
@@ -59,83 +59,83 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var biosSets = item.Read<Data.Models.Metadata.BiosSet[]>(Data.Models.Metadata.Machine.BiosSetKey);
|
||||
if (biosSets != null && biosSets.Length > 0)
|
||||
if (biosSets is not null && biosSets.Length > 0)
|
||||
machine.BiosSet = Array.ConvertAll(biosSets, ConvertFromInternalModel);
|
||||
|
||||
var roms = item.Read<Data.Models.Metadata.Rom[]>(Data.Models.Metadata.Machine.RomKey);
|
||||
if (roms != null && roms.Length > 0)
|
||||
if (roms is not null && roms.Length > 0)
|
||||
machine.Rom = Array.ConvertAll(roms, ConvertFromInternalModel);
|
||||
|
||||
var disks = item.Read<Data.Models.Metadata.Disk[]>(Data.Models.Metadata.Machine.DiskKey);
|
||||
if (disks != null && disks.Length > 0)
|
||||
if (disks is not null && disks.Length > 0)
|
||||
machine.Disk = Array.ConvertAll(disks, ConvertFromInternalModel);
|
||||
|
||||
var deviceRefs = item.Read<Data.Models.Metadata.DeviceRef[]>(Data.Models.Metadata.Machine.DeviceRefKey);
|
||||
if (deviceRefs != null && deviceRefs.Length > 0)
|
||||
if (deviceRefs is not null && deviceRefs.Length > 0)
|
||||
machine.DeviceRef = Array.ConvertAll(deviceRefs, ConvertFromInternalModel);
|
||||
|
||||
var samples = item.Read<Data.Models.Metadata.Sample[]>(Data.Models.Metadata.Machine.SampleKey);
|
||||
if (samples != null && samples.Length > 0)
|
||||
if (samples is not null && samples.Length > 0)
|
||||
machine.Sample = Array.ConvertAll(samples, ConvertFromInternalModel);
|
||||
|
||||
var chips = item.Read<Data.Models.Metadata.Chip[]>(Data.Models.Metadata.Machine.ChipKey);
|
||||
if (chips != null && chips.Length > 0)
|
||||
if (chips is not null && chips.Length > 0)
|
||||
machine.Chip = Array.ConvertAll(chips, ConvertFromInternalModel);
|
||||
|
||||
var displays = item.Read<Data.Models.Metadata.Display[]>(Data.Models.Metadata.Machine.DisplayKey);
|
||||
if (displays != null && displays.Length > 0)
|
||||
if (displays is not null && displays.Length > 0)
|
||||
machine.Display = Array.ConvertAll(displays, ConvertFromInternalModel);
|
||||
|
||||
var videos = item.Read<Data.Models.Metadata.Video[]>(Data.Models.Metadata.Machine.VideoKey);
|
||||
if (videos != null && videos.Length > 0)
|
||||
if (videos is not null && videos.Length > 0)
|
||||
machine.Video = Array.ConvertAll(videos, ConvertFromInternalModel);
|
||||
|
||||
var sound = item.Read<Data.Models.Metadata.Sound>(Data.Models.Metadata.Machine.SoundKey);
|
||||
if (sound != null)
|
||||
if (sound is not null)
|
||||
machine.Sound = ConvertFromInternalModel(sound);
|
||||
|
||||
var input = item.Read<Data.Models.Metadata.Input>(Data.Models.Metadata.Machine.InputKey);
|
||||
if (input != null)
|
||||
if (input is not null)
|
||||
machine.Input = ConvertFromInternalModel(input);
|
||||
|
||||
var dipSwitches = item.Read<Data.Models.Metadata.DipSwitch[]>(Data.Models.Metadata.Machine.DipSwitchKey);
|
||||
if (dipSwitches != null && dipSwitches.Length > 0)
|
||||
if (dipSwitches is not null && dipSwitches.Length > 0)
|
||||
machine.DipSwitch = Array.ConvertAll(dipSwitches, ConvertFromInternalModel);
|
||||
|
||||
var configurations = item.Read<Data.Models.Metadata.Configuration[]>(Data.Models.Metadata.Machine.ConfigurationKey);
|
||||
if (configurations != null && configurations.Length > 0)
|
||||
if (configurations is not null && configurations.Length > 0)
|
||||
machine.Configuration = Array.ConvertAll(configurations, ConvertFromInternalModel);
|
||||
|
||||
var ports = item.Read<Data.Models.Metadata.Port[]>(Data.Models.Metadata.Machine.PortKey);
|
||||
if (ports != null && ports.Length > 0)
|
||||
if (ports is not null && ports.Length > 0)
|
||||
machine.Port = Array.ConvertAll(ports, ConvertFromInternalModel);
|
||||
|
||||
var adjusters = item.Read<Data.Models.Metadata.Adjuster[]>(Data.Models.Metadata.Machine.AdjusterKey);
|
||||
if (adjusters != null && adjusters.Length > 0)
|
||||
if (adjusters is not null && adjusters.Length > 0)
|
||||
machine.Adjuster = Array.ConvertAll(adjusters, ConvertFromInternalModel);
|
||||
|
||||
var driver = item.Read<Data.Models.Metadata.Driver>(Data.Models.Metadata.Machine.DriverKey);
|
||||
if (driver != null)
|
||||
if (driver is not null)
|
||||
machine.Driver = ConvertFromInternalModel(driver);
|
||||
|
||||
var features = item.Read<Data.Models.Metadata.Feature[]>(Data.Models.Metadata.Machine.FeatureKey);
|
||||
if (features != null && features.Length > 0)
|
||||
if (features is not null && features.Length > 0)
|
||||
machine.Feature = Array.ConvertAll(features, ConvertFromInternalModel);
|
||||
|
||||
var devices = item.Read<Data.Models.Metadata.Device[]>(Data.Models.Metadata.Machine.DeviceKey);
|
||||
if (devices != null && devices.Length > 0)
|
||||
if (devices is not null && devices.Length > 0)
|
||||
machine.Device = Array.ConvertAll(devices, ConvertFromInternalModel);
|
||||
|
||||
var slots = item.Read<Data.Models.Metadata.Slot[]>(Data.Models.Metadata.Machine.SlotKey);
|
||||
if (slots != null && slots.Length > 0)
|
||||
if (slots is not null && slots.Length > 0)
|
||||
machine.Slot = Array.ConvertAll(slots, ConvertFromInternalModel);
|
||||
|
||||
var softwareLists = item.Read<Data.Models.Metadata.SoftwareList[]>(Data.Models.Metadata.Machine.SoftwareListKey);
|
||||
if (softwareLists != null && softwareLists.Length > 0)
|
||||
if (softwareLists is not null && softwareLists.Length > 0)
|
||||
machine.SoftwareList = Array.ConvertAll(softwareLists, ConvertFromInternalModel);
|
||||
|
||||
var ramOptions = item.Read<Data.Models.Metadata.RamOption[]>(Data.Models.Metadata.Machine.RamOptionKey);
|
||||
if (ramOptions != null && ramOptions.Length > 0)
|
||||
if (ramOptions is not null && ramOptions.Length > 0)
|
||||
machine.RamOption = Array.ConvertAll(ramOptions, ConvertFromInternalModel);
|
||||
|
||||
return machine;
|
||||
@@ -153,7 +153,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var condition = item.Read<Data.Models.Metadata.Condition>(Data.Models.Metadata.Adjuster.ConditionKey);
|
||||
if (condition != null)
|
||||
if (condition is not null)
|
||||
adjuster.Condition = ConvertFromInternalModel(condition);
|
||||
|
||||
return adjuster;
|
||||
@@ -229,15 +229,15 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var condition = item.Read<Data.Models.Metadata.Condition>(Data.Models.Metadata.Configuration.ConditionKey);
|
||||
if (condition != null)
|
||||
if (condition is not null)
|
||||
configuration.Condition = ConvertFromInternalModel(condition);
|
||||
|
||||
var confLocations = item.Read<Data.Models.Metadata.ConfLocation[]>(Data.Models.Metadata.Configuration.ConfLocationKey);
|
||||
if (confLocations != null && confLocations.Length > 0)
|
||||
if (confLocations is not null && confLocations.Length > 0)
|
||||
configuration.ConfLocation = Array.ConvertAll(confLocations, ConvertFromInternalModel);
|
||||
|
||||
var confSettings = item.Read<Data.Models.Metadata.ConfSetting[]>(Data.Models.Metadata.Configuration.ConfSettingKey);
|
||||
if (confSettings != null && confSettings.Length > 0)
|
||||
if (confSettings is not null && confSettings.Length > 0)
|
||||
configuration.ConfSetting = Array.ConvertAll(confSettings, ConvertFromInternalModel);
|
||||
|
||||
return configuration;
|
||||
@@ -270,7 +270,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var condition = item.Read<Data.Models.Metadata.Condition>(Data.Models.Metadata.ConfSetting.ConditionKey);
|
||||
if (condition != null)
|
||||
if (condition is not null)
|
||||
confSetting.Condition = ConvertFromInternalModel(condition);
|
||||
|
||||
return confSetting;
|
||||
@@ -314,11 +314,11 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var instance = item.Read<Data.Models.Metadata.Instance>(Data.Models.Metadata.Device.InstanceKey);
|
||||
if (instance != null)
|
||||
if (instance is not null)
|
||||
device.Instance = ConvertFromInternalModel(instance);
|
||||
|
||||
var extensions = item.Read<Data.Models.Metadata.Extension[]>(Data.Models.Metadata.Device.ExtensionKey);
|
||||
if (extensions != null && extensions.Length > 0)
|
||||
if (extensions is not null && extensions.Length > 0)
|
||||
device.Extension = Array.ConvertAll(extensions, ConvertFromInternalModel);
|
||||
|
||||
return device;
|
||||
@@ -363,15 +363,15 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var condition = item.Read<Data.Models.Metadata.Condition>(Data.Models.Metadata.DipSwitch.ConditionKey);
|
||||
if (condition != null)
|
||||
if (condition is not null)
|
||||
dipSwitch.Condition = ConvertFromInternalModel(condition);
|
||||
|
||||
var dipLocations = item.Read<Data.Models.Metadata.DipLocation[]>(Data.Models.Metadata.DipSwitch.DipLocationKey);
|
||||
if (dipLocations != null && dipLocations.Length > 0)
|
||||
if (dipLocations is not null && dipLocations.Length > 0)
|
||||
dipSwitch.DipLocation = Array.ConvertAll(dipLocations, ConvertFromInternalModel);
|
||||
|
||||
var dipValues = item.Read<Data.Models.Metadata.DipValue[]>(Data.Models.Metadata.DipSwitch.DipValueKey);
|
||||
if (dipValues != null && dipValues.Length > 0)
|
||||
if (dipValues is not null && dipValues.Length > 0)
|
||||
dipSwitch.DipValue = Array.ConvertAll(dipValues, ConvertFromInternalModel);
|
||||
|
||||
return dipSwitch;
|
||||
@@ -390,7 +390,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var condition = item.Read<Data.Models.Metadata.Condition>(Data.Models.Metadata.DipValue.ConditionKey);
|
||||
if (condition != null)
|
||||
if (condition is not null)
|
||||
dipValue.Condition = ConvertFromInternalModel(condition);
|
||||
|
||||
return dipValue;
|
||||
@@ -504,11 +504,11 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var controlAttr = item.ReadString(Data.Models.Metadata.Input.ControlKey);
|
||||
if (controlAttr != null)
|
||||
if (controlAttr is not null)
|
||||
input.ControlAttr = controlAttr;
|
||||
|
||||
var controls = item.Read<Data.Models.Metadata.Control[]>(Data.Models.Metadata.Input.ControlKey);
|
||||
if (controls != null && controls.Length > 0)
|
||||
if (controls is not null && controls.Length > 0)
|
||||
input.Control = Array.ConvertAll(controls, ConvertFromInternalModel);
|
||||
|
||||
return input;
|
||||
@@ -538,7 +538,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var analogs = item.Read<Data.Models.Metadata.Analog[]>(Data.Models.Metadata.Port.AnalogKey);
|
||||
if (analogs != null && analogs.Length > 0)
|
||||
if (analogs is not null && analogs.Length > 0)
|
||||
port.Analog = Array.ConvertAll(analogs, ConvertFromInternalModel);
|
||||
|
||||
return port;
|
||||
@@ -604,7 +604,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var slotOptions = item.Read<Data.Models.Metadata.SlotOption[]>(Data.Models.Metadata.Slot.SlotOptionKey);
|
||||
if (slotOptions != null && slotOptions.Length > 0)
|
||||
if (slotOptions is not null && slotOptions.Length > 0)
|
||||
slot.SlotOption = Array.ConvertAll(slotOptions, ConvertFromInternalModel);
|
||||
|
||||
return slot;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
};
|
||||
|
||||
if (item?.Game != null && item.Game.Length > 0)
|
||||
if (item?.Game is not null && item.Game.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(item.Game, ConvertMachineToInternalModel);
|
||||
@@ -61,112 +61,112 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Machine.HistoryKey] = item.History,
|
||||
};
|
||||
|
||||
if (item.BiosSet != null && item.BiosSet.Length > 0)
|
||||
if (item.BiosSet is not null && item.BiosSet.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.BiosSetKey]
|
||||
= Array.ConvertAll(item.BiosSet, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Rom != null && item.Rom.Length > 0)
|
||||
if (item.Rom is not null && item.Rom.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.RomKey]
|
||||
= Array.ConvertAll(item.Rom, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Disk != null && item.Disk.Length > 0)
|
||||
if (item.Disk is not null && item.Disk.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.DiskKey]
|
||||
= Array.ConvertAll(item.Disk, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.DeviceRef != null && item.DeviceRef.Length > 0)
|
||||
if (item.DeviceRef is not null && item.DeviceRef.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.DeviceRefKey]
|
||||
= Array.ConvertAll(item.DeviceRef, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Sample != null && item.Sample.Length > 0)
|
||||
if (item.Sample is not null && item.Sample.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.SampleKey]
|
||||
= Array.ConvertAll(item.Sample, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Chip != null && item.Chip.Length > 0)
|
||||
if (item.Chip is not null && item.Chip.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.ChipKey]
|
||||
= Array.ConvertAll(item.Chip, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Display != null && item.Display.Length > 0)
|
||||
if (item.Display is not null && item.Display.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.DisplayKey]
|
||||
= Array.ConvertAll(item.Display, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Video != null && item.Video.Length > 0)
|
||||
if (item.Video is not null && item.Video.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.VideoKey]
|
||||
= Array.ConvertAll(item.Video, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Sound != null)
|
||||
if (item.Sound is not null)
|
||||
machine[Data.Models.Metadata.Machine.SoundKey] = ConvertToInternalModel(item.Sound);
|
||||
|
||||
if (item.Input != null)
|
||||
if (item.Input is not null)
|
||||
machine[Data.Models.Metadata.Machine.InputKey] = ConvertToInternalModel(item.Input);
|
||||
|
||||
if (item.DipSwitch != null && item.DipSwitch.Length > 0)
|
||||
if (item.DipSwitch is not null && item.DipSwitch.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.DipSwitchKey]
|
||||
= Array.ConvertAll(item.DipSwitch, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Configuration != null && item.Configuration.Length > 0)
|
||||
if (item.Configuration is not null && item.Configuration.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.ConfigurationKey]
|
||||
= Array.ConvertAll(item.Configuration, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Port != null && item.Port.Length > 0)
|
||||
if (item.Port is not null && item.Port.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.PortKey]
|
||||
= Array.ConvertAll(item.Port, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Adjuster != null && item.Adjuster.Length > 0)
|
||||
if (item.Adjuster is not null && item.Adjuster.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.AdjusterKey]
|
||||
= Array.ConvertAll(item.Adjuster, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Driver != null)
|
||||
if (item.Driver is not null)
|
||||
machine[Data.Models.Metadata.Machine.DriverKey] = ConvertToInternalModel(item.Driver);
|
||||
|
||||
if (item.Feature != null && item.Feature.Length > 0)
|
||||
if (item.Feature is not null && item.Feature.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.FeatureKey]
|
||||
= Array.ConvertAll(item.Feature, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Device != null && item.Device.Length > 0)
|
||||
if (item.Device is not null && item.Device.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.DeviceKey]
|
||||
= Array.ConvertAll(item.Device, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.Slot != null && item.Slot.Length > 0)
|
||||
if (item.Slot is not null && item.Slot.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.SlotKey]
|
||||
= Array.ConvertAll(item.Slot, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.SoftwareList != null && item.SoftwareList.Length > 0)
|
||||
if (item.SoftwareList is not null && item.SoftwareList.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.SoftwareListKey]
|
||||
= Array.ConvertAll(item.SoftwareList, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.RamOption != null && item.RamOption.Length > 0)
|
||||
if (item.RamOption is not null && item.RamOption.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.RamOptionKey]
|
||||
= Array.ConvertAll(item.RamOption, ConvertToInternalModel);
|
||||
@@ -186,7 +186,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Adjuster.DefaultKey] = item.Default,
|
||||
};
|
||||
|
||||
if (item.Condition != null)
|
||||
if (item.Condition is not null)
|
||||
adjuster[Data.Models.Metadata.Adjuster.ConditionKey] = ConvertToInternalModel(item.Condition);
|
||||
|
||||
return adjuster;
|
||||
@@ -261,16 +261,16 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Configuration.MaskKey] = item.Mask,
|
||||
};
|
||||
|
||||
if (item.Condition != null)
|
||||
if (item.Condition is not null)
|
||||
configuration[Data.Models.Metadata.Configuration.ConditionKey] = ConvertToInternalModel(item.Condition);
|
||||
|
||||
if (item.ConfLocation != null && item.ConfLocation.Length > 0)
|
||||
if (item.ConfLocation is not null && item.ConfLocation.Length > 0)
|
||||
{
|
||||
configuration[Data.Models.Metadata.Configuration.ConfLocationKey]
|
||||
= Array.ConvertAll(item.ConfLocation, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.ConfSetting != null && item.ConfSetting.Length > 0)
|
||||
if (item.ConfSetting is not null && item.ConfSetting.Length > 0)
|
||||
{
|
||||
configuration[Data.Models.Metadata.Configuration.ConfSettingKey]
|
||||
= Array.ConvertAll(item.ConfSetting, ConvertToInternalModel);
|
||||
@@ -305,7 +305,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.ConfSetting.DefaultKey] = item.Default,
|
||||
};
|
||||
|
||||
if (item.Condition != null)
|
||||
if (item.Condition is not null)
|
||||
confSetting[Data.Models.Metadata.ConfSetting.ConditionKey] = ConvertToInternalModel(item.Condition);
|
||||
|
||||
return confSetting;
|
||||
@@ -348,10 +348,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Device.InterfaceKey] = item.Interface,
|
||||
};
|
||||
|
||||
if (item.Instance != null)
|
||||
if (item.Instance is not null)
|
||||
device[Data.Models.Metadata.Device.InstanceKey] = ConvertToInternalModel(item.Instance);
|
||||
|
||||
if (item.Extension != null && item.Extension.Length > 0)
|
||||
if (item.Extension is not null && item.Extension.Length > 0)
|
||||
{
|
||||
device[Data.Models.Metadata.Device.ExtensionKey]
|
||||
= Array.ConvertAll(item.Extension, ConvertToInternalModel);
|
||||
@@ -398,16 +398,16 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.DipSwitch.MaskKey] = item.Mask,
|
||||
};
|
||||
|
||||
if (item.Condition != null)
|
||||
if (item.Condition is not null)
|
||||
dipSwitch[Data.Models.Metadata.DipSwitch.ConditionKey] = ConvertToInternalModel(item.Condition);
|
||||
|
||||
if (item.DipLocation != null && item.DipLocation.Length > 0)
|
||||
if (item.DipLocation is not null && item.DipLocation.Length > 0)
|
||||
{
|
||||
dipSwitch[Data.Models.Metadata.DipSwitch.DipLocationKey]
|
||||
= Array.ConvertAll(item.DipLocation, ConvertToInternalModel);
|
||||
}
|
||||
|
||||
if (item.DipValue != null && item.DipValue.Length > 0)
|
||||
if (item.DipValue is not null && item.DipValue.Length > 0)
|
||||
{
|
||||
dipSwitch[Data.Models.Metadata.DipSwitch.DipValueKey]
|
||||
= Array.ConvertAll(item.DipValue, ConvertToInternalModel);
|
||||
@@ -428,7 +428,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.DipValue.DefaultKey] = item.Default,
|
||||
};
|
||||
|
||||
if (item.Condition != null)
|
||||
if (item.Condition is not null)
|
||||
dipValue[Data.Models.Metadata.DipValue.ConditionKey] = ConvertToInternalModel(item.Condition);
|
||||
|
||||
return dipValue;
|
||||
@@ -542,7 +542,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Input.CoinsKey] = item.Coins,
|
||||
};
|
||||
|
||||
if (item.Control != null && item.Control.Length > 0)
|
||||
if (item.Control is not null && item.Control.Length > 0)
|
||||
{
|
||||
input[Data.Models.Metadata.Input.ControlKey]
|
||||
= Array.ConvertAll(item.Control, ConvertToInternalModel);
|
||||
@@ -574,7 +574,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Port.TagKey] = item.Tag,
|
||||
};
|
||||
|
||||
if (item.Analog != null && item.Analog.Length > 0)
|
||||
if (item.Analog is not null && item.Analog.Length > 0)
|
||||
{
|
||||
port[Data.Models.Metadata.Port.AnalogKey]
|
||||
= Array.ConvertAll(item.Analog, ConvertToInternalModel);
|
||||
@@ -642,7 +642,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Slot.NameKey] = item.Name,
|
||||
};
|
||||
|
||||
if (item.SlotOption != null && item.SlotOption.Length > 0)
|
||||
if (item.SlotOption is not null && item.SlotOption.Length > 0)
|
||||
{
|
||||
slot[Data.Models.Metadata.Slot.SlotOptionKey]
|
||||
= Array.ConvertAll(item.SlotOption, ConvertToInternalModel);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var datafile = new Datafile();
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
{
|
||||
datafile.Build = header.ReadString(Data.Models.Metadata.Header.BuildKey);
|
||||
datafile.Debug = header.ReadString(Data.Models.Metadata.Header.DebugKey);
|
||||
@@ -27,7 +27,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
}
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
datafile.Game = Array.ConvertAll(machines, m => ConvertMachineFromInternalModel(m, game));
|
||||
|
||||
return datafile;
|
||||
@@ -60,19 +60,19 @@ namespace SabreTools.Serialization.CrossModel
|
||||
string? forceNodump = item.ReadString(Data.Models.Metadata.Header.ForceNodumpKey);
|
||||
string? forceUnpacking = item.ReadString(Data.Models.Metadata.Header.ForcePackingKey);
|
||||
|
||||
if (headerVal != null
|
||||
|| forceMerging != null
|
||||
|| forceNodump != null
|
||||
|| forceUnpacking != null)
|
||||
if (headerVal is not null
|
||||
|| forceMerging is not null
|
||||
|| forceNodump is not null
|
||||
|| forceUnpacking is not null)
|
||||
{
|
||||
header.ClrMamePro = new Data.Models.Logiqx.ClrMamePro();
|
||||
if (headerVal != null)
|
||||
if (headerVal is not null)
|
||||
header.ClrMamePro.Header = headerVal;
|
||||
if (forceMerging != null)
|
||||
if (forceMerging is not null)
|
||||
header.ClrMamePro.ForceMerging = forceMerging;
|
||||
if (forceNodump != null)
|
||||
if (forceNodump is not null)
|
||||
header.ClrMamePro.ForceNodump = forceNodump;
|
||||
if (forceUnpacking != null)
|
||||
if (forceUnpacking is not null)
|
||||
header.ClrMamePro.ForcePacking = forceUnpacking;
|
||||
}
|
||||
|
||||
@@ -84,28 +84,28 @@ namespace SabreTools.Serialization.CrossModel
|
||||
string? lockBiosMode = item.ReadString(Data.Models.Metadata.Header.LockBiosModeKey);
|
||||
string? lockSampleMode = item.ReadString(Data.Models.Metadata.Header.LockSampleModeKey);
|
||||
|
||||
if (plugin != null
|
||||
|| romMode != null
|
||||
|| biosMode != null
|
||||
|| sampleMode != null
|
||||
|| lockRomMode != null
|
||||
|| lockBiosMode != null
|
||||
|| lockSampleMode != null)
|
||||
if (plugin is not null
|
||||
|| romMode is not null
|
||||
|| biosMode is not null
|
||||
|| sampleMode is not null
|
||||
|| lockRomMode is not null
|
||||
|| lockBiosMode is not null
|
||||
|| lockSampleMode is not null)
|
||||
{
|
||||
header.RomCenter = new Data.Models.Logiqx.RomCenter();
|
||||
if (plugin != null)
|
||||
if (plugin is not null)
|
||||
header.RomCenter.Plugin = plugin;
|
||||
if (romMode != null)
|
||||
if (romMode is not null)
|
||||
header.RomCenter.RomMode = romMode;
|
||||
if (biosMode != null)
|
||||
if (biosMode is not null)
|
||||
header.RomCenter.BiosMode = biosMode;
|
||||
if (sampleMode != null)
|
||||
if (sampleMode is not null)
|
||||
header.RomCenter.SampleMode = sampleMode;
|
||||
if (lockRomMode != null)
|
||||
if (lockRomMode is not null)
|
||||
header.RomCenter.LockRomMode = lockRomMode;
|
||||
if (lockBiosMode != null)
|
||||
if (lockBiosMode is not null)
|
||||
header.RomCenter.LockBiosMode = lockBiosMode;
|
||||
if (lockSampleMode != null)
|
||||
if (lockSampleMode is not null)
|
||||
header.RomCenter.LockSampleMode = lockSampleMode;
|
||||
}
|
||||
|
||||
@@ -140,47 +140,47 @@ namespace SabreTools.Serialization.CrossModel
|
||||
gameBase.Category = item.ReadStringArray(Data.Models.Metadata.Machine.CategoryKey);
|
||||
|
||||
var trurip = item.Read<Trurip>(Data.Models.Metadata.Machine.TruripKey);
|
||||
if (trurip != null)
|
||||
if (trurip is not null)
|
||||
gameBase.Trurip = trurip;
|
||||
|
||||
var releases = item.Read<Data.Models.Metadata.Release[]>(Data.Models.Metadata.Machine.ReleaseKey);
|
||||
if (releases != null && releases.Length > 0)
|
||||
if (releases is not null && releases.Length > 0)
|
||||
gameBase.Release = Array.ConvertAll(releases, ConvertFromInternalModel);
|
||||
|
||||
var biosSets = item.Read<Data.Models.Metadata.BiosSet[]>(Data.Models.Metadata.Machine.BiosSetKey);
|
||||
if (biosSets != null && biosSets.Length > 0)
|
||||
if (biosSets is not null && biosSets.Length > 0)
|
||||
gameBase.BiosSet = Array.ConvertAll(biosSets, ConvertFromInternalModel);
|
||||
|
||||
var roms = item.Read<Data.Models.Metadata.Rom[]>(Data.Models.Metadata.Machine.RomKey);
|
||||
if (roms != null && roms.Length > 0)
|
||||
if (roms is not null && roms.Length > 0)
|
||||
gameBase.Rom = Array.ConvertAll(roms, ConvertFromInternalModel);
|
||||
|
||||
var disks = item.Read<Data.Models.Metadata.Disk[]>(Data.Models.Metadata.Machine.DiskKey);
|
||||
if (disks != null && disks.Length > 0)
|
||||
if (disks is not null && disks.Length > 0)
|
||||
gameBase.Disk = Array.ConvertAll(disks, ConvertFromInternalModel);
|
||||
|
||||
var medias = item.Read<Data.Models.Metadata.Media[]>(Data.Models.Metadata.Machine.MediaKey);
|
||||
if (medias != null && medias.Length > 0)
|
||||
if (medias is not null && medias.Length > 0)
|
||||
gameBase.Media = Array.ConvertAll(medias, ConvertFromInternalModel);
|
||||
|
||||
var deviceRefs = item.Read<Data.Models.Metadata.DeviceRef[]>(Data.Models.Metadata.Machine.DeviceRefKey);
|
||||
if (deviceRefs != null && deviceRefs.Length > 0)
|
||||
if (deviceRefs is not null && deviceRefs.Length > 0)
|
||||
gameBase.DeviceRef = Array.ConvertAll(deviceRefs, ConvertFromInternalModel);
|
||||
|
||||
var samples = item.Read<Data.Models.Metadata.Sample[]>(Data.Models.Metadata.Machine.SampleKey);
|
||||
if (samples != null && samples.Length > 0)
|
||||
if (samples is not null && samples.Length > 0)
|
||||
gameBase.Sample = Array.ConvertAll(samples, ConvertFromInternalModel);
|
||||
|
||||
var archives = item.Read<Data.Models.Metadata.Archive[]>(Data.Models.Metadata.Machine.ArchiveKey);
|
||||
if (archives != null && archives.Length > 0)
|
||||
if (archives is not null && archives.Length > 0)
|
||||
gameBase.Archive = Array.ConvertAll(archives, ConvertFromInternalModel);
|
||||
|
||||
var driver = item.Read<Data.Models.Metadata.Driver>(Data.Models.Metadata.Machine.DriverKey);
|
||||
if (driver != null)
|
||||
if (driver is not null)
|
||||
gameBase.Driver = ConvertFromInternalModel(driver);
|
||||
|
||||
var softwareLists = item.Read<Data.Models.Metadata.SoftwareList[]>(Data.Models.Metadata.Machine.SoftwareListKey);
|
||||
if (softwareLists != null && softwareLists.Length > 0)
|
||||
if (softwareLists is not null && softwareLists.Length > 0)
|
||||
gameBase.SoftwareList = Array.ConvertAll(softwareLists, ConvertFromInternalModel);
|
||||
|
||||
return gameBase;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
|
||||
var machines = new List<Data.Models.Metadata.Machine>();
|
||||
|
||||
if (item.Game != null && item.Game.Length > 0)
|
||||
if (item.Game is not null && item.Game.Length > 0)
|
||||
machines.AddRange(Array.ConvertAll(item.Game, g => ConvertMachineToInternalModel(g)));
|
||||
|
||||
foreach (var dir in item.Dir ?? [])
|
||||
@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
/// </summary>
|
||||
private static Data.Models.Metadata.Header ConvertHeaderToInternalModel(Datafile item)
|
||||
{
|
||||
var header = item.Header != null ? ConvertHeaderToInternalModel(item.Header) : [];
|
||||
var header = item.Header is not null ? ConvertHeaderToInternalModel(item.Header) : [];
|
||||
|
||||
header[Data.Models.Metadata.Header.BuildKey] = item.Build;
|
||||
header[Data.Models.Metadata.Header.DebugKey] = item.Debug;
|
||||
@@ -68,7 +68,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Header.TypeKey] = item.Type,
|
||||
};
|
||||
|
||||
if (item.ClrMamePro != null)
|
||||
if (item.ClrMamePro is not null)
|
||||
{
|
||||
header[Data.Models.Metadata.Header.HeaderKey] = item.ClrMamePro.Header;
|
||||
header[Data.Models.Metadata.Header.ForceMergingKey] = item.ClrMamePro.ForceMerging;
|
||||
@@ -76,7 +76,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
header[Data.Models.Metadata.Header.ForcePackingKey] = item.ClrMamePro.ForcePacking;
|
||||
}
|
||||
|
||||
if (item.RomCenter != null)
|
||||
if (item.RomCenter is not null)
|
||||
{
|
||||
header[Data.Models.Metadata.Header.PluginKey] = item.RomCenter.Plugin;
|
||||
header[Data.Models.Metadata.Header.RomModeKey] = item.RomCenter.RomMode;
|
||||
@@ -97,12 +97,12 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
// Get the directory name
|
||||
string? dirName = item.Name;
|
||||
if (parent != null)
|
||||
if (parent is not null)
|
||||
dirName = $"{parent}\\{item.Name}";
|
||||
|
||||
// Handle machine items
|
||||
Data.Models.Metadata.Machine[] machines = [];
|
||||
if (item.Game != null && item.Game.Length > 0)
|
||||
if (item.Game is not null && item.Game.Length > 0)
|
||||
machines = Array.ConvertAll(item.Game, g => ConvertMachineToInternalModel(g, dirName));
|
||||
|
||||
// Handle dir items
|
||||
@@ -121,7 +121,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
private static Data.Models.Metadata.Machine ConvertMachineToInternalModel(GameBase item, string? dir = null)
|
||||
{
|
||||
string? machineName = item.Name;
|
||||
if (machineName != null && dir != null)
|
||||
if (machineName is not null && dir is not null)
|
||||
machineName = $"{dir}\\{machineName}";
|
||||
|
||||
var machine = new Data.Models.Metadata.Machine
|
||||
@@ -148,34 +148,34 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Machine.TruripKey] = item.Trurip,
|
||||
};
|
||||
|
||||
if (item.Release != null && item.Release.Length > 0)
|
||||
if (item.Release is not null && item.Release.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.ReleaseKey] = Array.ConvertAll(item.Release, ConvertToInternalModel);
|
||||
|
||||
if (item.BiosSet != null && item.BiosSet.Length > 0)
|
||||
if (item.BiosSet is not null && item.BiosSet.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.BiosSetKey] = Array.ConvertAll(item.BiosSet, ConvertToInternalModel);
|
||||
|
||||
if (item.Rom != null && item.Rom.Length > 0)
|
||||
if (item.Rom is not null && item.Rom.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.RomKey] = Array.ConvertAll(item.Rom, ConvertToInternalModel);
|
||||
|
||||
if (item.Disk != null && item.Disk.Length > 0)
|
||||
if (item.Disk is not null && item.Disk.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.DiskKey] = Array.ConvertAll(item.Disk, ConvertToInternalModel);
|
||||
|
||||
if (item.Media != null && item.Media.Length > 0)
|
||||
if (item.Media is not null && item.Media.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.MediaKey] = Array.ConvertAll(item.Media, ConvertToInternalModel);
|
||||
|
||||
if (item.DeviceRef != null && item.DeviceRef.Length > 0)
|
||||
if (item.DeviceRef is not null && item.DeviceRef.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.DeviceRefKey] = Array.ConvertAll(item.DeviceRef, ConvertToInternalModel);
|
||||
|
||||
if (item.Sample != null && item.Sample.Length > 0)
|
||||
if (item.Sample is not null && item.Sample.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.SampleKey] = Array.ConvertAll(item.Sample, ConvertToInternalModel);
|
||||
|
||||
if (item.Archive != null && item.Archive.Length > 0)
|
||||
if (item.Archive is not null && item.Archive.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.ArchiveKey] = Array.ConvertAll(item.Archive, ConvertToInternalModel);
|
||||
|
||||
if (item.Driver != null)
|
||||
if (item.Driver is not null)
|
||||
machine[Data.Models.Metadata.Machine.DriverKey] = ConvertToInternalModel(item.Driver);
|
||||
|
||||
if (item.SoftwareList != null && item.SoftwareList.Length > 0)
|
||||
if (item.SoftwareList is not null && item.SoftwareList.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.SoftwareListKey] = Array.ConvertAll(item.SoftwareList, ConvertToInternalModel);
|
||||
|
||||
return machine;
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var m1 = header != null ? ConvertM1FromInternalModel(header) : new Data.Models.Listxml.M1();
|
||||
var m1 = header is not null ? ConvertM1FromInternalModel(header) : new Data.Models.Listxml.M1();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
m1.Game = Array.ConvertAll(machines, Listxml.ConvertMachineFromInternalModel);
|
||||
|
||||
return m1;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
};
|
||||
|
||||
if (item?.Game != null && item.Game.Length > 0)
|
||||
if (item?.Game is not null && item.Game.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(item.Game, Listxml.ConvertMachineToInternalModel);
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var m1 = header != null ? ConvertMessFromInternalModel(header) : new Data.Models.Listxml.Mess();
|
||||
var m1 = header is not null ? ConvertMessFromInternalModel(header) : new Data.Models.Listxml.Mess();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
m1.Game = Array.ConvertAll(machines, Listxml.ConvertMachineFromInternalModel);
|
||||
|
||||
return m1;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
};
|
||||
|
||||
if (item?.Game != null && item.Game.Length > 0)
|
||||
if (item?.Game is not null && item.Game.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(item.Game, Listxml.ConvertMachineToInternalModel);
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var dat = header != null ? ConvertHeaderFromInternalModel(header) : new Dat();
|
||||
var dat = header is not null ? ConvertHeaderFromInternalModel(header) : new Dat();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
{
|
||||
dat.Games = new Games
|
||||
{
|
||||
@@ -97,7 +97,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var roms = item.Read<Data.Models.Metadata.Rom[]>(Data.Models.Metadata.Machine.RomKey);
|
||||
if (roms != null && roms.Length > 0)
|
||||
if (roms is not null && roms.Length > 0)
|
||||
{
|
||||
var romSizes = Array.ConvertAll(roms, r => r.ReadLong(Data.Models.Metadata.Rom.SizeKey) ?? -1);
|
||||
game.RomSize = Array.Find(romSizes, s => s > -1).ToString();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
};
|
||||
|
||||
if (item?.Games?.Game != null && item.Games.Game.Length > 0)
|
||||
if (item?.Games?.Game is not null && item.Games.Game.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(item.Games.Game, ConvertMachineToInternalModel);
|
||||
@@ -35,7 +35,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Header.SchemaLocationKey] = item.NoNamespaceSchemaLocation,
|
||||
};
|
||||
|
||||
if (item.Configuration != null)
|
||||
if (item.Configuration is not null)
|
||||
{
|
||||
header[Data.Models.Metadata.Header.NameKey] = item.Configuration.DatName;
|
||||
header[Data.Models.Metadata.Header.ImFolderKey] = item.Configuration.ImFolder;
|
||||
@@ -50,7 +50,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
header[Data.Models.Metadata.Header.RomTitleKey] = item.Configuration.RomTitle;
|
||||
}
|
||||
|
||||
if (item.GUI != null)
|
||||
if (item.GUI is not null)
|
||||
{
|
||||
header[Data.Models.Metadata.Header.ImagesKey] = item.GUI.Images;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Machine.DuplicateIDKey] = item.DuplicateID,
|
||||
};
|
||||
|
||||
if (item.Files?.RomCRC != null && item.Files.RomCRC.Length > 0)
|
||||
if (item.Files?.RomCRC is not null && item.Files.RomCRC.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.RomKey]
|
||||
= Array.ConvertAll(item.Files.RomCRC, romCRC =>
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var softwareDb = header != null ? ConvertHeaderFromInternalModel(header) : new SoftwareDb();
|
||||
var softwareDb = header is not null ? ConvertHeaderFromInternalModel(header) : new SoftwareDb();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
softwareDb.Software = Array.ConvertAll(machines, ConvertMachineFromInternalModel);
|
||||
|
||||
return softwareDb;
|
||||
@@ -49,7 +49,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var dumps = item.Read<Data.Models.Metadata.Dump[]>(Data.Models.Metadata.Machine.DumpKey);
|
||||
if (dumps != null && dumps.Length > 0)
|
||||
if (dumps is not null && dumps.Length > 0)
|
||||
game.Dump = Array.ConvertAll(dumps, ConvertFromInternalModel);
|
||||
|
||||
return game;
|
||||
@@ -63,19 +63,19 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var dump = new Dump();
|
||||
|
||||
var original = item.Read<Data.Models.Metadata.Original>(Data.Models.Metadata.Dump.OriginalKey);
|
||||
if (original != null)
|
||||
if (original is not null)
|
||||
dump.Original = ConvertFromInternalModel(original);
|
||||
|
||||
var rom = item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.RomKey);
|
||||
if (rom != null)
|
||||
if (rom is not null)
|
||||
dump.Rom = ConvertRomFromInternalModel(rom);
|
||||
|
||||
var megaRom = item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.MegaRomKey);
|
||||
if (megaRom != null)
|
||||
if (megaRom is not null)
|
||||
dump.Rom = ConvertMegaRomFromInternalModel(megaRom);
|
||||
|
||||
var sccPlusCart = item.Read<Data.Models.Metadata.Rom>(Data.Models.Metadata.Dump.SCCPlusCartKey);
|
||||
if (sccPlusCart != null)
|
||||
if (sccPlusCart is not null)
|
||||
dump.Rom = ConvertSCCPlusCartFromInternalModel(sccPlusCart);
|
||||
|
||||
return dump;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
};
|
||||
|
||||
if (item?.Software != null && item.Software.Length > 0)
|
||||
if (item?.Software is not null && item.Software.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(item.Software, ConvertMachineToInternalModel);
|
||||
@@ -52,7 +52,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Machine.CountryKey] = item.Country,
|
||||
};
|
||||
|
||||
if (item.Dump != null && item.Dump.Length > 0)
|
||||
if (item.Dump is not null && item.Dump.Length > 0)
|
||||
{
|
||||
machine[Data.Models.Metadata.Machine.DumpKey]
|
||||
= Array.ConvertAll(item.Dump, ConvertToInternalModel);
|
||||
@@ -68,10 +68,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var dump = new Data.Models.Metadata.Dump();
|
||||
|
||||
if (item.Original != null)
|
||||
if (item.Original is not null)
|
||||
dump[Data.Models.Metadata.Dump.OriginalKey] = ConvertToInternalModel(item.Original);
|
||||
|
||||
if (item.Rom != null)
|
||||
if (item.Rom is not null)
|
||||
{
|
||||
switch (item.Rom)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var metadataFile = header != null ? ConvertHeaderFromInternalModel(header) : new MetadataFile();
|
||||
var metadataFile = header is not null ? ConvertHeaderFromInternalModel(header) : new MetadataFile();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
var items = new List<Rom>();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj),
|
||||
};
|
||||
|
||||
if (obj?.Games?.Rom != null && obj.Games.Rom.Length > 0)
|
||||
if (obj?.Games?.Rom is not null && obj.Games.Rom.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(obj.Games.Rom, ConvertMachineToInternalModel);
|
||||
@@ -32,7 +32,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
{
|
||||
var header = new Data.Models.Metadata.Header();
|
||||
|
||||
if (item.Credits != null)
|
||||
if (item.Credits is not null)
|
||||
{
|
||||
header[Data.Models.Metadata.Header.AuthorKey] = item.Credits.Author;
|
||||
header[Data.Models.Metadata.Header.VersionKey] = item.Credits.Version;
|
||||
@@ -43,7 +43,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
header[Data.Models.Metadata.Header.CommentKey] = item.Credits.Comment;
|
||||
}
|
||||
|
||||
if (item.Dat != null)
|
||||
if (item.Dat is not null)
|
||||
{
|
||||
header[Data.Models.Metadata.Header.DatVersionKey] = item.Dat.Version;
|
||||
header[Data.Models.Metadata.Header.PluginKey] = item.Dat.Plugin;
|
||||
@@ -54,7 +54,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
header[Data.Models.Metadata.Header.ForceMergingKey] = "merge";
|
||||
}
|
||||
|
||||
if (item.Emulator != null)
|
||||
if (item.Emulator is not null)
|
||||
{
|
||||
header[Data.Models.Metadata.Header.RefNameKey] = item.Emulator.RefName;
|
||||
header[Data.Models.Metadata.Header.EmulatorVersionKey] = item.Emulator.Version;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var metadataFile = header != null ? ConvertHeaderFromInternalModel(header) : new MetadataFile();
|
||||
var metadataFile = header is not null ? ConvertHeaderFromInternalModel(header) : new MetadataFile();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
var items = new List<Row>();
|
||||
@@ -46,21 +46,21 @@ namespace SabreTools.Serialization.CrossModel
|
||||
var rowItems = new List<Row>();
|
||||
|
||||
var roms = item.Read<Data.Models.Metadata.Rom[]>(Data.Models.Metadata.Machine.RomKey);
|
||||
if (roms != null && roms.Length > 0)
|
||||
if (roms is not null && roms.Length > 0)
|
||||
{
|
||||
rowItems.AddRange(
|
||||
Array.ConvertAll(roms, r => ConvertFromInternalModel(r, item, header)));
|
||||
}
|
||||
|
||||
var disks = item.Read<Data.Models.Metadata.Disk[]>(Data.Models.Metadata.Machine.DiskKey);
|
||||
if (disks != null && disks.Length > 0)
|
||||
if (disks is not null && disks.Length > 0)
|
||||
{
|
||||
rowItems.AddRange(
|
||||
Array.ConvertAll(disks, d => ConvertFromInternalModel(d, item, header)));
|
||||
}
|
||||
|
||||
var media = item.Read<Data.Models.Metadata.Media[]>(Data.Models.Metadata.Machine.MediaKey);
|
||||
if (media != null && media.Length > 0)
|
||||
if (media is not null && media.Length > 0)
|
||||
{
|
||||
rowItems.AddRange(
|
||||
Array.ConvertAll(media, m => ConvertFromInternalModel(m, item, header)));
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(obj),
|
||||
};
|
||||
|
||||
if (obj?.Row != null && obj.Row.Length > 0)
|
||||
if (obj?.Row is not null && obj.Row.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(obj.Row, ConvertMachineToInternalModel);
|
||||
@@ -35,7 +35,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Header.HeaderKey] = item.Header,
|
||||
};
|
||||
|
||||
if (item.Row != null && item.Row.Length > 0)
|
||||
if (item.Row is not null && item.Row.Length > 0)
|
||||
{
|
||||
var first = item.Row[0];
|
||||
header["FILENAME"] = first.FileName; // TODO: Make this an actual key to retrieve on an item -- OriginalFilename
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace SabreTools.Serialization.CrossModel
|
||||
return null;
|
||||
|
||||
var header = obj.Read<Data.Models.Metadata.Header>(Data.Models.Metadata.MetadataFile.HeaderKey);
|
||||
var metadataFile = header != null ? ConvertHeaderFromInternalModel(header) : new Data.Models.SoftwareList.SoftwareList();
|
||||
var metadataFile = header is not null ? ConvertHeaderFromInternalModel(header) : new Data.Models.SoftwareList.SoftwareList();
|
||||
|
||||
var machines = obj.Read<Data.Models.Metadata.Machine[]>(Data.Models.Metadata.MetadataFile.MachineKey);
|
||||
if (machines != null && machines.Length > 0)
|
||||
if (machines is not null && machines.Length > 0)
|
||||
metadataFile.Software = Array.ConvertAll(machines, ConvertMachineFromInternalModel);
|
||||
|
||||
return metadataFile;
|
||||
@@ -52,15 +52,15 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var infos = item.Read<Data.Models.Metadata.Info[]>(Data.Models.Metadata.Machine.InfoKey);
|
||||
if (infos != null && infos.Length > 0)
|
||||
if (infos is not null && infos.Length > 0)
|
||||
software.Info = Array.ConvertAll(infos, ConvertFromInternalModel);
|
||||
|
||||
var sharedFeats = item.Read<Data.Models.Metadata.SharedFeat[]>(Data.Models.Metadata.Machine.SharedFeatKey);
|
||||
if (sharedFeats != null && sharedFeats.Length > 0)
|
||||
if (sharedFeats is not null && sharedFeats.Length > 0)
|
||||
software.SharedFeat = Array.ConvertAll(sharedFeats, ConvertFromInternalModel);
|
||||
|
||||
var parts = item.Read<Data.Models.Metadata.Part[]>(Data.Models.Metadata.Machine.PartKey);
|
||||
if (parts != null && parts.Length > 0)
|
||||
if (parts is not null && parts.Length > 0)
|
||||
software.Part = Array.ConvertAll(parts, ConvertFromInternalModel);
|
||||
|
||||
return software;
|
||||
@@ -80,7 +80,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var roms = item.Read<Data.Models.Metadata.Rom[]>(Data.Models.Metadata.DataArea.RomKey);
|
||||
if (roms != null && roms.Length > 0)
|
||||
if (roms is not null && roms.Length > 0)
|
||||
dataArea.Rom = Array.ConvertAll(roms, ConvertFromInternalModel);
|
||||
|
||||
return dataArea;
|
||||
@@ -99,7 +99,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var dipValues = item.Read<Data.Models.Metadata.DipValue[]>(Data.Models.Metadata.DipSwitch.DipValueKey);
|
||||
if (dipValues != null && dipValues.Length > 0)
|
||||
if (dipValues is not null && dipValues.Length > 0)
|
||||
dipSwitch.DipValue = Array.ConvertAll(dipValues, ConvertFromInternalModel);
|
||||
|
||||
return dipSwitch;
|
||||
@@ -146,7 +146,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var disks = item.Read<Data.Models.Metadata.Disk[]>(Data.Models.Metadata.DiskArea.DiskKey);
|
||||
if (disks != null && disks.Length > 0)
|
||||
if (disks is not null && disks.Length > 0)
|
||||
diskArea.Disk = Array.ConvertAll(disks, ConvertFromInternalModel);
|
||||
|
||||
return diskArea;
|
||||
@@ -190,19 +190,19 @@ namespace SabreTools.Serialization.CrossModel
|
||||
};
|
||||
|
||||
var features = item.Read<Data.Models.Metadata.Feature[]>(Data.Models.Metadata.Part.FeatureKey);
|
||||
if (features != null && features.Length > 0)
|
||||
if (features is not null && features.Length > 0)
|
||||
part.Feature = Array.ConvertAll(features, ConvertFromInternalModel);
|
||||
|
||||
var dataAreas = item.Read<Data.Models.Metadata.DataArea[]>(Data.Models.Metadata.Part.DataAreaKey);
|
||||
if (dataAreas != null && dataAreas.Length > 0)
|
||||
if (dataAreas is not null && dataAreas.Length > 0)
|
||||
part.DataArea = Array.ConvertAll(dataAreas, ConvertFromInternalModel);
|
||||
|
||||
var diskAreas = item.Read<Data.Models.Metadata.DiskArea[]>(Data.Models.Metadata.Part.DiskAreaKey);
|
||||
if (diskAreas != null && diskAreas.Length > 0)
|
||||
if (diskAreas is not null && diskAreas.Length > 0)
|
||||
part.DiskArea = Array.ConvertAll(diskAreas, ConvertFromInternalModel);
|
||||
|
||||
var dipSwitches = item.Read<Data.Models.Metadata.DipSwitch[]>(Data.Models.Metadata.Part.DipSwitchKey);
|
||||
if (dipSwitches != null && dipSwitches.Length > 0)
|
||||
if (dipSwitches is not null && dipSwitches.Length > 0)
|
||||
part.DipSwitch = Array.ConvertAll(dipSwitches, ConvertFromInternalModel);
|
||||
|
||||
return part;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.MetadataFile.HeaderKey] = ConvertHeaderToInternalModel(item),
|
||||
};
|
||||
|
||||
if (item?.Software != null && item.Software.Length > 0)
|
||||
if (item?.Software is not null && item.Software.Length > 0)
|
||||
{
|
||||
metadataFile[Data.Models.Metadata.MetadataFile.MachineKey]
|
||||
= Array.ConvertAll(item.Software, ConvertMachineToInternalModel);
|
||||
@@ -55,13 +55,13 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Machine.NotesKey] = item.Notes,
|
||||
};
|
||||
|
||||
if (item.Info != null && item.Info.Length > 0)
|
||||
if (item.Info is not null && item.Info.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.InfoKey] = Array.ConvertAll(item.Info, ConvertToInternalModel);
|
||||
|
||||
if (item.SharedFeat != null && item.SharedFeat.Length > 0)
|
||||
if (item.SharedFeat is not null && item.SharedFeat.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.SharedFeatKey] = Array.ConvertAll(item.SharedFeat, ConvertToInternalModel);
|
||||
|
||||
if (item.Part != null && item.Part.Length > 0)
|
||||
if (item.Part is not null && item.Part.Length > 0)
|
||||
machine[Data.Models.Metadata.Machine.PartKey] = Array.ConvertAll(item.Part, ConvertToInternalModel);
|
||||
|
||||
return machine;
|
||||
@@ -80,7 +80,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.DataArea.EndiannessKey] = item.Endianness,
|
||||
};
|
||||
|
||||
if (item.Rom != null && item.Rom.Length > 0)
|
||||
if (item.Rom is not null && item.Rom.Length > 0)
|
||||
dataArea[Data.Models.Metadata.DataArea.RomKey] = Array.ConvertAll(item.Rom, ConvertToInternalModel);
|
||||
|
||||
return dataArea;
|
||||
@@ -98,7 +98,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.DipSwitch.MaskKey] = item.Mask,
|
||||
};
|
||||
|
||||
if (item.DipValue != null && item.DipValue.Length > 0)
|
||||
if (item.DipValue is not null && item.DipValue.Length > 0)
|
||||
dipSwitch[Data.Models.Metadata.DipSwitch.DipValueKey] = Array.ConvertAll(item.DipValue, ConvertToInternalModel);
|
||||
|
||||
return dipSwitch;
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.DiskArea.NameKey] = item.Name,
|
||||
};
|
||||
|
||||
if (item.Disk != null && item.Disk.Length > 0)
|
||||
if (item.Disk is not null && item.Disk.Length > 0)
|
||||
diskArea[Data.Models.Metadata.DiskArea.DiskKey] = Array.ConvertAll(item.Disk, ConvertToInternalModel);
|
||||
|
||||
return diskArea;
|
||||
@@ -187,16 +187,16 @@ namespace SabreTools.Serialization.CrossModel
|
||||
[Data.Models.Metadata.Part.InterfaceKey] = item.Interface,
|
||||
};
|
||||
|
||||
if (item.Feature != null && item.Feature.Length > 0)
|
||||
if (item.Feature is not null && item.Feature.Length > 0)
|
||||
part[Data.Models.Metadata.Part.FeatureKey] = Array.ConvertAll(item.Feature, ConvertToInternalModel);
|
||||
|
||||
if (item.DataArea != null && item.DataArea.Length > 0)
|
||||
if (item.DataArea is not null && item.DataArea.Length > 0)
|
||||
part[Data.Models.Metadata.Part.DataAreaKey] = Array.ConvertAll(item.DataArea, ConvertToInternalModel);
|
||||
|
||||
if (item.DiskArea != null && item.DiskArea.Length > 0)
|
||||
if (item.DiskArea is not null && item.DiskArea.Length > 0)
|
||||
part[Data.Models.Metadata.Part.DiskAreaKey] = Array.ConvertAll(item.DiskArea, ConvertToInternalModel);
|
||||
|
||||
if (item.DipSwitch != null && item.DipSwitch.Length > 0)
|
||||
if (item.DipSwitch is not null && item.DipSwitch.Length > 0)
|
||||
part[Data.Models.Metadata.Part.DipSwitchKey] = Array.ConvertAll(item.DipSwitch, ConvertToInternalModel);
|
||||
|
||||
return part;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace SabreTools.Data.Extensions
|
||||
|
||||
// If the RVA matches a section start exactly, use that
|
||||
var matchingSection = Array.Find(sections, s => s.VirtualAddress == rva);
|
||||
if (matchingSection != null)
|
||||
if (matchingSection is not null)
|
||||
return rva - matchingSection.VirtualAddress + matchingSection.PointerToRawData;
|
||||
|
||||
// Loop through all of the sections
|
||||
@@ -1009,7 +1009,7 @@ namespace SabreTools.Data.Extensions
|
||||
while (offset < entry.Data.Length)
|
||||
{
|
||||
string? stringValue = entry.Data.ReadPrefixedUnicodeString(ref offset);
|
||||
if (stringValue != null)
|
||||
if (stringValue is not null)
|
||||
{
|
||||
stringValue = stringValue.Replace("\n", "\\n").Replace("\r", newValue: "\\r");
|
||||
stringTable[stringIndex++] = stringValue;
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, char[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, c => c.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -299,7 +299,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, short[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, s => s.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -317,7 +317,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ushort[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, u => u.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -335,7 +335,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, int[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, i => i.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -353,7 +353,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, uint[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, u => u.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -371,7 +371,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, float[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, u => u.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -389,7 +389,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, long[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, l => l.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -407,7 +407,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, ulong[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, u => u.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -425,7 +425,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, double[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, u => u.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
@@ -443,7 +443,7 @@ namespace SabreTools.Data.Extensions
|
||||
public static StringBuilder AppendLine(this StringBuilder sb, Guid[]? value, string prefixString)
|
||||
{
|
||||
string valueString = "[NULL]";
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
{
|
||||
var valueArr = Array.ConvertAll(value, g => g.ToString());
|
||||
valueString = string.Join(", ", valueArr);
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return null;
|
||||
|
||||
bool? asBool = Read<bool?>(key);
|
||||
if (asBool != null)
|
||||
if (asBool is not null)
|
||||
return asBool;
|
||||
|
||||
string? asString = Read<string>(key);
|
||||
@@ -56,11 +56,11 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return null;
|
||||
|
||||
double? asDouble = Read<double?>(key);
|
||||
if (asDouble != null)
|
||||
if (asDouble is not null)
|
||||
return asDouble;
|
||||
|
||||
string? asString = Read<string>(key);
|
||||
if (asString != null && double.TryParse(asString, out double asStringDouble))
|
||||
if (asString is not null && double.TryParse(asString, out double asStringDouble))
|
||||
return asStringDouble;
|
||||
|
||||
return null;
|
||||
@@ -76,11 +76,11 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return null;
|
||||
|
||||
long? asLong = Read<long?>(key);
|
||||
if (asLong != null)
|
||||
if (asLong is not null)
|
||||
return asLong;
|
||||
|
||||
string? asString = Read<string>(key);
|
||||
if (asString != null && long.TryParse(asString, out long asStringLong))
|
||||
if (asString is not null && long.TryParse(asString, out long asStringLong))
|
||||
return asStringLong;
|
||||
|
||||
return null;
|
||||
@@ -95,11 +95,11 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return null;
|
||||
|
||||
string? asString = Read<string>(key);
|
||||
if (asString != null)
|
||||
if (asString is not null)
|
||||
return asString;
|
||||
|
||||
string[]? asArray = Read<string[]>(key);
|
||||
if (asArray != null)
|
||||
if (asArray is not null)
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0
|
||||
return string.Join(",", asArray);
|
||||
#else
|
||||
@@ -121,15 +121,15 @@ namespace SabreTools.Data.Models.Metadata
|
||||
return null;
|
||||
|
||||
string[]? asArray = Read<string[]>(key);
|
||||
if (asArray != null)
|
||||
if (asArray is not null)
|
||||
return asArray;
|
||||
|
||||
string? asString = Read<string>(key);
|
||||
if (asString != null)
|
||||
if (asString is not null)
|
||||
return [asString];
|
||||
|
||||
asString = this[key]!.ToString();
|
||||
if (asString != null)
|
||||
if (asString is not null)
|
||||
return [asString];
|
||||
|
||||
return null;
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < currentIndex + (long)obj.Length)
|
||||
{
|
||||
var value = ParseTypeLengthValue(data);
|
||||
if (value != null)
|
||||
if (value is not null)
|
||||
valueList.Add(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace SabreTools.Serialization.Readers
|
||||
break;
|
||||
case LumpType.LUMP_VISIBILITY:
|
||||
var visiblityLump = ParseVisibilityLump(data, lumpEntry.Offset, lumpEntry.Length);
|
||||
if (visiblityLump != null)
|
||||
if (visiblityLump is not null)
|
||||
file.VisibilityLump = visiblityLump;
|
||||
|
||||
break;
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace SabreTools.Serialization.Readers
|
||||
var difatSectors = new List<SectorNumber>();
|
||||
|
||||
// Add the sectors from the header
|
||||
if (fileHeader.DIFAT != null)
|
||||
if (fileHeader.DIFAT is not null)
|
||||
difatSectors.AddRange(fileHeader.DIFAT);
|
||||
|
||||
// Loop through and add the DIFAT sectors
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace SabreTools.Serialization.Readers
|
||||
case "machine":
|
||||
case "resource":
|
||||
case "set":
|
||||
if (game != null)
|
||||
if (game is not null)
|
||||
{
|
||||
game.Release = [.. releases];
|
||||
game.BiosSet = [.. biosSets];
|
||||
@@ -298,7 +298,7 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
case "source":
|
||||
string? source = reader.Standalone?.Value;
|
||||
if (source != null)
|
||||
if (source is not null)
|
||||
sources.Add(source);
|
||||
|
||||
break;
|
||||
@@ -310,7 +310,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|| reader.TopLevel == "machine"
|
||||
|| reader.TopLevel == "resource"
|
||||
|| reader.TopLevel == "set")
|
||||
&& game != null
|
||||
&& game is not null
|
||||
&& reader.RowType == CmpRowType.Internal)
|
||||
{
|
||||
// Create the block
|
||||
@@ -318,67 +318,67 @@ namespace SabreTools.Serialization.Readers
|
||||
{
|
||||
case "release":
|
||||
var release = CreateRelease(reader);
|
||||
if (release != null)
|
||||
if (release is not null)
|
||||
releases.Add(release);
|
||||
break;
|
||||
case "biosset":
|
||||
var biosSet = CreateBiosSet(reader);
|
||||
if (biosSet != null)
|
||||
if (biosSet is not null)
|
||||
biosSets.Add(biosSet);
|
||||
break;
|
||||
case "rom":
|
||||
var rom = CreateRom(reader);
|
||||
if (rom != null)
|
||||
if (rom is not null)
|
||||
roms.Add(rom);
|
||||
break;
|
||||
case "disk":
|
||||
var disk = CreateDisk(reader);
|
||||
if (disk != null)
|
||||
if (disk is not null)
|
||||
disks.Add(disk);
|
||||
break;
|
||||
case "media":
|
||||
var media = CreateMedia(reader);
|
||||
if (media != null)
|
||||
if (media is not null)
|
||||
medias.Add(media);
|
||||
break;
|
||||
case "sample":
|
||||
var sample = CreateSample(reader);
|
||||
if (sample != null)
|
||||
if (sample is not null)
|
||||
samples.Add(sample);
|
||||
break;
|
||||
case "archive":
|
||||
var archive = CreateArchive(reader);
|
||||
if (archive != null)
|
||||
if (archive is not null)
|
||||
archives.Add(archive);
|
||||
break;
|
||||
case "chip":
|
||||
var chip = CreateChip(reader);
|
||||
if (chip != null)
|
||||
if (chip is not null)
|
||||
chips.Add(chip);
|
||||
break;
|
||||
case "video":
|
||||
var video = CreateVideo(reader);
|
||||
if (video != null)
|
||||
if (video is not null)
|
||||
videos.Add(video);
|
||||
break;
|
||||
case "sound":
|
||||
var sound = CreateSound(reader);
|
||||
if (sound != null)
|
||||
if (sound is not null)
|
||||
game.Sound = sound;
|
||||
break;
|
||||
case "input":
|
||||
var input = CreateInput(reader);
|
||||
if (input != null)
|
||||
if (input is not null)
|
||||
game.Input = input;
|
||||
break;
|
||||
case "dipswitch":
|
||||
var dipSwitch = CreateDipSwitch(reader);
|
||||
if (dipSwitch != null)
|
||||
if (dipSwitch is not null)
|
||||
dipSwitches.Add(dipSwitch);
|
||||
break;
|
||||
case "driver":
|
||||
var driver = CreateDriver(reader);
|
||||
if (driver != null)
|
||||
if (driver is not null)
|
||||
game.Driver = driver;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace SabreTools.Serialization.Readers
|
||||
switch (lastTopLevel)
|
||||
{
|
||||
case "game":
|
||||
if (game != null)
|
||||
if (game is not null)
|
||||
{
|
||||
game.File = [.. files];
|
||||
games.Add(game);
|
||||
@@ -127,7 +127,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Create the file and add to the list
|
||||
var file = CreateFile(reader);
|
||||
if (file != null)
|
||||
if (file is not null)
|
||||
files.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -473,7 +473,7 @@ namespace SabreTools.Serialization.Readers
|
||||
}
|
||||
|
||||
// If no valid path tables were found, don't add the table group
|
||||
if (groupL.PathTableL != null || groupL.OptionalPathTableL != null || groupL.PathTableM != null || groupL.OptionalPathTableM != null)
|
||||
if (groupL.PathTableL is not null || groupL.OptionalPathTableL is not null || groupL.PathTableM is not null || groupL.OptionalPathTableM is not null)
|
||||
groups.Add(groupL);
|
||||
|
||||
// If the both-endian path table size value is consistent, return the single path table group
|
||||
@@ -504,7 +504,7 @@ namespace SabreTools.Serialization.Readers
|
||||
}
|
||||
|
||||
// If no valid path tables were found, don't add the table group
|
||||
if (groupB.PathTableL != null || groupB.OptionalPathTableL != null || groupB.PathTableM != null || groupB.OptionalPathTableM != null)
|
||||
if (groupB.PathTableL is not null || groupB.OptionalPathTableL is not null || groupB.PathTableM is not null || groupB.OptionalPathTableM is not null)
|
||||
groups.Add(groupB);
|
||||
|
||||
return groups;
|
||||
@@ -743,7 +743,7 @@ namespace SabreTools.Serialization.Readers
|
||||
if (dr.ExtendedAttributeRecordLength > 0)
|
||||
{
|
||||
var ear = ParseExtendedAttributeRecord(data);
|
||||
if (ear != null)
|
||||
if (ear is not null)
|
||||
{
|
||||
fileExtent.ExtendedAttributeRecord = ear;
|
||||
}
|
||||
@@ -759,7 +759,7 @@ namespace SabreTools.Serialization.Readers
|
||||
if (!bigEndian && dr.ExtentLocation.IsValid)
|
||||
{
|
||||
var bigEndianDir = ParseDirectory(data, sectorLength, blockLength, dr, true);
|
||||
if (bigEndianDir != null)
|
||||
if (bigEndianDir is not null)
|
||||
{
|
||||
// Add new directories to dictionary
|
||||
foreach (var kvp in bigEndianDir)
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Create and add the file descriptor
|
||||
string? directoryName = ParseDirectoryName(data, majorVersion);
|
||||
if (directoryName != null)
|
||||
if (directoryName is not null)
|
||||
cabinet.DirectoryNames[i] = directoryName;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (true)
|
||||
{
|
||||
var bundle = ParseEntryTableBundle(data);
|
||||
if (bundle != null)
|
||||
if (bundle is not null)
|
||||
entryTable.Add(bundle);
|
||||
|
||||
// If we have a 0-length entry
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace SabreTools.Serialization.Readers
|
||||
if (string.IsNullOrEmpty(line))
|
||||
{
|
||||
// If we have a set to process
|
||||
if (set != null)
|
||||
if (set is not null)
|
||||
{
|
||||
set.Row = [.. rows];
|
||||
sets.Add(set);
|
||||
@@ -225,12 +225,12 @@ namespace SabreTools.Serialization.Readers
|
||||
break;
|
||||
}
|
||||
|
||||
if (row != null)
|
||||
if (row is not null)
|
||||
rows.Add(row);
|
||||
}
|
||||
|
||||
// If we have a set to process
|
||||
if (set != null)
|
||||
if (set is not null)
|
||||
{
|
||||
set.Row = [.. rows];
|
||||
sets.Add(set);
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Set the hash table, if possible
|
||||
var hashTable = ParseHashTable(data, initialOffset, archive.ArchiveHeader, decrypter);
|
||||
if (hashTable != null)
|
||||
if (hashTable is not null)
|
||||
archive.HashTable = hashTable;
|
||||
|
||||
#endregion
|
||||
@@ -73,7 +73,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Set the block table, if possible
|
||||
var blockTable = ParseBlockTable(data, initialOffset, archive.ArchiveHeader, decrypter);
|
||||
if (blockTable != null)
|
||||
if (blockTable is not null)
|
||||
archive.BlockTable = blockTable;
|
||||
|
||||
#endregion
|
||||
@@ -82,7 +82,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Set the hi-block table, if possible
|
||||
var hiBlockTable = ParseHiBlockTable(data, initialOffset, archive.ArchiveHeader);
|
||||
if (hiBlockTable != null)
|
||||
if (hiBlockTable is not null)
|
||||
archive.HiBlockTable = hiBlockTable;
|
||||
|
||||
#endregion
|
||||
@@ -91,7 +91,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Set the BET table, if possible
|
||||
var betTable = ParseBetTable(data, initialOffset, archive.ArchiveHeader, decrypter);
|
||||
if (betTable != null)
|
||||
if (betTable is not null)
|
||||
archive.BetTable = betTable;
|
||||
|
||||
#endregion
|
||||
@@ -100,7 +100,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Set the HET table, if possible
|
||||
var hetTable = ParseHetTable(data, initialOffset, archive.ArchiveHeader, decrypter);
|
||||
if (hetTable != null)
|
||||
if (hetTable is not null)
|
||||
archive.HetTable = hetTable;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Cache the media unit size for further use
|
||||
long mediaUnitSize = 0;
|
||||
if (header.PartitionFlags != null)
|
||||
if (header.PartitionFlags is not null)
|
||||
mediaUnitSize = (uint)(0x200 * Math.Pow(2, header.PartitionFlags[(int)NCSDFlags.MediaUnitSize]));
|
||||
|
||||
#region Partitions
|
||||
|
||||
@@ -418,7 +418,7 @@ namespace SabreTools.Serialization.Readers
|
||||
obj.LocalFileHeader = localFileHeader;
|
||||
|
||||
ulong compressedSize = localFileHeader.CompressedSize;
|
||||
if (localFileHeader.ExtraFields != null)
|
||||
if (localFileHeader.ExtraFields is not null)
|
||||
{
|
||||
foreach (var field in localFileHeader.ExtraFields)
|
||||
{
|
||||
@@ -660,7 +660,7 @@ namespace SabreTools.Serialization.Readers
|
||||
_ => ParseUnknownExtraField(data, ref offset),
|
||||
};
|
||||
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
fields.Add(field);
|
||||
}
|
||||
|
||||
@@ -751,7 +751,7 @@ namespace SabreTools.Serialization.Readers
|
||||
_ => ParseUnknownExtraField(data, ref offset),
|
||||
};
|
||||
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
fields.Add(field);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace SabreTools.Serialization.Readers
|
||||
uint? unknownOffset2 = (audioHeader as AudioHeaderV1)?.UnknownOffset2;
|
||||
|
||||
// If we have an unknown value 2 offset
|
||||
if (unknownOffset2 != null && unknownOffset2 > 0)
|
||||
if (unknownOffset2 is not null && unknownOffset2 > 0)
|
||||
{
|
||||
// Get the unknown value 2 offset
|
||||
long offset = initialOffset + unknownOffset2.Value;
|
||||
@@ -96,7 +96,7 @@ namespace SabreTools.Serialization.Readers
|
||||
uint? unknownOffset3 = (audioHeader as AudioHeaderV1)?.UnknownOffset3;
|
||||
|
||||
// If we have an unknown block 3 offset
|
||||
if (unknownOffset3 != null && unknownOffset3 > 0)
|
||||
if (unknownOffset3 is not null && unknownOffset3 > 0)
|
||||
{
|
||||
// Get the unknown block 3 offset
|
||||
long offset = initialOffset + unknownOffset3.Value;
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace SabreTools.Serialization.Readers
|
||||
optionalHeader = ParseOptionalHeader(data, fileHeader.SizeOfOptionalHeader);
|
||||
|
||||
// Set the optional header
|
||||
if (optionalHeader != null)
|
||||
if (optionalHeader is not null)
|
||||
pex.OptionalHeader = optionalHeader;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace SabreTools.Serialization.Readers
|
||||
#region Export Table
|
||||
|
||||
// Should also be in a '.edata' section
|
||||
if (optionalHeader.ExportTable != null)
|
||||
if (optionalHeader.ExportTable is not null)
|
||||
{
|
||||
offset = initialOffset
|
||||
+ optionalHeader.ExportTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable);
|
||||
@@ -153,7 +153,7 @@ namespace SabreTools.Serialization.Readers
|
||||
pex.ExportDirectoryTable = exportDirectoryTable;
|
||||
|
||||
// If the export table was parsed, read the remaining pieces
|
||||
if (exportDirectoryTable != null)
|
||||
if (exportDirectoryTable is not null)
|
||||
{
|
||||
// Name
|
||||
offset = initialOffset + exportDirectoryTable.NameRVA.ConvertVirtualAddress(pex.SectionTable);
|
||||
@@ -194,7 +194,7 @@ namespace SabreTools.Serialization.Readers
|
||||
}
|
||||
|
||||
// Name table
|
||||
if (exportDirectoryTable.NumberOfNamePointers != 0 && pex.NamePointerTable?.Pointers != null)
|
||||
if (exportDirectoryTable.NumberOfNamePointers != 0 && pex.NamePointerTable?.Pointers is not null)
|
||||
pex.ExportNameTable = ParseExportNameTable(data, initialOffset, pex.NamePointerTable.Pointers, pex.SectionTable);
|
||||
}
|
||||
}
|
||||
@@ -205,7 +205,7 @@ namespace SabreTools.Serialization.Readers
|
||||
#region Import Table
|
||||
|
||||
// Should also be in a '.idata' section
|
||||
if (optionalHeader.ImportTable != null)
|
||||
if (optionalHeader.ImportTable is not null)
|
||||
{
|
||||
offset = initialOffset
|
||||
+ optionalHeader.ImportTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable);
|
||||
@@ -225,7 +225,7 @@ namespace SabreTools.Serialization.Readers
|
||||
pex.ImportDirectoryTable = importDirectoryTable;
|
||||
|
||||
// If the export table was parsed, read the remaining pieces
|
||||
if (pex.ImportDirectoryTable != null)
|
||||
if (pex.ImportDirectoryTable is not null)
|
||||
{
|
||||
// Names
|
||||
for (int i = 0; i < importDirectoryTable.Length; i++)
|
||||
@@ -252,7 +252,7 @@ namespace SabreTools.Serialization.Readers
|
||||
}
|
||||
|
||||
// If an error was not encountered, read the remaining tables
|
||||
if (pex.ImportDirectoryTable != null)
|
||||
if (pex.ImportDirectoryTable is not null)
|
||||
{
|
||||
pex.ImportLookupTables = ParseImportLookupTables(data,
|
||||
initialOffset,
|
||||
@@ -275,7 +275,7 @@ namespace SabreTools.Serialization.Readers
|
||||
}
|
||||
|
||||
// TODO: Figure out how to use this in lieu of the current ParseImportAddressTables
|
||||
if (optionalHeader.ImportAddressTable != null)
|
||||
if (optionalHeader.ImportAddressTable is not null)
|
||||
{
|
||||
offset = initialOffset
|
||||
+ optionalHeader.ImportAddressTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable);
|
||||
@@ -297,7 +297,7 @@ namespace SabreTools.Serialization.Readers
|
||||
#region Resource Directory Table
|
||||
|
||||
// Should also be in a '.rsrc' section
|
||||
if (optionalHeader.ResourceTable != null)
|
||||
if (optionalHeader.ResourceTable is not null)
|
||||
{
|
||||
offset = initialOffset
|
||||
+ optionalHeader.ResourceTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable);
|
||||
@@ -331,7 +331,7 @@ namespace SabreTools.Serialization.Readers
|
||||
#region Hidden Resources
|
||||
|
||||
// If we have not used up the full size, parse the remaining chunk as a single resource
|
||||
if (pex.ResourceDirectoryTable?.Entries != null
|
||||
if (pex.ResourceDirectoryTable?.Entries is not null
|
||||
&& tableOffset < tableSize
|
||||
&& (offset + tableOffset) != endOfSectionData)
|
||||
{
|
||||
@@ -368,7 +368,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
#region Certificate Table
|
||||
|
||||
if (optionalHeader.CertificateTable != null)
|
||||
if (optionalHeader.CertificateTable is not null)
|
||||
{
|
||||
// The Certificate Table entry points to a table of attribute certificates. These
|
||||
// certificates are not loaded into memory as part of the image. As such, the first
|
||||
@@ -392,7 +392,7 @@ namespace SabreTools.Serialization.Readers
|
||||
#region Base Relocation Table
|
||||
|
||||
// Should also be in a '.reloc' section
|
||||
if (optionalHeader.BaseRelocationTable != null)
|
||||
if (optionalHeader.BaseRelocationTable is not null)
|
||||
{
|
||||
offset = initialOffset
|
||||
+ optionalHeader.BaseRelocationTable.VirtualAddress.ConvertVirtualAddress(pex.SectionTable);
|
||||
@@ -414,7 +414,7 @@ namespace SabreTools.Serialization.Readers
|
||||
#region Debug Table
|
||||
|
||||
// Should also be in a '.debug' section
|
||||
if (optionalHeader.Debug != null)
|
||||
if (optionalHeader.Debug is not null)
|
||||
{
|
||||
offset = initialOffset
|
||||
+ optionalHeader.Debug.VirtualAddress.ConvertVirtualAddress(pex.SectionTable);
|
||||
@@ -442,7 +442,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
#region Delay-Load Directory Table
|
||||
|
||||
if (optionalHeader.DelayImportDescriptor != null)
|
||||
if (optionalHeader.DelayImportDescriptor is not null)
|
||||
{
|
||||
offset = initialOffset
|
||||
+ optionalHeader.DelayImportDescriptor.VirtualAddress.ConvertVirtualAddress(pex.SectionTable);
|
||||
@@ -1018,7 +1018,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
obj.Hint = data.ReadUInt16LittleEndian();
|
||||
string? name = data.ReadNullTerminatedAnsiString();
|
||||
if (name != null)
|
||||
if (name is not null)
|
||||
obj.Name = name;
|
||||
|
||||
return obj;
|
||||
@@ -1451,7 +1451,7 @@ namespace SabreTools.Serialization.Readers
|
||||
foreach (var entry in table.Entries)
|
||||
{
|
||||
// Handle directory entries directly
|
||||
if (entry.DataEntry != null && entry.DataEntry.Size > 0)
|
||||
if (entry.DataEntry is not null && entry.DataEntry.Size > 0)
|
||||
{
|
||||
// Convert the data RVA to an offset
|
||||
long nextOffset = entry.DataEntry.DataRVA.ConvertVirtualAddress(sections);
|
||||
@@ -1469,13 +1469,13 @@ namespace SabreTools.Serialization.Readers
|
||||
else if (nextOffset + entry.DataEntry.Size <= data.Length)
|
||||
{
|
||||
byte[]? entryData = data.ReadFrom(nextOffset + initialOffset, (int)entry.DataEntry.Size, retainPosition: true);
|
||||
if (entryData != null)
|
||||
if (entryData is not null)
|
||||
entry.DataEntry.Data = entryData;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle subdirectories by recursion
|
||||
else if (entry.Subdirectory != null)
|
||||
else if (entry.Subdirectory is not null)
|
||||
{
|
||||
ParseResourceData(data,
|
||||
initialOffset,
|
||||
@@ -1720,13 +1720,13 @@ namespace SabreTools.Serialization.Readers
|
||||
nextSymbolType = 3;
|
||||
}
|
||||
else if (obj.StorageClass == StorageClass.IMAGE_SYM_CLASS_FILE
|
||||
&& shortName != null)
|
||||
&& shortName is not null)
|
||||
{
|
||||
// Symbol name should be ".file"
|
||||
nextSymbolType = 4;
|
||||
}
|
||||
else if (obj.StorageClass == StorageClass.IMAGE_SYM_CLASS_STATIC
|
||||
&& shortName != null)
|
||||
&& shortName is not null)
|
||||
{
|
||||
// Should have the name of a section (like ".text")
|
||||
nextSymbolType = 5;
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace SabreTools.Serialization.Readers
|
||||
}
|
||||
|
||||
// Add extra pieces and return
|
||||
if (dat.Games != null && roms.Count > 0)
|
||||
if (dat.Games is not null && roms.Count > 0)
|
||||
{
|
||||
dat.Games.Rom = [.. roms];
|
||||
return dat;
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var plane = data.ReadType<Plane>();
|
||||
if (plane != null)
|
||||
if (plane is not null)
|
||||
planes.Add(plane);
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var texdata = data.ReadType<Texdata>();
|
||||
if (texdata != null)
|
||||
if (texdata is not null)
|
||||
texdatas.Add(texdata);
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var node = data.ReadType<VbspNode>();
|
||||
if (node != null)
|
||||
if (node is not null)
|
||||
nodes.Add(node);
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var texinfo = data.ReadType<VbspTexinfo>();
|
||||
if (texinfo != null)
|
||||
if (texinfo is not null)
|
||||
texinfos.Add(texinfo);
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var face = data.ReadType<VbspFace>();
|
||||
if (face != null)
|
||||
if (face is not null)
|
||||
faces.Add(face);
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var model = ParsePhysModel(data);
|
||||
if (model != null)
|
||||
if (model is not null)
|
||||
models.Add(model);
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ namespace SabreTools.Serialization.Readers
|
||||
for (int i = 0; i < model.Solids.Length; i++)
|
||||
{
|
||||
var solid = ParsePhysSolid(data);
|
||||
if (solid != null)
|
||||
if (solid is not null)
|
||||
model.Solids[i] = solid;
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ namespace SabreTools.Serialization.Readers
|
||||
for (int i = 0; i < lump.Count; i++)
|
||||
{
|
||||
var occluderData = data.ReadType<OccluderData>();
|
||||
if (occluderData != null)
|
||||
if (occluderData is not null)
|
||||
lump.Data[i] = occluderData;
|
||||
}
|
||||
lump.PolyDataCount = data.ReadInt32LittleEndian();
|
||||
@@ -577,7 +577,7 @@ namespace SabreTools.Serialization.Readers
|
||||
for (int i = 0; i < lump.Count; i++)
|
||||
{
|
||||
var polyData = data.ReadType<OccluderPolyData>();
|
||||
if (polyData != null)
|
||||
if (polyData is not null)
|
||||
lump.PolyData[i] = polyData;
|
||||
}
|
||||
lump.VertexIndexCount = data.ReadInt32LittleEndian();
|
||||
@@ -601,7 +601,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var leaf = ParseVbspLeaf(data, version);
|
||||
if (leaf != null)
|
||||
if (leaf is not null)
|
||||
leaves.Add(leaf);
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var edge = data.ReadType<Edge>();
|
||||
if (edge != null)
|
||||
if (edge is not null)
|
||||
edges.Add(edge);
|
||||
}
|
||||
|
||||
@@ -705,7 +705,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var model = data.ReadType<VbspModel>();
|
||||
if (model != null)
|
||||
if (model is not null)
|
||||
models.Add(model);
|
||||
}
|
||||
|
||||
@@ -723,7 +723,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var worldLight = data.ReadType<WorldLight>();
|
||||
if (worldLight != null)
|
||||
if (worldLight is not null)
|
||||
worldLights.Add(worldLight);
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var brush = data.ReadType<Brush>();
|
||||
if (brush != null)
|
||||
if (brush is not null)
|
||||
brushes.Add(brush);
|
||||
}
|
||||
|
||||
@@ -791,7 +791,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var brushside = data.ReadType<Brushside>();
|
||||
if (brushside != null)
|
||||
if (brushside is not null)
|
||||
brushsides.Add(brushside);
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var dispInfo = data.ReadType<DispInfo>();
|
||||
if (dispInfo != null)
|
||||
if (dispInfo is not null)
|
||||
dispInfos.Add(dispInfo);
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var vert = data.ReadType<DispVert>();
|
||||
if (vert != null)
|
||||
if (vert is not null)
|
||||
verts.Add(vert);
|
||||
}
|
||||
|
||||
@@ -848,7 +848,7 @@ namespace SabreTools.Serialization.Readers
|
||||
for (int i = 0; i < lump.LumpCount; i++)
|
||||
{
|
||||
var dir = data.ReadType<GameLumpDirectory>();
|
||||
if (dir != null)
|
||||
if (dir is not null)
|
||||
lump.Directories[i] = dir;
|
||||
}
|
||||
|
||||
@@ -866,7 +866,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var cubemap = data.ReadType<Cubemap>();
|
||||
if (cubemap != null)
|
||||
if (cubemap is not null)
|
||||
cubemaps.Add(cubemap);
|
||||
}
|
||||
|
||||
@@ -898,7 +898,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var str = data.ReadNullTerminatedAnsiString();
|
||||
if (str != null)
|
||||
if (str is not null)
|
||||
strings.Add(str);
|
||||
}
|
||||
|
||||
@@ -932,7 +932,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var overlay = data.ReadType<Overlay>();
|
||||
if (overlay != null)
|
||||
if (overlay is not null)
|
||||
overlays.Add(overlay);
|
||||
}
|
||||
|
||||
@@ -950,7 +950,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var tri = data.ReadType<DispTri>();
|
||||
if (tri != null)
|
||||
if (tri is not null)
|
||||
tris.Add(tri);
|
||||
}
|
||||
|
||||
@@ -968,7 +968,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var index = data.ReadType<LeafAmbientIndex>();
|
||||
if (index != null)
|
||||
if (index is not null)
|
||||
indicies.Add(index);
|
||||
}
|
||||
|
||||
@@ -986,7 +986,7 @@ namespace SabreTools.Serialization.Readers
|
||||
while (data.Position < offset + length)
|
||||
{
|
||||
var lighting = data.ReadType<LeafAmbientLighting>();
|
||||
if (lighting != null)
|
||||
if (lighting is not null)
|
||||
lightings.Add(lighting);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace SabreTools.Serialization.Readers
|
||||
#region Archive Hashes
|
||||
|
||||
if (header?.Version == 2
|
||||
&& file.ExtendedHeader != null
|
||||
&& file.ExtendedHeader is not null
|
||||
&& file.ExtendedHeader.ArchiveMD5SectionSize > 0
|
||||
&& data.Position + file.ExtendedHeader.ArchiveMD5SectionSize <= data.Length)
|
||||
{
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Try to parse the file entry
|
||||
var fileEntry = ParseFileEntry(data, dirEntry.Type);
|
||||
if (fileEntry != null)
|
||||
if (fileEntry is not null)
|
||||
file.FileEntries[i] = fileEntry;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Readers
|
||||
var overlayHeader = ParseOverlayHeader(data);
|
||||
|
||||
// DllName
|
||||
if (overlayHeader.DllName != null && overlayHeader.DllName.IndexOfAny(Path.GetInvalidFileNameChars()) > 0)
|
||||
if (overlayHeader.DllName is not null && overlayHeader.DllName.IndexOfAny(Path.GetInvalidFileNameChars()) > 0)
|
||||
return null;
|
||||
|
||||
// WiseColors.dib
|
||||
|
||||
@@ -69,9 +69,9 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(current, SeekOrigin.Begin);
|
||||
|
||||
// If the strings are valid
|
||||
if ((ftpUrl != null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath != null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont != null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
&& !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0))
|
||||
{
|
||||
// TODO: Figure out if this maps to existing fields
|
||||
@@ -92,9 +92,9 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(current, SeekOrigin.Begin);
|
||||
|
||||
// If the strings are valid
|
||||
if ((ftpUrl != null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath != null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont != null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
&& !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0))
|
||||
{
|
||||
header.Flags = data.ReadByteValue();
|
||||
@@ -117,9 +117,9 @@ namespace SabreTools.Serialization.Readers
|
||||
data.SeekIfPossible(current, SeekOrigin.Begin);
|
||||
|
||||
// If the strings are valid
|
||||
if ((ftpUrl != null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath != null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont != null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
if ((ftpUrl is not null && (ftpUrl.Length == 0 || ftpUrl.Split('.').Length > 2))
|
||||
&& (logPath is not null && (logPath.Length == 0 || logPath.StartsWith("%")))
|
||||
&& (messageFont is not null && (messageFont.Length == 0 || !IsTypicalControlCode(messageFont, strict: true)))
|
||||
&& !(ftpUrl.Length == 0 && logPath.Length == 0 && messageFont.Length == 0))
|
||||
{
|
||||
header.Flags = data.ReadByteValue();
|
||||
@@ -174,7 +174,7 @@ namespace SabreTools.Serialization.Readers
|
||||
|
||||
// Try to read the next block as an install file call
|
||||
var maybeInstall = ParseInstallFile(data, header.LanguageCount);
|
||||
if (maybeInstall != null
|
||||
if (maybeInstall is not null
|
||||
&& (maybeInstall.DeflateEnd - maybeInstall.DeflateStart) < data.Length
|
||||
&& (maybeInstall.DeflateEnd - maybeInstall.DeflateStart) < maybeInstall.InflatedSize)
|
||||
{
|
||||
@@ -583,9 +583,9 @@ namespace SabreTools.Serialization.Readers
|
||||
obj.ValueName = data.ReadNullTerminatedAnsiString();
|
||||
|
||||
// If the delete pattern is found
|
||||
if (obj.UnknownFsllib != null && obj.UnknownFsllib.Length > 0
|
||||
&& obj.Key != null && obj.Key.Length == 0
|
||||
&& obj.NewValue != null && obj.NewValue.Length == 0)
|
||||
if (obj.UnknownFsllib is not null && obj.UnknownFsllib.Length > 0
|
||||
&& obj.Key is not null && obj.Key.Length == 0
|
||||
&& obj.NewValue is not null && obj.NewValue.Length == 0)
|
||||
{
|
||||
data.SeekIfPossible(-(obj.ValueName?.Length ?? 0) - 1, SeekOrigin.Current);
|
||||
obj.ValueName = obj.NewValue;
|
||||
@@ -596,7 +596,7 @@ namespace SabreTools.Serialization.Readers
|
||||
}
|
||||
|
||||
// If the last value is a control
|
||||
else if (obj.ValueName != null && IsTypicalControlCode(obj.ValueName, strict: true))
|
||||
else if (obj.ValueName is not null && IsTypicalControlCode(obj.ValueName, strict: true))
|
||||
{
|
||||
data.SeekIfPossible(-obj.ValueName.Length - 1, SeekOrigin.Current);
|
||||
obj.ValueName = obj.NewValue;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached value, if it exists
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Find the type and version record, if possible
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Extract the file
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
builder.AppendLine($" Directory Entry {i}");
|
||||
builder.AppendLine(entry.Name?.TrimEnd('\0'), " Name");
|
||||
if (entry.Name != null)
|
||||
if (entry.Name is not null)
|
||||
builder.AppendLine(Encoding.UTF8.GetBytes(entry.Name), " Name (bytes)");
|
||||
builder.AppendLine(entry.NameLength, " Name length");
|
||||
builder.AppendLine($" Object type: {entry.ObjectType} (0x{entry.ObjectType:X})");
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached value, if it exists
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// If there are no directory entries
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached value, if it exists
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Otherwise, build the data block set
|
||||
@@ -50,7 +50,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached value, if it exists
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Otherwise, scan and build the files
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Ensure directory separators are consistent
|
||||
string filename = Header.OriginalFileName
|
||||
?? (Filename != null ? Path.GetFileName(Filename).Replace(".gz", string.Empty) : null)
|
||||
?? (Filename is not null ? Path.GetFileName(Filename).Replace(".gz", string.Empty) : null)
|
||||
?? $"extracted_file";
|
||||
|
||||
if (Path.DirectorySeparatorChar == '\\')
|
||||
@@ -48,7 +48,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Open the source as a DEFLATE stream
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return null;
|
||||
|
||||
// Use the cached value, if it exists
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// CRC-32 is the second packed field
|
||||
@@ -51,7 +51,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return null;
|
||||
|
||||
// Use the cached value, if it exists
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// MD5 is the first packed field
|
||||
@@ -108,11 +108,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Add extra lengths
|
||||
field += Header.ExtraLength;
|
||||
if (Header.OriginalFileName != null)
|
||||
if (Header.OriginalFileName is not null)
|
||||
field += Header.OriginalFileName.Length + 1;
|
||||
if (Header.FileComment != null)
|
||||
if (Header.FileComment is not null)
|
||||
field += Header.FileComment.Length + 1;
|
||||
if (Header.CRC16 != null)
|
||||
if (Header.CRC16 is not null)
|
||||
field += 2;
|
||||
|
||||
return field;
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
var filepath = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filepath);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
bool multiExtent = false;
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(encoding.GetString(vd.VolumeIdentifier), " Volume Identifier");
|
||||
|
||||
|
||||
if (vd.Unused8Bytes != null && Array.TrueForAll(vd.Unused8Bytes, b => b == 0))
|
||||
if (vd.Unused8Bytes is not null && Array.TrueForAll(vd.Unused8Bytes, b => b == 0))
|
||||
builder.AppendLine("Zeroed", " Unused 8 Bytes");
|
||||
else
|
||||
builder.AppendLine(vd.Unused8Bytes, " Unused 8 Bytes");
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
if (vd is PrimaryVolumeDescriptor pvd2)
|
||||
{
|
||||
if (pvd2.Unused32Bytes != null && Array.TrueForAll(pvd2.Unused32Bytes, b => b == 0))
|
||||
if (pvd2.Unused32Bytes is not null && Array.TrueForAll(pvd2.Unused32Bytes, b => b == 0))
|
||||
builder.AppendLine("Zeroed", " Unused 32 Bytes");
|
||||
else
|
||||
builder.AppendLine(pvd2.Unused32Bytes, " Unused 32 Bytes");
|
||||
@@ -268,7 +268,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
for (int tableNum = 0; tableNum < ptgs.Length; tableNum++)
|
||||
{
|
||||
if (ptgs[tableNum].PathTableL != null)
|
||||
if (ptgs[tableNum].PathTableL is not null)
|
||||
{
|
||||
builder.AppendLine($" Type-L Path Table {tableNum}:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -279,7 +279,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" No Type-L Path Table {tableNum}:");
|
||||
builder.AppendLine();
|
||||
}
|
||||
if (ptgs[tableNum].OptionalPathTableL != null)
|
||||
if (ptgs[tableNum].OptionalPathTableL is not null)
|
||||
{
|
||||
builder.AppendLine($" Optional Type-L Path Table {tableNum}:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -290,7 +290,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" No Optional Type-L Path Table {tableNum}:");
|
||||
builder.AppendLine();
|
||||
}
|
||||
if (ptgs[tableNum].PathTableM != null)
|
||||
if (ptgs[tableNum].PathTableM is not null)
|
||||
{
|
||||
builder.AppendLine($" Type-M Path Table {tableNum}:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -301,7 +301,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine($" No Type-M Path Table {tableNum}:");
|
||||
builder.AppendLine();
|
||||
}
|
||||
if (ptgs[tableNum].OptionalPathTableM != null)
|
||||
if (ptgs[tableNum].OptionalPathTableM is not null)
|
||||
{
|
||||
builder.AppendLine($" Optional Type-M Path Table {tableNum}:");
|
||||
builder.AppendLine(" -------------------------");
|
||||
@@ -333,7 +333,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(records[recordNum].ExtendedAttributeRecordLength, " Extended Attribute Record Length");
|
||||
builder.AppendLine(records[recordNum].ExtentLocation, " Extent Location");
|
||||
builder.AppendLine(records[recordNum].DirectoryIdentifier, " Directory Identifier");
|
||||
if (records[recordNum].PaddingField != null)
|
||||
if (records[recordNum].PaddingField is not null)
|
||||
builder.AppendLine(records[recordNum].PaddingField, " Padding Field");
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !System.IO.Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !System.IO.Directory.Exists(directoryName))
|
||||
System.IO.Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Return the prebuilt map
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Build the file map
|
||||
@@ -67,7 +67,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Return the prebuilt map
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Build the file map
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
for (ushort i = 1; iterate; i++)
|
||||
{
|
||||
var file = OpenFileForReading(pattern, i, HEADER_SUFFIX);
|
||||
if (file != null)
|
||||
if (file is not null)
|
||||
iterate = false;
|
||||
else
|
||||
file = OpenFileForReading(pattern, i, CABINET_SUFFIX);
|
||||
@@ -91,7 +91,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
break;
|
||||
|
||||
current.VolumeID = i;
|
||||
if (previous != null)
|
||||
if (previous is not null)
|
||||
{
|
||||
previous.Next = current;
|
||||
current.Prev = previous;
|
||||
@@ -161,7 +161,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return pattern;
|
||||
|
||||
string? directory = Path.GetDirectoryName(Path.GetFullPath(filename));
|
||||
if (directory != null)
|
||||
if (directory is not null)
|
||||
pattern = Path.Combine(directory, Path.GetFileNameWithoutExtension(filename));
|
||||
else
|
||||
pattern = Path.GetFileNameWithoutExtension(filename);
|
||||
@@ -204,7 +204,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
// Open the full set if possible
|
||||
var cabinet = this;
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
{
|
||||
// Get the name of the first cabinet file or header
|
||||
string pattern = CreateFilenamePattern(Filename)!;
|
||||
@@ -245,7 +245,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
cabinet.FileSave(i, filename, includeDebug);
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
public uint GetDirectoryIndexFromFile(int index)
|
||||
{
|
||||
FileDescriptor? descriptor = GetFileDescriptor(index);
|
||||
if (descriptor != null)
|
||||
if (descriptor is not null)
|
||||
return descriptor.DirectoryIndex;
|
||||
else
|
||||
return uint.MaxValue;
|
||||
@@ -223,7 +223,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
public ulong GetExpandedFileSize(int index)
|
||||
{
|
||||
FileDescriptor? descriptor = GetFileDescriptor(index);
|
||||
if (descriptor != null)
|
||||
if (descriptor is not null)
|
||||
return descriptor.ExpandedSize;
|
||||
else
|
||||
return 0;
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write the output file
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Create the full output path
|
||||
string filename = FileName ?? "tempfile";
|
||||
if (FileExtension != null)
|
||||
if (FileExtension is not null)
|
||||
filename += $".{FileExtension}";
|
||||
|
||||
// Ensure directory separators are consistent
|
||||
@@ -42,7 +42,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
public bool Extract(string filename, string outputDirectory, bool includeDebug)
|
||||
{
|
||||
// Ensure the filename
|
||||
if (filename.Length == 0 && Filename != null)
|
||||
if (filename.Length == 0 && Filename is not null)
|
||||
filename = Filename;
|
||||
|
||||
// Get the length of the compressed data
|
||||
@@ -49,7 +49,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_stubExecutableDataLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Populate the raw stub executable data based on the source
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return null;
|
||||
|
||||
// Seek to the first part of the cabinet set
|
||||
while (current.CabinetPrev != null)
|
||||
while (current.CabinetPrev is not null)
|
||||
{
|
||||
// Attempt to open the previous cabinet
|
||||
var prev = current.OpenPrevious(filename, includeDebug);
|
||||
@@ -66,7 +66,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
var start = current;
|
||||
|
||||
// Read in the cabinet parts sequentially
|
||||
while (current.CabinetNext != null)
|
||||
while (current.CabinetNext is not null)
|
||||
{
|
||||
// If the current and next filenames match
|
||||
if (Path.GetFileName(filename) == current.CabinetNext)
|
||||
@@ -108,7 +108,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Get the full next path
|
||||
string? folder = Path.GetDirectoryName(filename);
|
||||
if (folder != null)
|
||||
if (folder is not null)
|
||||
next = Path.Combine(folder, next);
|
||||
|
||||
// Open and return the next cabinet
|
||||
@@ -145,7 +145,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Get the full next path
|
||||
string? folder = Path.GetDirectoryName(filename);
|
||||
if (folder != null)
|
||||
if (folder is not null)
|
||||
prev = Path.Combine(folder, prev);
|
||||
|
||||
// Open and return the previous cabinet
|
||||
@@ -172,7 +172,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (includeDebug) Console.WriteLine("WARNING: LZX and Quantum compression schemes are not supported so some files may be skipped!");
|
||||
|
||||
MicrosoftCabinet? cabinet;
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
{
|
||||
// Open the full set if possible
|
||||
cabinet = OpenSet(Filename, includeDebug);
|
||||
@@ -378,7 +378,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Open the output file for writing
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
Prev = OpenPrevious(filename, includeDebug);
|
||||
|
||||
// Get all files from Prev
|
||||
if (Prev?.Header != null && Prev.Folders != null)
|
||||
if (Prev?.Header is not null && Prev.Folders is not null)
|
||||
{
|
||||
int prevFolderIndex = Prev.FolderCount - 1;
|
||||
prevFiles = Prev.GetSpannedFiles(filename, prevFolderIndex, includeDebug, skipNext: true) ?? [];
|
||||
@@ -294,7 +294,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
Next = OpenNext(filename);
|
||||
|
||||
// Get all files from Prev
|
||||
if (Next?.Header != null && Next.Folders != null)
|
||||
if (Next?.Header is not null && Next.Folders is not null)
|
||||
{
|
||||
var nextFolder = Next.Folders[0];
|
||||
nextFiles = Next.GetSpannedFiles(filename, 0, includeDebug, skipPrev: true) ?? [];
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -150,12 +150,12 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Create the temp filename
|
||||
string tempFile = $"embedded_overlay.{extension}";
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
tempFile = $"{Path.GetFileName(Filename)}-{tempFile}";
|
||||
|
||||
tempFile = Path.Combine(outputDirectory, tempFile);
|
||||
var directoryName = Path.GetDirectoryName(tempFile);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write the resource data to a temp file
|
||||
@@ -208,10 +208,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
// Get the source data for reading
|
||||
Stream source = _dataSource;
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
{
|
||||
// Try to open a multipart file
|
||||
if (WiseOverlayHeader.OpenFile(Filename, includeDebug, out var temp) && temp != null)
|
||||
if (WiseOverlayHeader.OpenFile(Filename, includeDebug, out var temp) && temp is not null)
|
||||
source = temp;
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Get the source directory
|
||||
string? sourceDirectory = null;
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
sourceDirectory = Path.GetDirectoryName(Path.GetFullPath(Filename));
|
||||
|
||||
// Process the state machine
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_overlayDataLock)
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Get the available source length, if possible
|
||||
@@ -211,7 +211,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_overlayStringsLock)
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Get the available source length, if possible
|
||||
@@ -259,7 +259,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_stubExecutableDataLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Populate the raw stub executable data based on the source
|
||||
@@ -398,7 +398,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Attempt to get the overlay header
|
||||
_dataSource.SeekIfPossible(overlayOffset, SeekOrigin.Begin);
|
||||
var header = WiseOverlayHeader.Create(_dataSource);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
return overlayOffset;
|
||||
|
||||
// Align and loop to see if it can be found
|
||||
@@ -409,7 +409,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
_dataSource.SeekIfPossible(overlayOffset, SeekOrigin.Begin);
|
||||
header = WiseOverlayHeader.Create(_dataSource);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
return overlayOffset;
|
||||
|
||||
overlayOffset += 0x10;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
else
|
||||
{
|
||||
bool? isDecrypted = CheckIfDecrypted(out string? message);
|
||||
if (message != null)
|
||||
if (message is not null)
|
||||
Console.WriteLine(message);
|
||||
|
||||
if (isDecrypted is null)
|
||||
@@ -149,7 +149,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
else
|
||||
{
|
||||
bool? isDecrypted = CheckIfDecrypted(out string? message);
|
||||
if (message != null)
|
||||
if (message is not null)
|
||||
Console.WriteLine(message);
|
||||
|
||||
if (isDecrypted is null)
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Create the output file
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
entry.WriteToFile(filename);
|
||||
@@ -156,7 +156,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
for (int i = 1; ; i++)
|
||||
{
|
||||
string nextPart = nextPartFunc(i);
|
||||
if (directory != null)
|
||||
if (directory is not null)
|
||||
nextPart = Path.Combine(directory, nextPart);
|
||||
|
||||
if (!File.Exists(nextPart))
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write the output file
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
string tempFile = string.IsNullOrEmpty(Filename) ? "temp.sxe" : $"{Path.GetFileNameWithoutExtension(Filename)}.sxe";
|
||||
tempFile = Path.Combine(outputDirectory, tempFile);
|
||||
var directoryName = Path.GetDirectoryName(tempFile);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write the file data to a temp file
|
||||
@@ -291,12 +291,12 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Create the temp filename
|
||||
string tempFile = $"embedded_overlay.{extension}";
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
tempFile = $"{Path.GetFileName(Filename)}-{tempFile}";
|
||||
|
||||
tempFile = Path.Combine(outputDirectory, tempFile);
|
||||
var directoryName = Path.GetDirectoryName(tempFile);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write the resource data to a temp file
|
||||
@@ -496,12 +496,12 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
// Create the temp filename
|
||||
string tempFile = $"embedded_resource_{i++} ({resourceKey}).{extension}";
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
tempFile = $"{Path.GetFileName(Filename)}-{tempFile}";
|
||||
|
||||
tempFile = Path.Combine(outputDirectory, tempFile);
|
||||
var directoryName = Path.GetDirectoryName(tempFile);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write the resource data to a temp file
|
||||
@@ -607,7 +607,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write the output file
|
||||
@@ -635,10 +635,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
// Get the source data for reading
|
||||
Stream source = _dataSource;
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
{
|
||||
// Try to open a multipart file
|
||||
if (WiseOverlayHeader.OpenFile(Filename, includeDebug, out var temp) && temp != null)
|
||||
if (WiseOverlayHeader.OpenFile(Filename, includeDebug, out var temp) && temp is not null)
|
||||
source = temp;
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Get the source directory
|
||||
string? sourceDirectory = null;
|
||||
if (Filename != null)
|
||||
if (Filename is not null)
|
||||
sourceDirectory = Path.GetDirectoryName(Path.GetFullPath(Filename));
|
||||
|
||||
// Process the state machine
|
||||
|
||||
@@ -143,49 +143,49 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(header.LoaderFlags, " Loader flags");
|
||||
builder.AppendLine(header.NumberOfRvaAndSizes, " Number of data-directory entries");
|
||||
|
||||
if (header.ExportTable != null)
|
||||
if (header.ExportTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Export Table (1)");
|
||||
builder.AppendLine(header.ExportTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ExportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ExportTable.Size, " Size");
|
||||
}
|
||||
if (header.ImportTable != null)
|
||||
if (header.ImportTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Import Table (2)");
|
||||
builder.AppendLine(header.ImportTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ImportTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ImportTable.Size, " Size");
|
||||
}
|
||||
if (header.ResourceTable != null)
|
||||
if (header.ResourceTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Resource Table (3)");
|
||||
builder.AppendLine(header.ResourceTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ResourceTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ResourceTable.Size, " Size");
|
||||
}
|
||||
if (header.ExceptionTable != null)
|
||||
if (header.ExceptionTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Exception Table (4)");
|
||||
builder.AppendLine(header.ExceptionTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ExceptionTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ExceptionTable.Size, " Size");
|
||||
}
|
||||
if (header.CertificateTable != null)
|
||||
if (header.CertificateTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Certificate Table (5)");
|
||||
builder.AppendLine(" Virtual address: N/A");
|
||||
builder.AppendLine(header.CertificateTable.VirtualAddress, " Physical address");
|
||||
builder.AppendLine(header.CertificateTable.Size, " Size");
|
||||
}
|
||||
if (header.BaseRelocationTable != null)
|
||||
if (header.BaseRelocationTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Base Relocation Table (6)");
|
||||
builder.AppendLine(header.BaseRelocationTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.BaseRelocationTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.BaseRelocationTable.Size, " Size");
|
||||
}
|
||||
if (header.Debug != null)
|
||||
if (header.Debug is not null)
|
||||
{
|
||||
builder.AppendLine(" Debug Table (7)");
|
||||
builder.AppendLine(header.Debug.VirtualAddress, " Virtual address");
|
||||
@@ -199,49 +199,49 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(" Physical address: 0 (0x00000000)");
|
||||
builder.AppendLine(" Size: 0 (0x00000000)");
|
||||
}
|
||||
if (header.GlobalPtr != null)
|
||||
if (header.GlobalPtr is not null)
|
||||
{
|
||||
builder.AppendLine(" Global Pointer Register (9)");
|
||||
builder.AppendLine(header.GlobalPtr.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.GlobalPtr.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.GlobalPtr.Size, " Size");
|
||||
}
|
||||
if (header.ThreadLocalStorageTable != null)
|
||||
if (header.ThreadLocalStorageTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Thread Local Storage (TLS) Table (10)");
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ThreadLocalStorageTable.Size, " Size");
|
||||
}
|
||||
if (header.LoadConfigTable != null)
|
||||
if (header.LoadConfigTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Load Config Table (11)");
|
||||
builder.AppendLine(header.LoadConfigTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.LoadConfigTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.LoadConfigTable.Size, " Size");
|
||||
}
|
||||
if (header.BoundImport != null)
|
||||
if (header.BoundImport is not null)
|
||||
{
|
||||
builder.AppendLine(" Bound Import Table (12)");
|
||||
builder.AppendLine(header.BoundImport.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.BoundImport.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.BoundImport.Size, " Size");
|
||||
}
|
||||
if (header.ImportAddressTable != null)
|
||||
if (header.ImportAddressTable is not null)
|
||||
{
|
||||
builder.AppendLine(" Import Address Table (13)");
|
||||
builder.AppendLine(header.ImportAddressTable.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.ImportAddressTable.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.ImportAddressTable.Size, " Size");
|
||||
}
|
||||
if (header.DelayImportDescriptor != null)
|
||||
if (header.DelayImportDescriptor is not null)
|
||||
{
|
||||
builder.AppendLine(" Delay Import Descriptor (14)");
|
||||
builder.AppendLine(header.DelayImportDescriptor.VirtualAddress, " Virtual address");
|
||||
builder.AppendLine(header.DelayImportDescriptor.VirtualAddress.ConvertVirtualAddress(table), " Physical address");
|
||||
builder.AppendLine(header.DelayImportDescriptor.Size, " Size");
|
||||
}
|
||||
if (header.CLRRuntimeHeader != null)
|
||||
if (header.CLRRuntimeHeader is not null)
|
||||
{
|
||||
builder.AppendLine(" CLR Runtime Header (15)");
|
||||
builder.AppendLine(header.CLRRuntimeHeader.VirtualAddress, " Virtual address");
|
||||
@@ -326,7 +326,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
private static void Print(StringBuilder builder, StandardRecord entry, int i)
|
||||
{
|
||||
builder.AppendLine($" Symbol Table Entry {i} (Standard Record)");
|
||||
if (entry.ShortName != null)
|
||||
if (entry.ShortName is not null)
|
||||
{
|
||||
builder.AppendLine(entry.ShortName, " Short name", Encoding.ASCII);
|
||||
}
|
||||
@@ -891,7 +891,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
var entry = table.Entries[i];
|
||||
|
||||
var newTypes = new List<object>(types ?? []);
|
||||
if (entry.Name?.UnicodeString != null)
|
||||
if (entry.Name?.UnicodeString is not null)
|
||||
newTypes.Add(Encoding.Unicode.GetString(entry.Name.UnicodeString));
|
||||
else
|
||||
newTypes.Add(entry.IntegerID);
|
||||
@@ -916,9 +916,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(entry.IntegerID, $"{padding}Integer ID");
|
||||
}
|
||||
|
||||
if (entry.DataEntry != null)
|
||||
if (entry.DataEntry is not null)
|
||||
Print(builder, entry.DataEntry, level: level + 1, types, sections);
|
||||
else if (entry.Subdirectory != null)
|
||||
else if (entry.Subdirectory is not null)
|
||||
Print(builder, entry.Subdirectory, level: level + 1, types, sections);
|
||||
}
|
||||
|
||||
@@ -938,7 +938,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(entry.Reserved, $"{padding}Reserved");
|
||||
|
||||
// TODO: Print out per-type data
|
||||
if (types != null && types.Count > 0 && types[0] is uint resourceType)
|
||||
if (types is not null && types.Count > 0 && types[0] is uint resourceType)
|
||||
{
|
||||
switch ((ResourceType)resourceType)
|
||||
{
|
||||
@@ -1010,7 +1010,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (types != null && types.Count > 0 && types[0] is string resourceString)
|
||||
else if (types is not null && types.Count > 0 && types[0] is string resourceString)
|
||||
{
|
||||
PrintResourceUNKNOWN(entry, level, types[0], builder);
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return;
|
||||
}
|
||||
|
||||
if (dialogBox.DialogTemplate != null)
|
||||
if (dialogBox.DialogTemplate is not null)
|
||||
{
|
||||
builder.AppendLine($"{padding}Style: {dialogBox.DialogTemplate.Style} (0x{dialogBox.DialogTemplate.Style:X})");
|
||||
builder.AppendLine($"{padding}Extended style: {dialogBox.DialogTemplate.ExtendedStyle} (0x{dialogBox.DialogTemplate.ExtendedStyle:X})");
|
||||
@@ -1172,13 +1172,13 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(dialogItemTemplate.TitleResource, $"{padding} Title resource");
|
||||
builder.AppendLine(dialogItemTemplate.TitleResourceOrdinal, $"{padding} Title resource ordinal");
|
||||
builder.AppendLine(dialogItemTemplate.CreationDataSize, $"{padding} Creation data size");
|
||||
if (dialogItemTemplate.CreationData != null && dialogItemTemplate.CreationData.Length != 0)
|
||||
if (dialogItemTemplate.CreationData is not null && dialogItemTemplate.CreationData.Length != 0)
|
||||
builder.AppendLine(dialogItemTemplate.CreationData, $"{padding} Creation data");
|
||||
else
|
||||
builder.AppendLine($"{padding} Creation data: [EMPTY]");
|
||||
}
|
||||
}
|
||||
else if (dialogBox.ExtendedDialogTemplate != null)
|
||||
else if (dialogBox.ExtendedDialogTemplate is not null)
|
||||
{
|
||||
builder.AppendLine(dialogBox.ExtendedDialogTemplate.Version, $"{padding}Version");
|
||||
builder.AppendLine(dialogBox.ExtendedDialogTemplate.Signature, $"{padding}Signature");
|
||||
@@ -1234,7 +1234,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(dialogItemTemplate.TitleResource, $"{padding} Title resource");
|
||||
builder.AppendLine(dialogItemTemplate.TitleResourceOrdinal, $"{padding} Title resource ordinal");
|
||||
builder.AppendLine(dialogItemTemplate.CreationDataSize, $"{padding} Creation data size");
|
||||
if (dialogItemTemplate.CreationData != null && dialogItemTemplate.CreationData.Length != 0)
|
||||
if (dialogItemTemplate.CreationData is not null && dialogItemTemplate.CreationData.Length != 0)
|
||||
builder.AppendLine(dialogItemTemplate.CreationData, $"{padding} Creation data");
|
||||
else
|
||||
builder.AppendLine($"{padding} Creation data: [EMPTY]");
|
||||
@@ -1348,13 +1348,13 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
builder.AppendLine(magic, $"{padding}Data");
|
||||
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(entry.Data, $"{padding}Value (Byte Data)");
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.ASCII.GetString(entry.Data), $"{padding}Value (ASCII)");
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.UTF8.GetString(entry.Data), $"{padding}Value (UTF-8)");
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.Unicode.GetString(entry.Data), $"{padding}Value (Unicode)");
|
||||
}
|
||||
}
|
||||
@@ -1453,7 +1453,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(versionInfo.ValueLength, $"{padding}Value length");
|
||||
builder.AppendLine($"{padding}Resource type: {versionInfo.ResourceType} (0x{versionInfo.ResourceType:X})");
|
||||
builder.AppendLine(versionInfo.Key, $"{padding}Key");
|
||||
if (versionInfo.ValueLength != 0 && versionInfo.Value != null)
|
||||
if (versionInfo.ValueLength != 0 && versionInfo.Value is not null)
|
||||
{
|
||||
builder.AppendLine(versionInfo.Value.Signature, $"{padding}[Fixed File Info] Signature");
|
||||
builder.AppendLine(versionInfo.Value.StrucVersion, $"{padding}[Fixed File Info] Struct version");
|
||||
@@ -1470,7 +1470,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(versionInfo.Value.FileDateLS, $"{padding}[Fixed File Info] File date (LS)");
|
||||
}
|
||||
|
||||
if (versionInfo.StringFileInfo != null)
|
||||
if (versionInfo.StringFileInfo is not null)
|
||||
{
|
||||
builder.AppendLine(versionInfo.StringFileInfo.Length, $"{padding}[String File Info] Length");
|
||||
builder.AppendLine(versionInfo.StringFileInfo.ValueLength, $"{padding}[String File Info] Value length");
|
||||
@@ -1525,7 +1525,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
if (versionInfo.VarFileInfo != null)
|
||||
if (versionInfo.VarFileInfo is not null)
|
||||
{
|
||||
builder.AppendLine(versionInfo.VarFileInfo.Length, $"{padding}[Var File Info] Length");
|
||||
builder.AppendLine(versionInfo.VarFileInfo.ValueLength, $"{padding}[Var File Info] Value length");
|
||||
@@ -1593,11 +1593,11 @@ namespace SabreTools.Serialization.Wrappers
|
||||
string padding = new(' ', (level + 1) * 2);
|
||||
builder.AppendLine($"{padding}HTML resource found, not parsed yet");
|
||||
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.ASCII.GetString(entry.Data), $"{padding}Value (ASCII)");
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.UTF8.GetString(entry.Data), $"{padding}Value (UTF-8)");
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.Unicode.GetString(entry.Data), $"{padding}Value (Unicode)");
|
||||
}
|
||||
|
||||
@@ -1614,7 +1614,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
builder.AppendLine(assemblyManifest.ManifestVersion, $"{padding}Manifest version");
|
||||
if (assemblyManifest.AssemblyIdentities != null && assemblyManifest.AssemblyIdentities.Length > 0)
|
||||
if (assemblyManifest.AssemblyIdentities is not null && assemblyManifest.AssemblyIdentities.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < assemblyManifest.AssemblyIdentities.Length; i++)
|
||||
{
|
||||
@@ -1629,10 +1629,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
if (assemblyManifest.Description != null)
|
||||
if (assemblyManifest.Description is not null)
|
||||
builder.AppendLine(assemblyManifest.Description.Value, $"{padding}[Assembly Description] Value");
|
||||
|
||||
if (assemblyManifest.COMInterfaceExternalProxyStub != null && assemblyManifest.COMInterfaceExternalProxyStub.Length > 0)
|
||||
if (assemblyManifest.COMInterfaceExternalProxyStub is not null && assemblyManifest.COMInterfaceExternalProxyStub.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < assemblyManifest.COMInterfaceExternalProxyStub.Length; i++)
|
||||
{
|
||||
@@ -1647,14 +1647,14 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
if (assemblyManifest.Dependency != null && assemblyManifest.Dependency.Length > 0)
|
||||
if (assemblyManifest.Dependency is not null && assemblyManifest.Dependency.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < assemblyManifest.Dependency.Length; i++)
|
||||
{
|
||||
var dependency = assemblyManifest.Dependency[i];
|
||||
if (dependency?.DependentAssembly != null)
|
||||
if (dependency?.DependentAssembly is not null)
|
||||
{
|
||||
if (dependency.DependentAssembly.AssemblyIdentity != null)
|
||||
if (dependency.DependentAssembly.AssemblyIdentity is not null)
|
||||
{
|
||||
builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.Name, $"{padding}[Dependency {i} Assembly Identity] Name");
|
||||
builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.Version, $"{padding}[Dependency {i} Assembly Identity] Version");
|
||||
@@ -1663,7 +1663,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.PublicKeyToken, $"{padding}[Dependency {i} Assembly Identity] Public key token");
|
||||
builder.AppendLine(dependency.DependentAssembly.AssemblyIdentity.Language, $"{padding}[Dependency {i} Assembly Identity] Language");
|
||||
}
|
||||
if (dependency.DependentAssembly.BindingRedirect != null && dependency.DependentAssembly.BindingRedirect.Length > 0)
|
||||
if (dependency.DependentAssembly.BindingRedirect is not null && dependency.DependentAssembly.BindingRedirect.Length > 0)
|
||||
{
|
||||
for (int j = 0; j < dependency.DependentAssembly.BindingRedirect.Length; j++)
|
||||
{
|
||||
@@ -1675,12 +1675,12 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
if (dependency != null)
|
||||
if (dependency is not null)
|
||||
builder.AppendLine(dependency.Optional, $"{padding}[Dependency {i}] Optional");
|
||||
}
|
||||
}
|
||||
|
||||
if (assemblyManifest.File != null && assemblyManifest.File.Length > 0)
|
||||
if (assemblyManifest.File is not null && assemblyManifest.File.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < assemblyManifest.File.Length; i++)
|
||||
{
|
||||
@@ -1696,7 +1696,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(file.HashAlgorithm, $"{padding}[File {i}] Hash algorithm");
|
||||
builder.AppendLine(file.Size, $"{padding}[File {i}] Size");
|
||||
|
||||
if (file.COMClass != null && file.COMClass.Length > 0)
|
||||
if (file.COMClass is not null && file.COMClass.Length > 0)
|
||||
{
|
||||
for (int j = 0; j < file.COMClass.Length; j++)
|
||||
{
|
||||
@@ -1708,7 +1708,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(comClass.TLBID, $"{padding}[File {i} COM Class {j}] TLBID");
|
||||
builder.AppendLine(comClass.Description, $"{padding}[File {i} COM Class {j}] Description");
|
||||
|
||||
if (comClass.ProgIDs != null && comClass.ProgIDs.Length > 0)
|
||||
if (comClass.ProgIDs is not null && comClass.ProgIDs.Length > 0)
|
||||
{
|
||||
for (int k = 0; k < comClass.ProgIDs.Length; k++)
|
||||
{
|
||||
@@ -1719,7 +1719,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
if (file.COMInterfaceProxyStub != null && file.COMInterfaceProxyStub.Length > 0)
|
||||
if (file.COMInterfaceProxyStub is not null && file.COMInterfaceProxyStub.Length > 0)
|
||||
{
|
||||
for (int j = 0; j < file.COMInterfaceProxyStub.Length; j++)
|
||||
{
|
||||
@@ -1734,7 +1734,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
if (file.Typelib != null && file.Typelib.Length > 0)
|
||||
if (file.Typelib is not null && file.Typelib.Length > 0)
|
||||
{
|
||||
for (int j = 0; j < file.Typelib.Length; j++)
|
||||
{
|
||||
@@ -1748,7 +1748,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
if (file.WindowClass != null && file.WindowClass.Length > 0)
|
||||
if (file.WindowClass is not null && file.WindowClass.Length > 0)
|
||||
{
|
||||
for (int j = 0; j < file.WindowClass.Length; j++)
|
||||
{
|
||||
@@ -1761,7 +1761,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
}
|
||||
|
||||
if (assemblyManifest.EverythingElse != null && assemblyManifest.EverythingElse.Length > 0)
|
||||
if (assemblyManifest.EverythingElse is not null && assemblyManifest.EverythingElse.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < assemblyManifest.EverythingElse.Length; i++)
|
||||
{
|
||||
@@ -1832,13 +1832,13 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
builder.AppendLine(magic, $"{padding}Data");
|
||||
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(entry.Data, $"{padding}Value (Byte Data)");
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.ASCII.GetString(entry.Data), $"{padding}Value (ASCII)");
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.UTF8.GetString(entry.Data), $"{padding}Value (UTF-8)");
|
||||
//if (entry.Data != null)
|
||||
//if (entry.Data is not null)
|
||||
// builder.AppendLine(Encoding.Unicode.GetString(entry.Data), $"{padding}Value (Unicode)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_entryPointDataLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// If we have no entry point
|
||||
@@ -114,7 +114,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_headerPaddingDataLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// TODO: Don't scan the known header data as well
|
||||
@@ -157,7 +157,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_headerPaddingStringsLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Get the header padding data, if possible
|
||||
@@ -197,7 +197,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_matroschkaPackageLock)
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Check to see if creation has already been attempted
|
||||
@@ -268,7 +268,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_installshieldExecutableLock)
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Check to see if creation has already been attempted
|
||||
@@ -334,7 +334,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
// If we have certificate data, use that as the end
|
||||
if (OptionalHeader.CertificateTable != null)
|
||||
if (OptionalHeader.CertificateTable is not null)
|
||||
{
|
||||
long certificateTableAddress = OptionalHeader.CertificateTable.VirtualAddress;
|
||||
if (certificateTableAddress != 0 && certificateTableAddress < dataLength)
|
||||
@@ -372,7 +372,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_overlayDataLock)
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Get the available source length, if possible
|
||||
@@ -384,7 +384,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
// If we have certificate data, use that as the end
|
||||
if (OptionalHeader.CertificateTable != null)
|
||||
if (OptionalHeader.CertificateTable is not null)
|
||||
{
|
||||
long certificateTableAddress = OptionalHeader.CertificateTable.VirtualAddress;
|
||||
if (certificateTableAddress != 0 && certificateTableAddress < dataLength)
|
||||
@@ -441,7 +441,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
// If we have certificate data, use that as the end
|
||||
if (OptionalHeader.CertificateTable != null)
|
||||
if (OptionalHeader.CertificateTable is not null)
|
||||
{
|
||||
long certificateTableAddress = OptionalHeader.CertificateTable.VirtualAddress;
|
||||
if (certificateTableAddress != 0 && certificateTableAddress < dataLength)
|
||||
@@ -482,7 +482,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_overlayStringsLock)
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Get the overlay data, if possible
|
||||
@@ -513,7 +513,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_sectionNamesLock)
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Otherwise, build and return the cached array
|
||||
@@ -544,7 +544,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_sectionTableTrailerDataLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Get the offset from the end of the section table
|
||||
@@ -577,7 +577,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_stubExecutableDataLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// Populate the raw stub executable data based on the source
|
||||
@@ -629,7 +629,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
lock (_wiseSectionHeaderLock)
|
||||
{
|
||||
// If we already have cached data, just use that immediately
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// If the header will not be found due to missing section data
|
||||
@@ -692,7 +692,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("BuildGuid");
|
||||
@@ -708,7 +708,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("BuildSignature");
|
||||
@@ -724,7 +724,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("Comments");
|
||||
@@ -741,7 +741,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("CompanyName");
|
||||
@@ -757,7 +757,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("DebugVersion");
|
||||
@@ -775,7 +775,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("FileDescription");
|
||||
@@ -792,7 +792,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("FileVersion");
|
||||
@@ -810,7 +810,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("InternalName");
|
||||
@@ -827,7 +827,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("LegalCopyright");
|
||||
@@ -845,7 +845,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("LegalTrademarks");
|
||||
@@ -864,7 +864,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("OriginalFilename");
|
||||
@@ -882,7 +882,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("PrivateBuild");
|
||||
@@ -898,7 +898,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("ProductGuid");
|
||||
@@ -914,7 +914,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("ProductName");
|
||||
@@ -931,7 +931,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("ProductVersion");
|
||||
@@ -950,7 +950,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("SpecialBuild") ?? GetVersionInfoString("Special Build");
|
||||
@@ -966,7 +966,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
field = GetVersionInfoString("TradeName");
|
||||
@@ -1311,7 +1311,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Return the match if found
|
||||
match = Array.Find(st.Children, sd => key.Equals(sd.Key, StringComparison.OrdinalIgnoreCase));
|
||||
if (match != null)
|
||||
if (match is not null)
|
||||
return match.Value?.TrimEnd('\0');
|
||||
}
|
||||
|
||||
@@ -1325,7 +1325,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
private AssemblyManifest? GetAssemblyManifest()
|
||||
{
|
||||
// Use the cached data if possible
|
||||
if (_assemblyManifest != null)
|
||||
if (_assemblyManifest is not null)
|
||||
return _assemblyManifest;
|
||||
|
||||
// Cache the resource data for easier reading
|
||||
@@ -1485,7 +1485,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (signature == 0x3031424E)
|
||||
{
|
||||
var nb10ProgramDatabase = entryData.ParseNB10ProgramDatabase(ref offset);
|
||||
if (nb10ProgramDatabase != null)
|
||||
if (nb10ProgramDatabase is not null)
|
||||
{
|
||||
debugData[i] = nb10ProgramDatabase;
|
||||
continue;
|
||||
@@ -1496,7 +1496,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
else if (signature == 0x53445352)
|
||||
{
|
||||
var rsdsProgramDatabase = entryData.ParseRSDSProgramDatabase(ref offset);
|
||||
if (rsdsProgramDatabase != null)
|
||||
if (rsdsProgramDatabase is not null)
|
||||
{
|
||||
debugData[i] = rsdsProgramDatabase;
|
||||
continue;
|
||||
@@ -1565,15 +1565,15 @@ namespace SabreTools.Serialization.Wrappers
|
||||
if (resource is not DialogBoxResource dbr || dbr is null)
|
||||
continue;
|
||||
|
||||
if (dbr.DialogItemTemplates != null)
|
||||
if (dbr.DialogItemTemplates is not null)
|
||||
{
|
||||
var templates = Array.FindAll(dbr.DialogItemTemplates, dit => dit?.TitleResource != null);
|
||||
var templates = Array.FindAll(dbr.DialogItemTemplates, dit => dit?.TitleResource is not null);
|
||||
if (Array.FindIndex(templates, dit => dit?.TitleResource?.Contains(title) == true) > -1)
|
||||
resources.Add(dbr);
|
||||
}
|
||||
else if (dbr.ExtendedDialogItemTemplates != null)
|
||||
else if (dbr.ExtendedDialogItemTemplates is not null)
|
||||
{
|
||||
var templates = Array.FindAll(dbr.ExtendedDialogItemTemplates, edit => edit?.TitleResource != null);
|
||||
var templates = Array.FindAll(dbr.ExtendedDialogItemTemplates, edit => edit?.TitleResource is not null);
|
||||
if (Array.FindIndex(templates, edit => edit?.TitleResource?.Contains(title) == true) > -1)
|
||||
resources.Add(dbr);
|
||||
}
|
||||
@@ -1718,7 +1718,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
{
|
||||
_dataSource.SeekIfPossible(overlayOffset, SeekOrigin.Begin);
|
||||
var header = WiseOverlayHeader.Create(_dataSource);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
return overlayOffset;
|
||||
}
|
||||
|
||||
@@ -1730,7 +1730,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
_dataSource.SeekIfPossible(sectionOffset, SeekOrigin.Begin);
|
||||
|
||||
var header = WiseOverlayHeader.Create(_dataSource);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
return sectionOffset;
|
||||
|
||||
// Check after the resource table
|
||||
@@ -1741,7 +1741,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
_dataSource.SeekIfPossible(afterResourceOffset, SeekOrigin.Begin);
|
||||
|
||||
header = WiseOverlayHeader.Create(_dataSource);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
return afterResourceOffset;
|
||||
|
||||
// Data following padding data
|
||||
@@ -1750,7 +1750,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
afterResourceOffset = _dataSource.Position;
|
||||
header = WiseOverlayHeader.Create(_dataSource);
|
||||
if (header != null)
|
||||
if (header is not null)
|
||||
return afterResourceOffset;
|
||||
}
|
||||
}
|
||||
@@ -1832,7 +1832,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
var entry = table.Entries[i];
|
||||
var newTypes = new List<object>(types ?? []);
|
||||
|
||||
if (entry.Name?.UnicodeString != null)
|
||||
if (entry.Name?.UnicodeString is not null)
|
||||
newTypes.Add(Encoding.Unicode.GetString(entry.Name.UnicodeString));
|
||||
else
|
||||
newTypes.Add(entry.IntegerID);
|
||||
@@ -1846,9 +1846,9 @@ namespace SabreTools.Serialization.Wrappers
|
||||
/// </summary>
|
||||
private void ParseResourceDirectoryEntry(Data.Models.PortableExecutable.Resource.DirectoryEntry entry, List<object> types)
|
||||
{
|
||||
if (entry.DataEntry != null)
|
||||
if (entry.DataEntry is not null)
|
||||
ParseResourceDataEntry(entry.DataEntry, types);
|
||||
else if (entry.Subdirectory != null)
|
||||
else if (entry.Subdirectory is not null)
|
||||
ParseResourceDirectoryTable(entry.Subdirectory, types);
|
||||
}
|
||||
|
||||
@@ -1870,7 +1870,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
object? value = entry.Data;
|
||||
|
||||
// If we have a known resource type
|
||||
if (types != null && types.Count > 0 && types[0] is uint resourceType)
|
||||
if (types is not null && types.Count > 0 && types[0] is uint resourceType)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -1954,7 +1954,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
// If we have a custom resource type
|
||||
else if (types != null && types.Count > 0 && types[0] is string)
|
||||
else if (types is not null && types.Count > 0 && types[0] is string)
|
||||
{
|
||||
value = entry.Data;
|
||||
}
|
||||
@@ -2145,7 +2145,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
_sectionData ??= new byte[SectionNames.Length][];
|
||||
|
||||
// If we already have cached data, just use that immediately
|
||||
if (_sectionData[index] != null && _sectionData[index].Length > 0)
|
||||
if (_sectionData[index] is not null && _sectionData[index].Length > 0)
|
||||
return _sectionData[index];
|
||||
|
||||
// Populate the raw section data based on the source
|
||||
@@ -2219,7 +2219,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
_sectionStringData ??= new List<string>?[SectionNames.Length];
|
||||
|
||||
// If we already have cached data, just use that immediately
|
||||
if (_sectionStringData[index] != null)
|
||||
if (_sectionStringData[index] is not null)
|
||||
return _sectionStringData[index];
|
||||
|
||||
// Get the section data, if possible
|
||||
@@ -2287,7 +2287,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return null;
|
||||
|
||||
// If we already have cached data, just use that immediately
|
||||
if (_tableData[index] != null && _tableData[index].Length > 0)
|
||||
if (_tableData[index] is not null && _tableData[index].Length > 0)
|
||||
return _tableData[index];
|
||||
|
||||
// Get the table from the optional header
|
||||
@@ -2322,7 +2322,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
return null;
|
||||
|
||||
// If we already have cached data, just use that immediately
|
||||
if (_tableStringData[index] != null)
|
||||
if (_tableStringData[index] is not null)
|
||||
return _tableStringData[index];
|
||||
|
||||
// Get the table data, if possible
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
builder.AppendLine(fileDescriptor.ExpandedFileSize, " Expanded file size");
|
||||
builder.AppendLine(fileDescriptor.FileTime, " File time");
|
||||
builder.AppendLine(fileDescriptor.FileDate, " File date");
|
||||
if (fileDescriptor.Unknown != null)
|
||||
if (fileDescriptor.Unknown is not null)
|
||||
builder.AppendLine(fileDescriptor.Unknown.Value, " Unknown (Checksum?)");
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
for (int i = 1; ; i++)
|
||||
{
|
||||
string nextPart = nextPartFunc(i);
|
||||
if (directory != null)
|
||||
if (directory is not null)
|
||||
nextPart = Path.Combine(directory, nextPart);
|
||||
|
||||
if (!File.Exists(nextPart))
|
||||
@@ -247,7 +247,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outDir, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
entry.WriteToFile(filename);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
|
||||
// Get the parent directory
|
||||
string? folderName = GetParentName(index);
|
||||
if (folderName != null)
|
||||
if (folderName is not null)
|
||||
parentNames.Add(folderName);
|
||||
|
||||
// TODO: Should the section name/alias be used in the path as well?
|
||||
@@ -127,7 +127,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !System.IO.Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !System.IO.Directory.Exists(directoryName))
|
||||
System.IO.Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -220,10 +220,10 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Get the folder
|
||||
Folder? folder = Directory switch
|
||||
{
|
||||
Directory4 d4 => Array.Find(d4.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory5 d5 => Array.Find(d5.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory6 d6 => Array.Find(d6.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory7 d7 => Array.Find(d7.Folders, f => f != null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory4 d4 => Array.Find(d4.Folders, f => f is not null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory5 d5 => Array.Find(d5.Folders, f => f is not null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory6 d6 => Array.Find(d6.Folders, f => f is not null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
Directory7 d7 => Array.Find(d7.Folders, f => f is not null && index >= f.FileStartIndex && index <= f.FileEndIndex),
|
||||
_ => default,
|
||||
};
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
for (int i = 1; ; i++)
|
||||
{
|
||||
string nextPart = nextPartFunc(i);
|
||||
if (directory != null)
|
||||
if (directory is not null)
|
||||
nextPart = Path.Combine(directory, nextPart);
|
||||
|
||||
if (!File.Exists(nextPart))
|
||||
@@ -215,7 +215,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
entry.WriteToFile(filename);
|
||||
@@ -257,7 +257,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write to file
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Write the file
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
}
|
||||
|
||||
// If we have preload data, prepend it
|
||||
if (data != null && directoryItem.PreloadData != null)
|
||||
if (data is not null && directoryItem.PreloadData is not null)
|
||||
data = [.. directoryItem.PreloadData, .. data];
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
get
|
||||
{
|
||||
// Use the cached value, if it exists
|
||||
if (field != null)
|
||||
if (field is not null)
|
||||
return field;
|
||||
|
||||
// If we don't have a source filename
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Ensure the full output directory exists
|
||||
filename = Path.Combine(outputDirectory, filename);
|
||||
var directoryName = Path.GetDirectoryName(filename);
|
||||
if (directoryName != null && !Directory.Exists(directoryName))
|
||||
if (directoryName is not null && !Directory.Exists(directoryName))
|
||||
Directory.CreateDirectory(directoryName);
|
||||
|
||||
// Try to write the data
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace SabreTools.Serialization.Wrappers
|
||||
// Strip the extension and rebuild
|
||||
string? directory = Path.GetDirectoryName(filename);
|
||||
filename = Path.GetFileNameWithoutExtension(filename);
|
||||
if (directory != null)
|
||||
if (directory is not null)
|
||||
filename = Path.Combine(directory, filename);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user