Use List<T> instead of Array<T> in device report.

This commit is contained in:
2018-11-27 01:42:25 +00:00
parent 9c83c3d296
commit 7b45cf1b92
4 changed files with 76 additions and 64 deletions

View File

@@ -37,6 +37,7 @@
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.Decoders.ATA;
@@ -99,7 +100,7 @@ namespace DiscImageChef.CommonTypes.Metadata
public int Id { get; set; }
public byte[] Identify { get; set; }
public TestedMedia ReadCapabilities { get; set; }
public TestedMedia[] RemovableMedias { get; set; }
public List<TestedMedia> RemovableMedias { get; set; }
}
public class Chs
@@ -117,14 +118,14 @@ namespace DiscImageChef.CommonTypes.Metadata
[JsonIgnore]
public int Id { get; set; }
public byte[] InquiryData { get; set; }
public ScsiPage[] EVPDPages { get; set; }
public List<ScsiPage> EVPDPages { get; set; }
public bool SupportsModeSense6 { get; set; }
public bool SupportsModeSense10 { get; set; }
public bool SupportsModeSubpages { get; set; }
public ScsiMode ModeSense { get; set; }
public Mmc MultiMediaDevice { get; set; }
public TestedMedia ReadCapabilities { get; set; }
public TestedMedia[] RemovableMedias { get; set; }
public List<TestedMedia> RemovableMedias { get; set; }
public Ssc SequentialDevice { get; set; }
public byte[] ModeSense6Data { get; set; }
public byte[] ModeSense10Data { get; set; }
@@ -136,12 +137,12 @@ namespace DiscImageChef.CommonTypes.Metadata
public int Id { get; set; }
public byte? MediumType { get; set; }
public bool WriteProtected { get; set; }
public BlockDescriptor[] BlockDescriptors { get; set; }
public List<BlockDescriptor> BlockDescriptors { get; set; }
public byte? Speed { get; set; }
public byte? BufferedMode { get; set; }
public bool BlankCheckEnabled { get; set; }
public bool DPOandFUA { get; set; }
public ScsiPage[] ModePages { get; set; }
public List<ScsiPage> ModePages { get; set; }
}
public class BlockDescriptor
@@ -168,7 +169,7 @@ namespace DiscImageChef.CommonTypes.Metadata
public int Id { get; set; }
public Modes.ModePage_2A ModeSense2A { get; set; }
public MmcFeatures Features { get; set; }
public TestedMedia[] TestedMedia { get; set; }
public List<TestedMedia> TestedMedia { get; set; }
}
public class MmcFeatures
@@ -407,9 +408,9 @@ namespace DiscImageChef.CommonTypes.Metadata
public uint? MaxBlockLength { get; set; }
public uint? MinBlockLength { get; set; }
public SupportedDensity[] SupportedDensities { get; set; }
public SscSupportedMedia[] SupportedMediaTypes { get; set; }
public TestedSequentialMedia[] TestedMedia { get; set; }
public List<SupportedDensity> SupportedDensities { get; set; }
public List<SscSupportedMedia> SupportedMediaTypes { get; set; }
public List<TestedSequentialMedia> TestedMedia { get; set; }
}
public class TestedSequentialMedia
@@ -423,8 +424,8 @@ namespace DiscImageChef.CommonTypes.Metadata
public byte? MediumType { get; set; }
public string MediumTypeName { get; set; }
public string Model { get; set; }
public SupportedDensity[] SupportedDensities { get; set; }
public SscSupportedMedia[] SupportedMediaTypes { get; set; }
public List<SupportedDensity> SupportedDensities { get; set; }
public List<SscSupportedMedia> SupportedMediaTypes { get; set; }
public byte[] ModeSense6Data { get; set; }
public byte[] ModeSense10Data { get; set; }
@@ -459,7 +460,7 @@ namespace DiscImageChef.CommonTypes.Metadata
[JsonIgnore]
public int Id { get; set; }
public byte MediumType { get; set; }
public DensityCode[] DensityCodes { get; set; }
public List<DensityCode> DensityCodes { get; set; }
public ushort Width { get; set; }
public ushort Length { get; set; }
public string Organization { get; set; }

View File

