Move some classes around and cleanup

This commit is contained in:
Matt Nadareski
2021-03-29 11:55:29 -07:00
parent 11ce78fca2
commit d963dbbd5f
11 changed files with 54 additions and 49 deletions

View File

@@ -2211,9 +2211,11 @@ namespace MPF.Aaru
// Required variables
uint totalTracks = 0;
CueSheet cueSheet = new CueSheet();
cueSheet.Performer = string.Join(", ", cicmSidecar.Performer ?? new string[0]);
cueSheet.Files = new List<CueFile>();
CueSheet cueSheet = new CueSheet
{
Performer = string.Join(", ", cicmSidecar.Performer ?? new string[0]),
Files = new List<CueFile>(),
};
// Only care about OpticalDisc types
if (cicmSidecar.OpticalDisc == null || cicmSidecar.OpticalDisc.Length == 0)
@@ -2237,17 +2239,21 @@ namespace MPF.Aaru
foreach (TrackType track in opticalDisc.Track)
{
// Create cue track entry
CueTrack cueTrack = new CueTrack();
cueTrack.Number = (int)(track.Sequence?.TrackNumber ?? 0);
cueTrack.DataType = ConvertToDataType(track.TrackType1, track.BytesPerSector);
cueTrack.Flags = ConvertToTrackFlag(track.Flags);
cueTrack.ISRC = track.ISRC;
CueTrack cueTrack = new CueTrack
{
Number = (int)(track.Sequence?.TrackNumber ?? 0),
DataType = ConvertToDataType(track.TrackType1, track.BytesPerSector),
Flags = ConvertToTrackFlag(track.Flags),
ISRC = track.ISRC,
};
// Create cue file entry
CueFile cueFile = new CueFile();
cueFile.FileName = GenerateTrackName(basePath, (int)totalTracks, cueTrack.Number, opticalDisc.DiscType);
cueFile.FileType = CueFileType.BINARY;
cueFile.Tracks = new List<CueTrack>();
CueFile cueFile = new CueFile
{
FileName = GenerateTrackName(basePath, (int)totalTracks, cueTrack.Number, opticalDisc.DiscType),
FileType = CueFileType.BINARY,
Tracks = new List<CueTrack>(),
};
// Add index data
if (track.Indexes != null && track.Indexes.Length > 0)

View File

@@ -1,7 +1,6 @@
using System.IO;
using MPF.Data;
namespace MPF.Utilities
namespace MPF.Data
{
/// <summary>
/// Represents information for a single drive
@@ -54,7 +53,7 @@ namespace MPF.Utilities
/// <summary>
/// DriveInfo object representing the drive, if possible
/// </summary>
private DriveInfo driveInfo = null;
private readonly DriveInfo driveInfo;
public Drive(InternalDriveType? driveType, DriveInfo driveInfo)
{

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -9,11 +8,11 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BurnOutSharp;
using MPF.Data;
using MPF.Redump;
using MPF.Utilities;
using Newtonsoft.Json;
namespace MPF.Utilities
namespace MPF.Data
{
/// <summary>
/// Represents the state of all settings to be used during dumping
@@ -139,40 +138,33 @@ namespace MPF.Utilities
{
// Dumping support
case InternalProgram.Aaru:
this.Parameters = new Aaru.Parameters(parameters);
this.Parameters.ExecutablePath = Options.AaruPath;
this.Parameters = new Aaru.Parameters(parameters) { ExecutablePath = Options.AaruPath };
break;
case InternalProgram.DD:
this.Parameters = new DD.Parameters(parameters);
this.Parameters.ExecutablePath = Options.DDPath;
this.Parameters = new DD.Parameters(parameters) { ExecutablePath = Options.DDPath };
break;
case InternalProgram.DiscImageCreator:
this.Parameters = new DiscImageCreator.Parameters(parameters);
this.Parameters.ExecutablePath = Options.DiscImageCreatorPath;
this.Parameters = new DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath };
break;
// Verification support only
case InternalProgram.CleanRip:
this.Parameters = new CleanRip.Parameters(parameters);
this.Parameters.ExecutablePath = null;
this.Parameters = new CleanRip.Parameters(parameters) { ExecutablePath = null };
break;
case InternalProgram.DCDumper:
this.Parameters = null; // TODO: Create correct parameter type when supported
this.Parameters.ExecutablePath = null;
break;
case InternalProgram.UmdImageCreator:
this.Parameters = new UmdImageCreator.Parameters(parameters);
this.Parameters.ExecutablePath = null;
this.Parameters = new UmdImageCreator.Parameters(parameters) { ExecutablePath = null };
break;
// This should never happen, but it needs a fallback
default:
this.Parameters = new DiscImageCreator.Parameters(parameters);
this.Parameters.ExecutablePath = Options.DiscImageCreatorPath;
this.Parameters = new DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath };
break;
}
@@ -778,9 +770,9 @@ namespace MPF.Utilities
info.CommonDiscInfo.Layer1ToolstampMasteringCode = (Options.AddPlaceholders ? Template.RequiredIfExistsValue : "");
}
info.SizeAndChecksums.CRC32 = info.SizeAndChecksums.CRC32 == null ? (Options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : "") : info.SizeAndChecksums.CRC32;
info.SizeAndChecksums.MD5 = info.SizeAndChecksums.MD5 == null ? (Options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : "") : info.SizeAndChecksums.MD5;
info.SizeAndChecksums.SHA1 = info.SizeAndChecksums.SHA1 == null ? (Options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : "") : info.SizeAndChecksums.SHA1;
info.SizeAndChecksums.CRC32 = info.SizeAndChecksums.CRC32 ?? (Options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : "");
info.SizeAndChecksums.MD5 = info.SizeAndChecksums.MD5 ?? (Options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : "");
info.SizeAndChecksums.SHA1 = info.SizeAndChecksums.SHA1 ?? (Options.AddPlaceholders ? Template.RequiredValue + " [Not automatically generated for UMD]" : "");
info.TracksAndWriteOffsets.ClrMameProData = null;
break;
}
@@ -1181,7 +1173,11 @@ namespace MPF.Utilities
// TODO: Figure out what the addtional layerbreaks indicate
case MediaType.BluRay:
if (layerbreak != default)
if (layerbreak3 != default)
return $"{mediaType.LongName()}-50";
else if (layerbreak2 != default)
return $"{mediaType.LongName()}-50";
else if (layerbreak != default)
return $"{mediaType.LongName()}-50";
else
return $"{mediaType.LongName()}-25";

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace MPF.Utilities
namespace MPF.Data
{
public class IniFile : IDictionary<string, string>
{

View File

@@ -2,7 +2,7 @@
using System.Collections.Concurrent;
using System.Threading.Tasks;
namespace MPF.Utilities
namespace MPF.Data
{
public class ProcessingQueue<T> : IDisposable
{

View File

@@ -1,4 +1,4 @@
namespace MPF.Utilities
namespace MPF.Data
{
/// <summary>
/// Generic success/failure result object, with optional message

View File

@@ -6,7 +6,7 @@ namespace MPF.Utilities
/// <summary>
/// Big endian reading overloads for BinaryReader
/// </summary>
public static class BinaryReaderExtensions
internal static class BinaryReaderExtensions
{
/// <summary>
/// Reads the specified number of bytes from the stream, starting from a specified point in the byte array.

View File

@@ -464,7 +464,7 @@ namespace MPF.Utilities
/// <summary>
/// Long name method cache
/// </summary>
private static ConcurrentDictionary<Type, MethodInfo> LongNameMethods = new ConcurrentDictionary<Type, MethodInfo>();
private static readonly ConcurrentDictionary<Type, MethodInfo> LongNameMethods = new ConcurrentDictionary<Type, MethodInfo>();
/// <summary>
/// Get the string representation of a generic enumerable value
@@ -1455,7 +1455,7 @@ namespace MPF.Utilities
/// <summary>
/// Short name method cache
/// </summary>
private static ConcurrentDictionary<Type, MethodInfo> ShortNameMethods = new ConcurrentDictionary<Type, MethodInfo>();
private static readonly ConcurrentDictionary<Type, MethodInfo> ShortNameMethods = new ConcurrentDictionary<Type, MethodInfo>();
/// <summary>
/// Get the short string representation of a generic enumerable value

View File

@@ -2,7 +2,7 @@
namespace MPF.Utilities
{
public static class Extensions
public static class EnumExtensions
{
/// <summary>
/// Determine the category based on the system

View File

@@ -7,7 +7,7 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using MPF.Utilities;
using MPF.Data;
namespace MPF.UserControls
{

View File

@@ -567,9 +567,11 @@ namespace MPF.Windows
/// <returns>Dialog open result</returns>
private bool? ShowDiscInformationWindow(SubmissionInfo submissionInfo)
{
var discInformationWindow = new DiscInformationWindow(submissionInfo);
discInformationWindow.Owner = this;
discInformationWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
var discInformationWindow = new DiscInformationWindow(submissionInfo)
{
Owner = this,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
};
return discInformationWindow.ShowDialog();
}
@@ -824,9 +826,11 @@ namespace MPF.Windows
/// </summary>
private void OptionsMenuItemClick(object sender, RoutedEventArgs e)
{
var optionsWindow = new OptionsWindow(UIOptions);
optionsWindow.Owner = this;
optionsWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
var optionsWindow = new OptionsWindow(UIOptions)
{
Owner = this,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
};
optionsWindow.Closed += OnOptionsUpdated;
optionsWindow.Show();
}