From 647d3fac26b2dca37adf53280ce02a4b929800a2 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 16 Dec 2022 01:16:41 +0000 Subject: [PATCH] Add converters from CICM Metadata to Aaru Metadata. --- AaruMetadata/ATA.cs | 11 +- AaruMetadata/AaruMetadata.cs | 134 +++++++++++++- AaruMetadata/Advertisement.cs | 57 ++++++ AaruMetadata/AudioMedia.cs | 75 ++++++++ AaruMetadata/AudioVideo.cs | 111 +++++++++++ AaruMetadata/Barcode.cs | 11 +- AaruMetadata/BlockMedia.cs | 122 ++++++++++++ AaruMetadata/Book.cs | 38 ++++ AaruMetadata/Checksum.cs | 11 +- AaruMetadata/Contents.cs | 139 ++++++++++++++ AaruMetadata/Dimensions.cs | 14 +- AaruMetadata/Dump.cs | 71 +++++++ AaruMetadata/DumpHardware.cs | 44 +++++ AaruMetadata/FileSystem.cs | 26 +++ AaruMetadata/Layers.cs | 38 ++++ AaruMetadata/LinearMedia.cs | 55 ++++++ AaruMetadata/Magazine.cs | 35 ++++ AaruMetadata/MultiMediaCard.cs | 14 +- AaruMetadata/OpticalDisc.cs | 234 ++++++++++++++++++++++++ AaruMetadata/PCI.cs | 14 +- AaruMetadata/PCMCIA.cs | 14 ++ AaruMetadata/PS3.cs | 12 +- AaruMetadata/Partition.cs | 29 +++ AaruMetadata/RequiredOperatingSystem.cs | 10 + AaruMetadata/SCSI.cs | 51 ++++++ AaruMetadata/Scanning.cs | 140 ++++++++++++++ AaruMetadata/SecureDigital.cs | 14 +- AaruMetadata/Sequence.cs | 15 +- AaruMetadata/Tape.cs | 65 ++++++- AaruMetadata/USB.cs | 13 +- AaruMetadata/UserManual.cs | 24 +++ AaruMetadata/Xbox.cs | 30 +++ 32 files changed, 1649 insertions(+), 22 deletions(-) diff --git a/AaruMetadata/ATA.cs b/AaruMetadata/ATA.cs index 3392e3916..d5e11447d 100644 --- a/AaruMetadata/ATA.cs +++ b/AaruMetadata/ATA.cs @@ -36,14 +36,21 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; +using Schemas; + namespace Aaru.CommonTypes.AaruMetadata; public class ATA { public Dump Identify { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator ATA(ATAType cicm) => cicm is null ? null : new ATA + { + Identify = cicm.Identify + }; } diff --git a/AaruMetadata/AaruMetadata.cs b/AaruMetadata/AaruMetadata.cs index da913d712..931a2fdec 100644 --- a/AaruMetadata/AaruMetadata.cs +++ b/AaruMetadata/AaruMetadata.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -77,5 +78,136 @@ public class Metadata public List LinearMedias { get; set; } public List PciCards { get; set; } public List BlockMedias { get; set; } - public List AudioMedia { get; set; } + public List AudioMedias { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Metadata(CICMMetadataType cicm) + { + if(cicm is null) + return null; + + var metadata = new Metadata + { + Developers = cicm.Developer is null ? null : new List(cicm.Developer), + Publishers = cicm.Publisher is null ? null : new List(cicm.Publisher), + Authors = cicm.Author is null ? null : new List(cicm.Author), + Performers = cicm.Performer is null ? null : new List(cicm.Performer), + Name = cicm.Name, + Version = cicm.Version, + Release = cicm.ReleaseTypeSpecified ? (ReleaseType)cicm.ReleaseType : null, + ReleaseDate = cicm.ReleaseDateSpecified ? cicm.ReleaseDate : null, + PartNumber = cicm.PartNumber, + SerialNumber = cicm.SerialNumber, + Keywords = cicm.Keywords is null ? null : new List(cicm.Keywords), + Categories = cicm.Categories is null ? null : new List(cicm.Categories), + Subcategories = cicm.Subcategories is null ? null : new List(cicm.Subcategories), + Systems = cicm.Systems is null ? null : new List(cicm.Systems) + }; + + if(cicm.Barcodes is not null) + { + metadata.Barcodes = new List(); + + foreach(Schemas.BarcodeType code in cicm.Barcodes) + metadata.Barcodes.Add(code); + } + + if(cicm.Magazine is not null) + { + metadata.Magazines = new List(); + + foreach(MagazineType magazine in cicm.Magazine) + metadata.Magazines.Add(magazine); + } + + if(cicm.Book is not null) + { + metadata.Books = new List(); + + foreach(BookType book in cicm.Book) + metadata.Books.Add(book); + } + + if(cicm.Languages is not null) + { + metadata.Languages = new List(); + + foreach(LanguagesTypeLanguage lng in cicm.Languages) + metadata.Languages.Add((Language)lng); + } + + if(cicm.Architectures is not null) + { + metadata.Architectures = new List(); + + foreach(ArchitecturesTypeArchitecture arch in cicm.Architectures) + metadata.Architectures.Add((Architecture)arch); + } + + if(cicm.RequiredOperatingSystems is not null) + { + metadata.RequiredOperatingSystems = new List(); + + foreach(RequiredOperatingSystemType os in cicm.RequiredOperatingSystems) + metadata.RequiredOperatingSystems.Add(os); + } + + if(cicm.UserManual is not null) + { + metadata.UserManuals = new List(); + + foreach(UserManualType manual in cicm.UserManual) + metadata.UserManuals.Add(manual); + } + + if(cicm.OpticalDisc is not null) + { + metadata.OpticalDiscs = new List(); + + foreach(OpticalDiscType disc in cicm.OpticalDisc) + metadata.OpticalDiscs.Add(disc); + } + + if(cicm.Advertisement is not null) + { + metadata.Advertisements = new List(); + + foreach(AdvertisementType adv in cicm.Advertisement) + metadata.Advertisements.Add(adv); + } + + if(cicm.LinearMedia is not null) + { + metadata.LinearMedias = new List(); + + foreach(LinearMediaType media in cicm.LinearMedia) + metadata.LinearMedias.Add(media); + } + + if(cicm.PCICard is not null) + { + metadata.PciCards = new List(); + + foreach(PCIType pci in cicm.PCICard) + metadata.PciCards.Add(pci); + } + + if(cicm.BlockMedia is not null) + { + metadata.BlockMedias = new List(); + + foreach(BlockMediaType media in cicm.BlockMedia) + metadata.BlockMedias.Add(media); + } + + if(cicm.AudioMedia is not null) + { + metadata.AudioMedias = new List(); + + foreach(AudioMediaType media in cicm.AudioMedia) + metadata.AudioMedias.Add(media); + } + + return metadata; + } } \ No newline at end of file diff --git a/AaruMetadata/Advertisement.cs b/AaruMetadata/Advertisement.cs index 309f8fa9c..eb99ea69f 100644 --- a/AaruMetadata/Advertisement.cs +++ b/AaruMetadata/Advertisement.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -57,4 +59,59 @@ public class Advertisement public List VideoTracks { get; set; } public List SubtitleTracks { get; set; } public Recording Recording { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Advertisement(AdvertisementType cicm) + { + if(cicm is null) + return null; + + var adv = new Advertisement + { + Manufacturer = cicm.Manufacturer, + Product = cicm.Product, + File = cicm.File, + FileSize = cicm.FileSize, + Frames = cicm.FramesSpecified ? cicm.Frames : null, + Duration = cicm.Duration, + MeanFrameRate = cicm.MeanFrameRateSpecified ? cicm.MeanFrameRate : null, + Recording = cicm.Recording + }; + + if(cicm.Checksums is not null) + { + adv.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + adv.Checksums.Add(chk); + } + + if(cicm.AudioTrack is not null) + { + adv.AudioTracks = new List(); + + foreach(AudioTracksType trk in cicm.AudioTrack) + adv.AudioTracks.Add(trk); + } + + if(cicm.VideoTrack is not null) + { + adv.VideoTracks = new List(); + + foreach(VideoTracksType trk in cicm.VideoTrack) + adv.VideoTracks.Add(trk); + } + + if(cicm.SubtitleTrack is null) + return adv; + + { + adv.SubtitleTracks = new List(); + + foreach(SubtitleTracksType trk in cicm.SubtitleTrack) + adv.SubtitleTracks.Add(trk); + } + + return adv; + } } diff --git a/AaruMetadata/AudioMedia.cs b/AaruMetadata/AudioMedia.cs index cdb2e4aa9..b806fb056 100644 --- a/AaruMetadata/AudioMedia.cs +++ b/AaruMetadata/AudioMedia.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -59,6 +61,54 @@ public class AudioMedia public DimensionsNew Dimensions { get; set; } public Scans Scans { get; set; } public List DumpHardware { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator AudioMedia(AudioMediaType cicm) + { + if(cicm is null) + return null; + + var media = new AudioMedia + { + Image = cicm.Image, + Size = cicm.Size, + Sequence = cicm.Sequence, + PartNumber = cicm.PartNumber, + SerialNumber = cicm.SerialNumber, + Manufacturer = cicm.Manufacturer, + Model = cicm.Model, + AccoustID = cicm.AccoustID, + CopyProtection = cicm.CopyProtection, + Dimensions = cicm.Dimensions, + Scans = cicm.Scans + }; + + if(cicm.Checksums is not null) + { + media.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + media.Checksums.Add(chk); + } + + if(cicm.Block is not null) + { + media.Blocks = new List(); + + foreach(AudioBlockType blk in cicm.Block) + media.Blocks.Add(blk); + } + + if(cicm.DumpHardwareArray is null) + return media; + + media.DumpHardware = new List(); + + foreach(DumpHardwareType hw in cicm.DumpHardwareArray) + media.DumpHardware.Add(hw); + + return media; + } } public class AudioBlock @@ -68,4 +118,29 @@ public class AudioBlock public string AccoustID { get; set; } public List Checksums { get; set; } public string Format { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator AudioBlock(AudioBlockType cicm) + { + if(cicm is null) + return null; + + var blk = new AudioBlock + { + Image = cicm.Image, + Size = cicm.Size, + AccoustID = cicm.AccoustID, + Format = cicm.Format + }; + + if(cicm.Checksums is null) + return blk; + + blk.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + blk.Checksums.Add(chk); + + return blk; + } } diff --git a/AaruMetadata/AudioVideo.cs b/AaruMetadata/AudioVideo.cs index 324076c69..8ff335f7f 100644 --- a/AaruMetadata/AudioVideo.cs +++ b/AaruMetadata/AudioVideo.cs @@ -40,6 +40,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Text.Json.Serialization; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -55,6 +56,33 @@ public class AudioTrack public uint Channels { get; set; } public double SampleRate { get; set; } public long MeanBitrate { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator AudioTrack(AudioTracksType cicm) + { + if(cicm is null) + return null; + + var trk = new AudioTrack + { + Number = cicm.TrackNumber, + AccoustID = cicm.AccoustID, + Codec = cicm.Codec, + Channels = cicm.Channels, + SampleRate = cicm.SampleRate, + MeanBitrate = cicm.MeanBitrate + }; + + if(cicm.Languages is null) + return trk; + + trk.Languages = new List(); + + foreach(LanguagesTypeLanguage lng in cicm.Languages) + trk.Languages.Add((Language)lng); + + return trk; + } } public class VideoTrack @@ -67,6 +95,33 @@ public class VideoTrack public long MeanBitrate { get; set; } [JsonPropertyName("3D")] public bool ThreeD { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator VideoTrack(VideoTracksType cicm) + { + if(cicm is null) + return null; + + var trk = new VideoTrack + { + Number = cicm.TrackNumber, + Codec = cicm.Codec, + Horizontal = cicm.Horizontal, + Vertical = cicm.Vertical, + MeanBitrate = cicm.MeanBitrate, + ThreeD = cicm.ThreeD + }; + + if(cicm.Languages is null) + return trk; + + trk.Languages = new List(); + + foreach(LanguagesTypeLanguage lng in cicm.Languages) + trk.Languages.Add((Language)lng); + + return trk; + } } public class SubtitleTrack @@ -74,6 +129,29 @@ public class SubtitleTrack public List Languages { get; set; } public uint Number { get; set; } public string Codec { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator SubtitleTrack(SubtitleTracksType cicm) + { + if(cicm is null) + return null; + + var sub = new SubtitleTrack + { + Number = cicm.TrackNumber, + Codec = cicm.Codec + }; + + if(cicm.Languages is null) + return sub; + + sub.Languages = new List(); + + foreach(LanguagesTypeLanguage lng in cicm.Languages) + sub.Languages.Add((Language)lng); + + return sub; + } } public class Recording @@ -84,12 +162,45 @@ public class Recording public DateTime Timestamp { get; set; } public List Software { get; set; } public Coordinates Coordinates { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Recording(RecordingType cicm) + { + if(cicm is null) + return null; + + var recording = new Recording + { + Broadcaster = cicm.Broadcaster, + BroadcastPlatform = cicm.BroadcastPlatform, + SourceFormat = (SourceFormat)cicm.SourceFormat, + Timestamp = cicm.Timestamp, + Coordinates = cicm.Coordinates + }; + + if(cicm.Software is null) + return recording; + + recording.Software = new List(); + + foreach(SoftwareType sw in cicm.Software) + recording.Software.Add(sw); + + return recording; + } } public class Coordinates { public double Latitude { get; set; } public double Longitude { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Coordinates(CoordinatesType cicm) => cicm is null ? null : new Coordinates + { + Latitude = cicm.Latitude, + Longitude = cicm.Longitude + }; } [JsonConverter(typeof(JsonStringEnumMemberConverter)), SuppressMessage("ReSharper", "InconsistentNaming")] diff --git a/AaruMetadata/Barcode.cs b/AaruMetadata/Barcode.cs index cde1ad0ec..6d828ac87 100644 --- a/AaruMetadata/Barcode.cs +++ b/AaruMetadata/Barcode.cs @@ -36,11 +36,11 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; + namespace Aaru.CommonTypes.AaruMetadata; public enum BarcodeType @@ -61,4 +61,11 @@ public class Barcode { public BarcodeType Type { get; set; } public string Value { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Barcode(Schemas.BarcodeType cicm) => cicm is null ? null : new Barcode + { + Type = (BarcodeType)cicm.type, + Value = cicm.Value + }; } diff --git a/AaruMetadata/BlockMedia.cs b/AaruMetadata/BlockMedia.cs index 204e850ce..1319e0bc7 100644 --- a/AaruMetadata/BlockMedia.cs +++ b/AaruMetadata/BlockMedia.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -81,6 +83,96 @@ public class BlockMedia public string MediaType { get; set; } public string MediaSubType { get; set; } public string Interface { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator BlockMedia(BlockMediaType cicm) + { + if(cicm is null) + return null; + + var media = new BlockMedia + { + Image = cicm.Image, + Size = cicm.Size, + Sequence = cicm.Sequence, + Manufacturer = cicm.Manufacturer, + Model = cicm.Model, + Serial = cicm.Serial, + Firmware = cicm.Firmware, + PartNumber = cicm.PartNumber, + SerialNumber = cicm.SerialNumber, + PhysicalBlockSize = cicm.PhysicalBlockSize, + LogicalBlockSize = cicm.LogicalBlockSize, + LogicalBlocks = cicm.LogicalBlocks, + Scans = cicm.Scans, + ATA = cicm.ATA, + Pci = cicm.PCI, + Pcmcia = cicm.PCMCIA, + SecureDigital = cicm.SecureDigital, + MultiMediaCard = cicm.MultiMediaCard, + SCSI = cicm.SCSI, + Usb = cicm.USB, + Mam = cicm.MAM, + Heads = cicm.HeadsSpecified ? cicm.Heads : null, + Cylinders = cicm.CylindersSpecified ? cicm.Cylinders : null, + SectorsPerTrack = cicm.SectorsPerTrackSpecified ? cicm.SectorsPerTrack : null, + CopyProtection = cicm.CopyProtection, + Dimensions = cicm.Dimensions, + MediaType = cicm.DiskType, + MediaSubType = cicm.DiskSubType, + Interface = cicm.Interface + }; + + if(cicm.Checksums is not null) + { + media.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + media.Checksums.Add(chk); + } + + if(cicm.ContentChecksums is not null) + { + media.ContentChecksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.ContentChecksums) + media.ContentChecksums.Add(chk); + } + + if(cicm.VariableBlockSize is not null) + { + media.VariableBlockSize = new List(); + + foreach(BlockSizeType blkSize in cicm.VariableBlockSize) + media.VariableBlockSize.Add(blkSize); + } + + if(cicm.TapeInformation is not null) + { + media.TapeInformation = new List(); + + foreach(TapePartitionType tapeInformation in cicm.TapeInformation) + media.TapeInformation.Add(tapeInformation); + } + + if(cicm.FileSystemInformation is not null) + { + media.FileSystemInformation = new List(); + + foreach(PartitionType fsInfo in cicm.FileSystemInformation) + media.FileSystemInformation.Add(fsInfo); + } + + if(cicm.DumpHardwareArray is null) + return media; + + media.DumpHardware = new List(); + + foreach(DumpHardwareType hw in cicm.DumpHardwareArray) + media.DumpHardware.Add(hw); + + return media; + } } public class BlockTrack @@ -95,4 +187,34 @@ public class BlockTrack public uint BytesPerSector { get; set; } public List Checksums { get; set; } public string Format { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator BlockTrack(BlockTrackType cicm) + { + if(cicm is null) + return null; + + var trk = new BlockTrack + { + Image = cicm.Image, + Size = cicm.Size, + Head = cicm.Head, + Cylinder = cicm.Cylinder, + StartSector = cicm.StartSector, + EndSector = cicm.EndSector, + Sectors = cicm.Sectors, + BytesPerSector = cicm.BytesPerSector, + Format = cicm.Format + }; + + if(cicm.Checksums is null) + return trk; + + trk.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + trk.Checksums.Add(chk); + + return trk; + } } diff --git a/AaruMetadata/Book.cs b/AaruMetadata/Book.cs index 98006a7b7..fcf7382f6 100644 --- a/AaruMetadata/Book.cs +++ b/AaruMetadata/Book.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -56,4 +57,41 @@ public class Book public uint? Pages { get; set; } public string PageSize { get; set; } public Scan Scan { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Book(BookType cicm) + { + if(cicm is null) + return null; + + var book = new Book + { + Cover = cicm.Cover, + Name = cicm.Name, + Editorial = cicm.Editorial, + Author = cicm.Author, + PublicationDate = cicm.PublicationDateSpecified ? cicm.PublicationDate : null, + Pages = cicm.PagesSpecified ? cicm.Pages : null, + PageSize = cicm.PageSize, + Scan = cicm.Scan + }; + + if(cicm.Barcodes is not null) + { + book.Barcodes = new List(); + + foreach(Schemas.BarcodeType code in cicm.Barcodes) + book.Barcodes.Add(code); + } + + if(cicm.Language is null) + return book; + + book.Languages = new List(); + + foreach(LanguagesTypeLanguage lng in cicm.Language) + book.Languages.Add((Language)lng); + + return book; + } } diff --git a/AaruMetadata/Checksum.cs b/AaruMetadata/Checksum.cs index 342741626..4e4bbe963 100644 --- a/AaruMetadata/Checksum.cs +++ b/AaruMetadata/Checksum.cs @@ -36,17 +36,24 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; + namespace Aaru.CommonTypes.AaruMetadata; public class Checksum { public ChecksumType Type { get; set; } public string Value { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Checksum(Schemas.ChecksumType cicm) => cicm is null ? null : new Checksum + { + Value = cicm.Value, + Type = (ChecksumType)cicm.type + }; } public enum ChecksumType diff --git a/AaruMetadata/Contents.cs b/AaruMetadata/Contents.cs index 15d99d538..59fae2d05 100644 --- a/AaruMetadata/Contents.cs +++ b/AaruMetadata/Contents.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -49,6 +50,36 @@ public class FilesystemContents public List Files { get; set; } public List Directories { get; set; } public string Namespace { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator FilesystemContents(FilesystemContentsType cicm) + { + if(cicm is null) + return null; + + var fs = new FilesystemContents + { + Namespace = cicm.@namespace + }; + + if(cicm.File is not null) + { + fs.Files = new List(); + + foreach(ContentsFileType file in cicm.File) + fs.Files.Add(file); + } + + if(cicm.Directory is null) + return fs; + + fs.Directories = new List(); + + foreach(DirectoryType dir in cicm.Directory) + fs.Directories.Add(dir); + + return fs; + } } public class ContentsFile @@ -69,6 +100,49 @@ public class ContentsFile public ulong Links { get; set; } public ulong? PosixUserId { get; set; } public ulong Length { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator ContentsFile(ContentsFileType cicm) + { + if(cicm is null) + return null; + + var file = new ContentsFile + { + Name = cicm.name, + CreationTime = cicm.creationTimeSpecified ? cicm.creationTime : null, + AccessTime = cicm.accessTimeSpecified ? cicm.accessTime : null, + StatusChangeTime = cicm.statusChangeTimeSpecified ? cicm.statusChangeTime : null, + BackupTime = cicm.backupTimeSpecified ? cicm.backupTime : null, + LastWriteTime = cicm.lastWriteTimeSpecified ? cicm.lastWriteTime : null, + Attributes = cicm.attributes, + PosixMode = cicm.posixModeSpecified ? cicm.posixMode : null, + DeviceNumber = cicm.deviceNumberSpecified ? cicm.deviceNumber : null, + PosixGroupId = cicm.posixGroupIdSpecified ? cicm.posixGroupId : null, + Inode = cicm.inode, + Links = cicm.links, + PosixUserId = cicm.posixUserIdSpecified ? cicm.posixUserId : null, + Length = cicm.length + }; + + if(cicm.Checksums is not null) + { + file.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + file.Checksums.Add(chk); + } + + if(cicm.ExtendedAttributes is null) + return file; + + file.ExtendedAttributes = new List(); + + foreach(ExtendedAttributeType xa in cicm.ExtendedAttributes) + file.ExtendedAttributes.Add(xa); + + return file; + } } public class ExtendedAttribute @@ -76,6 +150,29 @@ public class ExtendedAttribute public List Checksums { get; set; } public string Name { get; set; } public ulong Length { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator ExtendedAttribute(ExtendedAttributeType cicm) + { + if(cicm is null) + return null; + + var xa = new ExtendedAttribute + { + Name = cicm.name, + Length = cicm.length + }; + + if(cicm.Checksums is null) + return xa; + + xa.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + xa.Checksums.Add(chk); + + return xa; + } } public class Directory @@ -95,4 +192,46 @@ public class Directory public ulong? Inode { get; set; } public ulong? Links { get; set; } public ulong? PosixUserId { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Directory(DirectoryType cicm) + { + if(cicm is null) + return null; + + var dir = new Directory + { + Name = cicm.name, + CreationTime = cicm.creationTimeSpecified ? cicm.creationTime : null, + AccessTime = cicm.accessTimeSpecified ? cicm.accessTime : null, + StatusChangeTime = cicm.statusChangeTimeSpecified ? cicm.statusChangeTime : null, + BackupTime = cicm.backupTimeSpecified ? cicm.backupTime : null, + LastWriteTime = cicm.lastWriteTimeSpecified ? cicm.lastWriteTime : null, + Attributes = cicm.attributes, + PosixMode = cicm.posixModeSpecified ? cicm.posixMode : null, + DeviceNumber = cicm.deviceNumberSpecified ? cicm.deviceNumber : null, + PosixGroupId = cicm.posixGroupIdSpecified ? cicm.posixGroupId : null, + Inode = cicm.inodeSpecified ? cicm.inode : null, + Links = cicm.linksSpecified ? cicm.links : null, + PosixUserId = cicm.posixUserIdSpecified ? cicm.posixUserId : null + }; + + if(cicm.Directory is not null) + { + dir.Directories = new List(); + + foreach(DirectoryType d in cicm.Directory) + dir.Directories.Add(d); + } + + if(cicm.File is null) + return dir; + + dir.Files = new List(); + + foreach(ContentsFileType file in cicm.File) + dir.Files.Add(file); + + return dir; + } } diff --git a/AaruMetadata/Dimensions.cs b/AaruMetadata/Dimensions.cs index 8b71cef44..328a85e22 100644 --- a/AaruMetadata/Dimensions.cs +++ b/AaruMetadata/Dimensions.cs @@ -36,11 +36,12 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; +using Schemas; + namespace Aaru.CommonTypes.AaruMetadata; public class DimensionsNew @@ -49,4 +50,13 @@ public class DimensionsNew public double? Height { get; set; } public double? Width { get; set; } public double Thickness { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator DimensionsNew(DimensionsType cicm) => cicm is null ? null : new DimensionsNew + { + Diameter = cicm.DiameterSpecified ? cicm.Diameter : null, + Height = cicm.HeightSpecified ? cicm.Height : null, + Width = cicm.WidthSpecified ? cicm.Width : null, + Thickness = cicm.Thickness + }; } diff --git a/AaruMetadata/Dump.cs b/AaruMetadata/Dump.cs index 318d2e4fb..d89ecb2c6 100644 --- a/AaruMetadata/Dump.cs +++ b/AaruMetadata/Dump.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -48,6 +50,14 @@ public class Image public string Format { get; set; } public ulong? Offset { get; set; } public string Value { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Image(ImageType cicm) => cicm is null ? null : new Image + { + Format = cicm.format, + Offset = cicm.offsetSpecified ? cicm.offset : null, + Value = cicm.Value + }; } public class Dump @@ -55,6 +65,29 @@ public class Dump public string Image { get; set; } public ulong Size { get; set; } public List Checksums { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Dump(DumpType cicm) + { + if(cicm is null) + return null; + + Dump dump = new() + { + Image = cicm.Image, + Size = cicm.Size + }; + + if(cicm.Checksums is null) + return dump; + + dump.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + dump.Checksums.Add(chk); + + return dump; + } } public class Border @@ -63,16 +96,54 @@ public class Border public ulong Size { get; set; } public List Checksums { get; set; } public uint? Session { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Border(BorderType cicm) + { + if(cicm is null) + return null; + + var border = new Border + { + Image = cicm.Image, + Size = cicm.Size, + Session = cicm.sessionSpecified ? cicm.session : null + }; + + if(cicm.Checksums is null) + return border; + + border.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + border.Checksums.Add(chk); + + return border; + } } public class File { public string Format { get; set; } public string Value { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator File(FileType cicm) => cicm is null ? null : new File + { + Format = cicm.format, + Value = cicm.Value + }; } public class BlockSize { public uint StartingBlock { get; set; } public uint Value { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator BlockSize(BlockSizeType cicm) => cicm is null ? null : new BlockSize + { + StartingBlock = cicm.startingBlock, + Value = cicm.Value + }; } \ No newline at end of file diff --git a/AaruMetadata/DumpHardware.cs b/AaruMetadata/DumpHardware.cs index 85ef97f3e..ce4729e91 100644 --- a/AaruMetadata/DumpHardware.cs +++ b/AaruMetadata/DumpHardware.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -52,12 +54,46 @@ public class DumpHardware public string Serial { get; set; } public List Extents { get; set; } public Software Software { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator DumpHardware(DumpHardwareType cicm) + { + if(cicm is null) + return null; + + var hw = new DumpHardware + { + Manufacturer = cicm.Manufacturer, + Model = cicm.Model, + Revision = cicm.Revision, + Firmware = cicm.Firmware, + Serial = cicm.Serial, + Software = cicm.Software + }; + + if(cicm.Extents is null) + return hw; + + hw.Extents = new List(); + + foreach(ExtentType ext in cicm.Extents) + hw.Extents.Add(ext); + + return hw; + } } public class Extent { public ulong Start { get; set; } public ulong End { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Extent(ExtentType cicm) => cicm is null ? null : new Extent + { + Start = cicm.Start, + End = cicm.End + }; } public class Software @@ -65,4 +101,12 @@ public class Software public string Name { get; set; } public string Version { get; set; } public string OperatingSystem { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Software(SoftwareType cicm) => cicm is null ? null : new Software + { + Name = cicm.Name, + Version = cicm.Version, + OperatingSystem = cicm.OperatingSystem + }; } diff --git a/AaruMetadata/FileSystem.cs b/AaruMetadata/FileSystem.cs index 8c59c3272..1012b25a3 100644 --- a/AaruMetadata/FileSystem.cs +++ b/AaruMetadata/FileSystem.cs @@ -37,6 +37,7 @@ // ****************************************************************************/ using System; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -65,4 +66,29 @@ public class FileSystem public string DataPreparerIdentifier { get; set; } public string ApplicationIdentifier { get; set; } public FilesystemContents Contents { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator FileSystem(FileSystemType cicm) => cicm is null ? null : new FileSystem + { + Type = cicm.Type, + CreationDate = cicm.CreationDateSpecified ? cicm.CreationDate : null, + ModificationDate = cicm.ModificationDateSpecified ? cicm.ModificationDate : null, + BackupDate = cicm.BackupDateSpecified ? cicm.BackupDate : null, + ClusterSize = cicm.ClusterSize, + Clusters = cicm.Clusters, + Files = cicm.FilesSpecified ? cicm.Files : null, + Bootable = cicm.Bootable, + VolumeSerial = cicm.VolumeSerial, + VolumeName = cicm.VolumeName, + FreeClusters = cicm.FreeClustersSpecified ? cicm.FreeClusters : null, + Dirty = cicm.Dirty, + ExpirationDate = cicm.ExpirationDateSpecified ? cicm.ExpirationDate : null, + EffectiveDate = cicm.EffectiveDateSpecified ? cicm.EffectiveDate : null, + SystemIdentifier = cicm.SystemIdentifier, + VolumeSetIdentifier = cicm.VolumeSetIdentifier, + PublisherIdentifier = cicm.PublisherIdentifier, + DataPreparerIdentifier = cicm.DataPreparerIdentifier, + ApplicationIdentifier = cicm.ApplicationIdentifier, + Contents = cicm.Contents + }; } diff --git a/AaruMetadata/Layers.cs b/AaruMetadata/Layers.cs index fa4074d36..90762d1cb 100644 --- a/AaruMetadata/Layers.cs +++ b/AaruMetadata/Layers.cs @@ -36,8 +36,10 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -48,6 +50,28 @@ public class Layers { public List Sectors { get; set; } public LayerType? Type { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Layers(LayersType cicm) + { + if(cicm is null) + return null; + + var layers = new Layers + { + Type = cicm.typeSpecified ? (LayerType)cicm.type : null + }; + + if(cicm.Sectors is null) + return layers; + + layers.Sectors = new List(); + + foreach(SectorsType sec in cicm.Sectors) + layers.Sectors.Add(sec); + + return layers; + } } [SuppressMessage("ReSharper", "InconsistentNaming")] @@ -60,10 +84,24 @@ public class LayeredText { public uint? Layer { get; set; } public string Text { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator LayeredText(LayeredTextType cicm) => cicm is null ? null : new LayeredText + { + Layer = cicm.layerSpecified ? cicm.layer : null, + Text = cicm.Value + }; } public class Sectors { public uint? Layer { get; set; } public ulong Value { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Sectors(SectorsType cicm) => cicm is null ? null : new Sectors + { + Layer = cicm.layerSpecified ? cicm.layer : null, + Value = cicm.Value + }; } diff --git a/AaruMetadata/LinearMedia.cs b/AaruMetadata/LinearMedia.cs index 66ff64828..135b2bc88 100644 --- a/AaruMetadata/LinearMedia.cs +++ b/AaruMetadata/LinearMedia.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -64,4 +66,57 @@ public class LinearMedia public List DumpHardware { get; set; } public Pcmcia Pcmcia { get; set; } public string CopyProtection { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator LinearMedia(LinearMediaType cicm) + { + if(cicm is null) + return null; + + var linearMedia = new LinearMedia + { + Image = cicm.Image, + Size = cicm.Size, + PartNumber = cicm.PartNumber, + SerialNumber = cicm.SerialNumber, + Title = cicm.Title, + Sequence = cicm.SequenceSpecified ? cicm.Sequence : null, + ImageInterleave = cicm.ImageInterleaveSpecified ? cicm.ImageInterleave : null, + Interleave = cicm.InterleaveSpecified ? cicm.Interleave : null, + Manufacturer = cicm.Manufacturer, + Model = cicm.Model, + Package = cicm.Package, + Interface = cicm.Interface, + Dimensions = cicm.Dimensions, + Scans = cicm.Scans, + Pcmcia = cicm.PCMCIA, + CopyProtection = cicm.CopyProtection + }; + + if(cicm.ImageChecksums is not null) + { + linearMedia.ImageChecksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.ImageChecksums) + linearMedia.ImageChecksums.Add(chk); + } + + if(cicm.Checksums is not null) + { + linearMedia.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + linearMedia.Checksums.Add(chk); + } + + if(cicm.DumpHardwareArray is null) + return linearMedia; + + linearMedia.DumpHardware = new List(); + + foreach(DumpHardwareType hw in cicm.DumpHardwareArray) + linearMedia.DumpHardware.Add(hw); + + return linearMedia; + } } diff --git a/AaruMetadata/Magazine.cs b/AaruMetadata/Magazine.cs index d4924f063..1edd8e38f 100644 --- a/AaruMetadata/Magazine.cs +++ b/AaruMetadata/Magazine.cs @@ -38,6 +38,7 @@ using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -56,4 +57,38 @@ public class Magazine public uint? Pages { get; set; } public string PageSize { get; set; } public Scan Scan { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Magazine(MagazineType cicm) + { + if(cicm is null) + return null; + + var magazine = new Magazine + { + Cover = cicm.Cover, + Name = cicm.Name, + Editorial = cicm.Editorial, + PublicationDate = cicm.PublicationDateSpecified ? cicm.PublicationDate : null, + Number = cicm.NumberSpecified ? cicm.Number : null, + Pages = cicm.PagesSpecified ? cicm.Pages : null, + Scan = cicm.Scan + }; + + if(cicm.Barcodes is not null) + { + magazine.Barcodes = new List(); + + foreach(Schemas.BarcodeType code in cicm.Barcodes) + magazine.Barcodes.Add(code); + } + + if(cicm.Language is null) + return magazine; + + foreach(LanguagesTypeLanguage lng in cicm.Language) + magazine.Languages.Add((Language)lng); + + return magazine; + } } diff --git a/AaruMetadata/MultiMediaCard.cs b/AaruMetadata/MultiMediaCard.cs index 59a08cf41..fab493fae 100644 --- a/AaruMetadata/MultiMediaCard.cs +++ b/AaruMetadata/MultiMediaCard.cs @@ -36,11 +36,12 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; +using Schemas; + namespace Aaru.CommonTypes.AaruMetadata; public class MultiMediaCard @@ -49,4 +50,13 @@ public class MultiMediaCard public Dump CSD { get; set; } public Dump ExtendedCSD { get; set; } public Dump OCR { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator MultiMediaCard(MultiMediaCardType cicm) => cicm is null ? null : new MultiMediaCard + { + CSD = cicm.CSD, + CID = cicm.CID, + ExtendedCSD = cicm.ExtendedCSD, + OCR = cicm.OCR + }; } diff --git a/AaruMetadata/OpticalDisc.cs b/AaruMetadata/OpticalDisc.cs index 70a4b6d85..dddafdcb3 100644 --- a/AaruMetadata/OpticalDisc.cs +++ b/AaruMetadata/OpticalDisc.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -92,6 +94,142 @@ public class OpticalDisc public string MediaCatalogueNumber { get; set; } public List Track { get; set; } public List DumpHardware { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator OpticalDisc(OpticalDiscType cicm) + { + if(cicm is null) + return null; + + var disc = new OpticalDisc + { + Image = cicm.Image, + Size = cicm.Size, + Sequence = cicm.Sequence, + Layers = cicm.Layers, + PartNumber = cicm.PartNumber, + SerialNumber = cicm.SerialNumber, + DiscType = cicm.DiscType, + DiscSubType = cicm.DiscSubType, + Offset = cicm.OffsetSpecified ? cicm.Offset : null, + Tracks = cicm.Tracks, + Sessions = cicm.Sessions, + CopyProtection = cicm.CopyProtection, + Dimensions = cicm.Dimensions, + Case = cicm.Case, + Scans = cicm.Scans, + Pfi = cicm.PFI, + Dmi = cicm.DMI, + Cmi = cicm.CMI, + Bca = cicm.BCA, + Atip = cicm.ATIP, + Adip = cicm.ADIP, + Pma = cicm.PMA, + Dds = cicm.DDS, + Sai = cicm.SAI, + LastRmd = cicm.LastRMD, + Pri = cicm.PRI, + MediaID = cicm.MediaID, + Pfir = cicm.PFIR, + Dcb = cicm.DCB, + Pac = cicm.PAC, + Toc = cicm.TOC, + LeadInCdText = cicm.LeadInCdText, + Xbox = cicm.Xbox, + Ps3Encryption = cicm.PS3Encryption, + MediaCatalogueNumber = cicm.MediaCatalogueNumber + }; + + if(cicm.Checksums is not null) + { + disc.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + disc.Checksums.Add(chk); + } + + if(cicm.RingCode is not null) + { + disc.RingCode = new List(); + + foreach(LayeredTextType lt in cicm.RingCode) + disc.RingCode.Add(lt); + } + + if(cicm.MasteringSID is not null) + { + disc.MasteringSid = new List(); + + foreach(LayeredTextType lt in cicm.MasteringSID) + disc.MasteringSid.Add(lt); + } + + if(cicm.Toolstamp is not null) + { + disc.Toolstamp = new List(); + + foreach(LayeredTextType lt in cicm.Toolstamp) + disc.Toolstamp.Add(lt); + } + + if(cicm.MouldSID is not null) + { + disc.MouldSid = new List(); + + foreach(LayeredTextType lt in cicm.MouldSID) + disc.MouldSid.Add(lt); + } + + if(cicm.MouldText is not null) + { + disc.MouldText = new List(); + + foreach(LayeredTextType lt in cicm.MouldText) + disc.MouldText.Add(lt); + } + + if(cicm.FirstTrackPregrap is not null) + { + disc.FirstTrackPregrap = new List(); + + foreach(BorderType lt in cicm.FirstTrackPregrap) + disc.FirstTrackPregrap.Add(lt); + } + + if(cicm.LeadIn is not null) + { + disc.LeadIn = new List(); + + foreach(BorderType lt in cicm.LeadIn) + disc.LeadIn.Add(lt); + } + + if(cicm.LeadOut is not null) + { + disc.LeadOut = new List(); + + foreach(BorderType lt in cicm.LeadOut) + disc.LeadOut.Add(lt); + } + + if(cicm.Track is not null) + { + disc.Track = new List(); + + foreach(Schemas.TrackType lt in cicm.Track) + disc.Track.Add(lt); + } + + if(cicm.DumpHardwareArray is null) + return cicm; + + disc.DumpHardware = new List(); + + foreach(DumpHardwareType hw in cicm.DumpHardwareArray) + disc.DumpHardware.Add(hw); + + return cicm; + } } public class Track @@ -112,18 +250,82 @@ public class Track public List Checksums { get; set; } public SubChannel SubChannel { get; set; } public List FileSystemInformation { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Track(Schemas.TrackType cicm) + { + if(cicm is null) + return null; + + var trk = new Track + { + Image = cicm.Image, + Size = cicm.Size, + Sequence = cicm.Sequence, + StartMsf = cicm.StartMSF, + EndMsf = cicm.EndMSF, + StartSector = cicm.StartSector, + EndSector = cicm.EndSector, + Flags = cicm.Flags, + ISRC = cicm.ISRC, + Type = (TrackType)cicm.TrackType1, + BytesPerSector = cicm.BytesPerSector, + AccoustID = cicm.AccoustID, + SubChannel = cicm.SubChannel + }; + + if(cicm.Indexes is not null) + { + trk.Indexes = new List(); + + foreach(TrackIndexType idx in cicm.Indexes) + trk.Indexes.Add(idx); + } + + if(cicm.Checksums is not null) + { + trk.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + trk.Checksums.Add(chk); + } + + if(cicm.FileSystemInformation is null) + return trk; + + trk.FileSystemInformation = new List(); + + foreach(PartitionType fs in cicm.FileSystemInformation) + trk.FileSystemInformation.Add(fs); + + return trk; + } } public class TrackSequence { public uint Number { get; set; } public uint Session { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator TrackSequence(TrackSequenceType cicm) => cicm is null ? null : new TrackSequence + { + Number = cicm.TrackNumber, + Session = cicm.Session + }; } public class TrackIndex { public ushort Index { get; set; } public int Value { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator TrackIndex(TrackIndexType cicm) => cicm is null ? null : new TrackIndex + { + Index = cicm.index, + Value = cicm.Value + }; } public class TrackFlags @@ -132,6 +334,15 @@ public class TrackFlags public bool Data { get; set; } public bool CopyPermitted { get; set; } public bool PreEmphasis { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator TrackFlags(TrackFlagsType cicm) => cicm is null ? null : new TrackFlags + { + CopyPermitted = cicm.CopyPermitted, + Data = cicm.Data, + PreEmphasis = cicm.PreEmphasis, + Quadraphonic = cicm.Quadraphonic + }; } public enum TrackType @@ -147,4 +358,27 @@ public class SubChannel public Image Image { get; set; } public ulong Size { get; set; } public List Checksums { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator SubChannel(SubChannelType cicm) + { + if(cicm is null) + return null; + + var subchannel = new SubChannel + { + Image = cicm.Image, + Size = cicm.Size + }; + + if(cicm.Checksums is null) + return subchannel; + + subchannel.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + subchannel.Checksums.Add(chk); + + return subchannel; + } } diff --git a/AaruMetadata/PCI.cs b/AaruMetadata/PCI.cs index f9f14a097..229b0a636 100644 --- a/AaruMetadata/PCI.cs +++ b/AaruMetadata/PCI.cs @@ -36,11 +36,12 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; +using Schemas; + namespace Aaru.CommonTypes.AaruMetadata; public class Pci @@ -52,4 +53,13 @@ public class Pci public Dump Configuration { get; set; } public LinearMedia ExpansionRom { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Pci(PCIType cicm) => cicm is null ? null : new Pci + { + VendorID = cicm.VendorID, + DeviceID = cicm.DeviceID, + Configuration = cicm.Configuration, + ExpansionRom = cicm.ExpansionROM + }; } diff --git a/AaruMetadata/PCMCIA.cs b/AaruMetadata/PCMCIA.cs index a287f3e48..cfccfc4c2 100644 --- a/AaruMetadata/PCMCIA.cs +++ b/AaruMetadata/PCMCIA.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -52,4 +54,16 @@ public class Pcmcia public string Manufacturer { get; set; } public string ProductName { get; set; } public List AdditionalInformation { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Pcmcia(PCMCIAType cicm) => cicm is null ? null : new Pcmcia + { + Cis = cicm.CIS, + Compliance = cicm.Compliance, + ManufacturerCode = cicm.ManufacturerCodeSpecified ? cicm.ManufacturerCode : null, + CardCode = cicm.CardCodeSpecified ? cicm.CardCode : null, + Manufacturer = cicm.Manufacturer, + ProductName = cicm.ProductName, + AdditionalInformation = cicm.AdditionalInformation is null ? null : new List(cicm.AdditionalInformation) + }; } diff --git a/AaruMetadata/PS3.cs b/AaruMetadata/PS3.cs index 73b606592..c0d3e2897 100644 --- a/AaruMetadata/PS3.cs +++ b/AaruMetadata/PS3.cs @@ -36,15 +36,23 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; +using Schemas; + namespace Aaru.CommonTypes.AaruMetadata; public class Ps3Encryption { public string Key { get; set; } public string Serial { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Ps3Encryption(PS3EncryptionType cicm) => cicm is null ? null : new Ps3Encryption + { + Key = cicm.Key, + Serial = cicm.Serial + }; } diff --git a/AaruMetadata/Partition.cs b/AaruMetadata/Partition.cs index 811f0b34c..da5819bde 100644 --- a/AaruMetadata/Partition.cs +++ b/AaruMetadata/Partition.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -52,4 +54,31 @@ public class Partition public ulong EndSector { get; set; } public string Description { get; set; } public List FileSystems { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Partition(PartitionType cicm) + { + if(cicm is null) + return null; + + var part = new Partition + { + Sequence = cicm.Sequence, + Name = cicm.Name, + Type = cicm.Type, + StartSector = cicm.StartSector, + EndSector = cicm.EndSector, + Description = cicm.Description + }; + + if(cicm.FileSystems is null) + return part; + + part.FileSystems = new List(); + + foreach(FileSystemType fs in cicm.FileSystems) + part.FileSystems.Add(fs); + + return part; + } } diff --git a/AaruMetadata/RequiredOperatingSystem.cs b/AaruMetadata/RequiredOperatingSystem.cs index 8dcc4f575..7501b37d3 100644 --- a/AaruMetadata/RequiredOperatingSystem.cs +++ b/AaruMetadata/RequiredOperatingSystem.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -47,4 +49,12 @@ public class RequiredOperatingSystem { public string Name { get; set; } public List Versions { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator RequiredOperatingSystem(RequiredOperatingSystemType cicm) => + cicm is null ? null : new RequiredOperatingSystem + { + Name = cicm.Name, + Versions = cicm.Version is null ? null : new List(cicm.Version) + }; } diff --git a/AaruMetadata/SCSI.cs b/AaruMetadata/SCSI.cs index 50f667fd8..67137c007 100644 --- a/AaruMetadata/SCSI.cs +++ b/AaruMetadata/SCSI.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -50,6 +52,31 @@ public class SCSI public Dump ModeSense { get; set; } public Dump ModeSense10 { get; set; } public Dump LogSense { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator SCSI(SCSIType cicm) + { + if(cicm is null) + return null; + + var scsi = new SCSI + { + Inquiry = cicm.Inquiry, + LogSense = cicm.LogSense, + ModeSense = cicm.ModeSense, + ModeSense10 = cicm.ModeSense10 + }; + + if(cicm.EVPD is null) + return cicm; + + scsi.Evpds = new List(); + + foreach(EVPDType evpd in cicm.EVPD) + scsi.Evpds.Add(evpd); + + return scsi; + } } public class Evpd @@ -58,4 +85,28 @@ public class Evpd public ulong Size { get; set; } public List Checksums { get; set; } public byte? Page { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Evpd(EVPDType cicm) + { + if(cicm is null) + return null; + + var evpd = new Evpd + { + Image = cicm.Image, + Size = cicm.Size, + Page = cicm.pageSpecified ? cicm.page : null + }; + + if(cicm.Checksums is null) + return evpd; + + evpd.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + evpd.Checksums.Add(chk); + + return evpd; + } } diff --git a/AaruMetadata/Scanning.cs b/AaruMetadata/Scanning.cs index 5715608cc..f49152136 100644 --- a/AaruMetadata/Scanning.cs +++ b/AaruMetadata/Scanning.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -50,6 +52,50 @@ public class Scan public List Scanner { get; set; } public List ScanProcessing { get; set; } public List OCR { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Scan(ScanType cicm) + { + if(cicm is null) + return null; + + var scan = new Scan(); + scan.File = cicm.File; + + if(cicm.Checksums is not null) + { + scan.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + scan.Checksums.Add(chk); + } + + if(cicm.Scanner is not null) + { + scan.Scanner = new List(); + + foreach(ScannerType scanner in cicm.Scanner) + scan.Scanner.Add(scanner); + } + + if(cicm.ScanProcessing is not null) + { + scan.ScanProcessing = new List(); + + foreach(ScanProcessingType processing in cicm.ScanProcessing) + scan.ScanProcessing.Add(processing); + } + + if(cicm.OCR is null) + return scan; + + scan.OCR = new List(); + + foreach(OCRType ocr in cicm.OCR) + scan.OCR.Add(ocr); + + return scan; + } } public class Cover @@ -57,12 +103,42 @@ public class Cover public File File { get; set; } public List Checksums { get; set; } public byte[] Thumbnail { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Cover(CoverType cicm) + { + if(cicm is null) + return null; + + var cover = new Cover + { + File = cicm.File, + Thumbnail = cicm.Thumbnail + }; + + if(cicm.Checksums is null) + return cover; + + cover.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + cover.Checksums.Add(chk); + + return cover; + } } public class Case { public CaseType Type { get; set; } public Scans Scans { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Case(Schemas.CaseType cicm) => cicm is null ? null : new Case + { + Type = (CaseType)cicm.CaseType1, + Scans = cicm.Scans + }; } public enum CaseType @@ -82,12 +158,26 @@ public class Scans { public CaseScan Case { get; set; } public MediaScan Media { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Scans(ScansType cicm) => cicm is null ? null : new Scans + { + Case = cicm.CaseScan, + Media = cicm.Scan + }; } public class CaseScan { public CaseScanElement Element { get; set; } public Scan Scan { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator CaseScan(CaseScanType cicm) => cicm is null ? null : new CaseScan + { + Element = (CaseScanElement)cicm.CaseScanElement, + Scan = cicm.Scan + }; } public enum CaseScanElement @@ -101,6 +191,13 @@ public class MediaScan { public MediaScanElement Element { get; set; } public Scan Scan { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator MediaScan(MediaScanType cicm) => cicm is null ? null : new MediaScan + { + Element = (MediaScanElement)cicm.MediaScanElement, + Scan = cicm.Scan + }; } public enum MediaScanElement @@ -117,6 +214,17 @@ public class Scanner public string Serial { get; set; } public string Software { get; set; } public string SoftwareVersion { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Scanner(ScannerType cicm) => cicm is null ? null : new Scanner + { + Author = cicm.Author, + Manufacturer = cicm.Manufacturer, + Model = cicm.Model, + Serial = cicm.Serial, + Software = cicm.Software, + SoftwareVersion = cicm.SoftwareVersion + }; } public class ScanProcessing @@ -124,6 +232,14 @@ public class ScanProcessing public string Author { get; set; } public string Software { get; set; } public string SoftwareVersion { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator ScanProcessing(ScanProcessingType cicm) => cicm is null ? null : new ScanProcessing + { + Author = cicm.Author, + Software = cicm.Software, + SoftwareVersion = cicm.SoftwareVersion + }; } public class OCR @@ -132,4 +248,28 @@ public class OCR public string Software { get; set; } public string SoftwareVersion { get; set; } public List Language { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator OCR(OCRType cicm) + { + if(cicm is null) + return null; + + var ocr = new OCR + { + Author = cicm.Author, + Software = cicm.Software, + SoftwareVersion = cicm.SoftwareVersion + }; + + if(cicm.Language is null) + return ocr; + + ocr.Language = new List(); + + foreach(Language lng in cicm.Language) + ocr.Language.Add(lng); + + return ocr; + } } diff --git a/AaruMetadata/SecureDigital.cs b/AaruMetadata/SecureDigital.cs index 380bd3020..ae607b8ac 100644 --- a/AaruMetadata/SecureDigital.cs +++ b/AaruMetadata/SecureDigital.cs @@ -36,11 +36,12 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; +using Schemas; + namespace Aaru.CommonTypes.AaruMetadata; public class SecureDigital @@ -49,4 +50,13 @@ public class SecureDigital public Dump CSD { get; set; } public Dump SCR { get; set; } public Dump OCR { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator SecureDigital(SecureDigitalType cicm) => cicm is null ? null : new SecureDigital + { + CID = cicm.CID, + CSD = cicm.CSD, + SCR = cicm.SCR, + OCR = cicm.OCR + }; } diff --git a/AaruMetadata/Sequence.cs b/AaruMetadata/Sequence.cs index 6744153f5..cd8346153 100644 --- a/AaruMetadata/Sequence.cs +++ b/AaruMetadata/Sequence.cs @@ -36,11 +36,12 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; +using Schemas; + namespace Aaru.CommonTypes.AaruMetadata; public class Sequence @@ -50,4 +51,14 @@ public class Sequence public uint TotalMedia { get; set; } public byte? Side { get; set; } public byte? Layer { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Sequence(SequenceType cicm) => cicm is null ? null : new Sequence + { + Title = cicm.MediaTitle, + MediaSequence = cicm.MediaSequence, + TotalMedia = cicm.TotalMedia, + Side = cicm.SideSpecified ? cicm.Side : null, + Layer = cicm.LayerSpecified ? cicm.Layer : null + }; } diff --git a/AaruMetadata/Tape.cs b/AaruMetadata/Tape.cs index e5f6c59e5..9d597ef93 100644 --- a/AaruMetadata/Tape.cs +++ b/AaruMetadata/Tape.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -51,7 +53,41 @@ public class TapePartition public ulong StartBlock { get; set; } public ulong EndBlock { get; set; } public List Checksums { get; set; } - public List File { get; set; } + public List Files { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator TapePartition(TapePartitionType cicm) + { + if(cicm is null) + return null; + + TapePartition partition = new() + { + Image = cicm.Image, + Size = cicm.Size, + Sequence = cicm.Sequence, + StartBlock = cicm.StartBlock, + EndBlock = cicm.EndBlock + }; + + if(cicm.Checksums is not null) + { + partition.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + partition.Checksums.Add(chk); + } + + if(cicm.File is null) + return partition; + + partition.Files = new List(); + + foreach(TapeFileType file in cicm.File) + partition.Files.Add(file); + + return partition; + } } public class TapeFile @@ -63,4 +99,31 @@ public class TapeFile public ulong StartBlock { get; set; } public ulong EndBlock { get; set; } public List Checksums { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator TapeFile(TapeFileType cicm) + { + if(cicm is null) + return null; + + var file = new TapeFile + { + Image = cicm.Image, + Size = cicm.Size, + Sequence = cicm.Sequence, + BlockSize = cicm.BlockSize, + StartBlock = cicm.StartBlock, + EndBlock = cicm.EndBlock + }; + + if(cicm.Checksums is null) + return file; + + file.Checksums = new List(); + + foreach(Schemas.ChecksumType chk in cicm.Checksums) + file.Checksums.Add(chk); + + return file; + } } diff --git a/AaruMetadata/USB.cs b/AaruMetadata/USB.cs index 811d12334..a9be39343 100644 --- a/AaruMetadata/USB.cs +++ b/AaruMetadata/USB.cs @@ -36,11 +36,12 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ - - // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global +using System; +using Schemas; + namespace Aaru.CommonTypes.AaruMetadata; public class Usb @@ -48,4 +49,12 @@ public class Usb public ushort VendorID { get; set; } public ushort ProductID { get; set; } public Dump Descriptors { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Usb(USBType cicm) => cicm is null ? null : new Usb + { + VendorID = cicm.VendorID, + ProductID = cicm.ProductID, + Descriptors = cicm.Descriptors + }; } diff --git a/AaruMetadata/UserManual.cs b/AaruMetadata/UserManual.cs index 04b4b716d..78b4a67f8 100644 --- a/AaruMetadata/UserManual.cs +++ b/AaruMetadata/UserManual.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -49,4 +51,26 @@ public class UserManual public uint Pages { get; set; } public string PageSize { get; set; } public Scan Scan { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator UserManual(UserManualType cicm) + { + if(cicm is null) + return null; + + var manual = new UserManual(); + manual.Pages = cicm.Pages; + manual.PageSize = cicm.PageSize; + manual.Scan = cicm.Scan; + + if(cicm.Language is null) + return manual; + + manual.Language = new List(); + + foreach(LanguagesTypeLanguage lng in cicm.Language) + manual.Language.Add((Language)lng); + + return manual; + } } diff --git a/AaruMetadata/Xbox.cs b/AaruMetadata/Xbox.cs index a049621d2..e5551adee 100644 --- a/AaruMetadata/Xbox.cs +++ b/AaruMetadata/Xbox.cs @@ -36,7 +36,9 @@ // Copyright © 2011-2023 Natalia Portillo // ****************************************************************************/ +using System; using System.Collections.Generic; +using Schemas; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global @@ -48,6 +50,25 @@ public class Xbox public Dump Pfi { get; set; } public Dump Dmi { get; set; } public List SecuritySectors { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator Xbox(XboxType cicm) + { + if(cicm is null) + return null; + + Xbox xbox = new(); + xbox.Pfi = cicm.PFI; + xbox.Dmi = cicm.DMI; + + if(cicm.SecuritySectors is null) + return xbox; + + foreach(XboxSecuritySectorsType ss in cicm.SecuritySectors) + xbox.SecuritySectors.Add(ss); + + return xbox; + } } public class XboxSecuritySector @@ -55,4 +76,13 @@ public class XboxSecuritySector public uint RequestVersion { get; set; } public uint RequestNumber { get; set; } public Dump SecuritySectors { get; set; } + + [Obsolete("Will be removed in Aaru 7")] + public static implicit operator XboxSecuritySector(XboxSecuritySectorsType cicm) => + cicm is null ? null : new XboxSecuritySector + { + RequestNumber = cicm.RequestNumber, + RequestVersion = cicm.RequestVersion, + SecuritySectors = cicm.SecuritySectors + }; }