@@ -30,6 +30,7 @@
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System.Linq;
using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Console;
using DiscImageChef.Decoders.SCSI;
@@ -65,7 +66,7 @@ namespace DiscImageChef.Core.Devices.Report
DensitySupport.DensitySupportHeader? dsh = DensitySupport.DecodeDensity(buffer);
if(dsh.HasValue)
{
report.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
{
report.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
@@ -81,6 +82,8 @@ namespace DiscImageChef.Core.Devices.Report
report.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
report.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
}
report.SupportedDensities = array.ToList();
}
}
@@ -91,7 +94,7 @@ namespace DiscImageChef.Core.Devices.Report
DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer);
if(!mtsh.HasValue) return report;
report.SupportedMediaTypes = new SscSupportedMedia[mtsh.Value.descriptors.Length];
SscSupportedMedia[] array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length];
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
{
report.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
@@ -102,13 +105,15 @@ namespace DiscImageChef.Core.Devices.Report
report.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
if(mtsh.Value.descriptors[i].densityCodes == null) continue;
report.SupportedMediaTypes[i].DensityCodes =
new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
DensityCode[] array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
report.SupportedMediaTypes[i].DensityCodes[j] =
new DensityCode {Code = mtsh.Value.descriptors[i].densityCodes[j]};
report.SupportedMediaTypes[i].DensityCodes = array3.ToList();
}
report.SupportedMediaTypes = array2.ToList();
return report;
}
@@ -149,7 +154,7 @@ namespace DiscImageChef.Core.Devices.Report
DensitySupport.DensitySupportHeader? dsh = DensitySupport.DecodeDensity(buffer);
if(dsh.HasValue)
{
seqTest.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];
for(int i = 0; i < dsh.Value.descriptors.Length; i++)
{
seqTest.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
@@ -165,6 +170,8 @@ namespace DiscImageChef.Core.Devices.Report
seqTest.SupportedDensities[i].Width = dsh.Value.descriptors[i].width;
seqTest.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
}
seqTest.SupportedDensities = array.ToList();
}
}
@@ -175,7 +182,7 @@ namespace DiscImageChef.Core.Devices.Report
DensitySupport.MediaTypeSupportHeader? mtsh = DensitySupport.DecodeMediumType(buffer);
if(mtsh.HasValue)
{
seqTest.SupportedMediaTypes = new SscSupportedMedia[mtsh.Value.descriptors.Length];
SscSupportedMedia[] array = new SscSupportedMedia[mtsh.Value.descriptors.Length];
for(int i = 0; i < mtsh.Value.descriptors.Length; i++)
{
seqTest.SupportedMediaTypes[i].Description = mtsh.Value.descriptors[i].description;
@@ -186,12 +193,14 @@ namespace DiscImageChef.Core.Devices.Report
seqTest.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
if(mtsh.Value.descriptors[i].densityCodes == null) continue;
seqTest.SupportedMediaTypes[i].DensityCodes =
new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
DensityCode[] array2 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];
for(int j = 0; j < mtsh.Value.descriptors.Length; j++)
seqTest.SupportedMediaTypes[i].DensityCodes[j] =
new DensityCode {Code = mtsh.Value.descriptors[i].densityCodes[j]};
seqTest.SupportedMediaTypes[i].DensityCodes = array2.ToList();
}
seqTest.SupportedMediaTypes = array.ToList();
}
}

View File

@@ -58,7 +58,7 @@ namespace DiscImageChef.Core.Devices.Report
return report;
}
public ScsiPage[] ReportEvpdPages()
public List<ScsiPage> ReportEvpdPages()
{
DicConsole.WriteLine("Querying list of SCSI EVPDs...");
bool sense = dev.ScsiInquiry(out byte[] buffer, out _, 0x00);
@@ -79,7 +79,7 @@ namespace DiscImageChef.Core.Devices.Report
evpds.Add(evpd);
}
return evpds.Count > 0 ? evpds.ToArray() : null;
return evpds.Count > 0 ? evpds : null;
}
public void ReportScsiModes(ref DeviceReportV2 report, ref Modes.ModePage_2A cdromMode)
@@ -160,7 +160,7 @@ namespace DiscImageChef.Core.Devices.Report
cdromMode = Modes.DecodeModePage_2A(page.PageResponse);
}
if(modePages.Count > 0) report.SCSI.ModeSense.ModePages = modePages.ToArray();
if(modePages.Count > 0) report.SCSI.ModeSense.ModePages = modePages;
}
public TestedMedia ReportScsiMedia()

View File

@@ -38,10 +38,12 @@ using DiscImageChef.CommonTypes.Enums;
using DiscImageChef.CommonTypes.Metadata;
using DiscImageChef.Console;
using DiscImageChef.Core;
using DiscImageChef.Database;
using DiscImageChef.Database.Models;
using DiscImageChef.Decoders.ATA;
using DiscImageChef.Decoders.SCSI;
using DiscImageChef.Devices;
using Newtonsoft.Json;
using Device = DiscImageChef.Devices.Device;
namespace DiscImageChef.Commands
{
@@ -220,7 +222,7 @@ namespace DiscImageChef.Commands
mediaTests.Add(mediaTest);
}
report.ATA.RemovableMedias = mediaTests.ToArray();
report.ATA.RemovableMedias = mediaTests;
}
else report.ATA.ReadCapabilities = reporter.ReportAta(report.ATA.IdentifyDevice.Value);
@@ -607,7 +609,7 @@ namespace DiscImageChef.Commands
mediaTests.Add(mediaTest);
}
report.SCSI.MultiMediaDevice.TestedMedia = mediaTests.ToArray();
report.SCSI.MultiMediaDevice.TestedMedia = mediaTests;
}
break;
case PeripheralDeviceTypes.SequentialAccess:
@@ -694,7 +696,7 @@ namespace DiscImageChef.Commands
seqTests.Add(seqTest);
}
report.SCSI.SequentialDevice.TestedMedia = seqTests.ToArray();
report.SCSI.SequentialDevice.TestedMedia = seqTests;
}
break;
@@ -828,7 +830,7 @@ namespace DiscImageChef.Commands
mediaTests.Add(mediaTest);
}
report.SCSI.RemovableMedias = mediaTests.ToArray();
report.SCSI.RemovableMedias = mediaTests;
}
else
{