[Refactor] Use collection expressions.

This commit is contained in:
2024-05-01 04:39:38 +01:00
parent f7ca79b09e
commit 134ce7041e
667 changed files with 12936 additions and 13750 deletions

View File

@@ -68,7 +68,7 @@ public sealed class DecodeMediaTagsViewModel : ViewModelBase
public DecodeMediaTagsViewModel([NotNull] IMediaImage inputFormat)
{
TagsList = new ObservableCollection<MediaTagModel>();
TagsList = [];
_mediaType = inputFormat.Info.MediaType;

View File

@@ -107,8 +107,8 @@ public sealed class ImageChecksumViewModel : ViewModelBase
Md5Checked = true;
Sha1Checked = true;
SpamsumChecked = true;
TrackChecksums = new ObservableCollection<ChecksumModel>();
MediaChecksums = new ObservableCollection<ChecksumModel>();
TrackChecksums = [];
MediaChecksums = [];
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);

View File

@@ -1145,7 +1145,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
Dictionary<byte, string> isrcs = new();
Dictionary<byte, byte> trackFlags = new();
string mcn = null;
HashSet<int> subchannelExtents = new();
HashSet<int> subchannelExtents = [];
Dictionary<byte, int> smallestPregapLbaPerTrack = new();
foreach(SectorTagType tag in _inputFormat.Info.ReadableSectorTags.Where(t => t == SectorTagType.CdTrackIsrc)
@@ -1436,12 +1436,7 @@ public sealed class ImageConvertViewModel : ViewModelBase
{
foreach(KeyValuePair<byte, byte> flags in trackFlags)
{
outputOptical.WriteSectorTag(new[]
{
flags.Value
},
flags.Key,
SectorTagType.CdTrackFlags);
outputOptical.WriteSectorTag([flags.Value], flags.Key, SectorTagType.CdTrackFlags);
}
}
@@ -2130,10 +2125,13 @@ public sealed class ImageConvertViewModel : ViewModelBase
dlgMetadata.Filters?.Add(new FileDialogFilter
{
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[]
{
".json"
})
Extensions =
[
..new[]
{
".json"
}
]
});
string[] result = await dlgMetadata.ShowAsync(_view);
@@ -2178,10 +2176,13 @@ public sealed class ImageConvertViewModel : ViewModelBase
dlgMetadata.Filters?.Add(new FileDialogFilter
{
Name = UI.Dialog_Choose_existing_resume_file,
Extensions = new List<string>(new[]
{
".json"
})
Extensions =
[
..new[]
{
".json"
}
]
});
string[] result = await dlgMetadata.ShowAsync(_view);

View File

@@ -86,7 +86,7 @@ public sealed class ImageEntropyViewModel : ViewModelBase
{
_inputFormat = inputFormat;
_view = view;
TrackEntropy = new ObservableCollection<TrackEntropyModel>();
TrackEntropy = [];
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);

View File

@@ -31,7 +31,6 @@
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reactive;
@@ -331,10 +330,13 @@ public sealed class ImageSidecarViewModel : ViewModelBase
dlgDestination.Filters?.Add(new FileDialogFilter
{
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[]
{
"*.json"
})
Extensions =
[
..new[]
{
"*.json"
}
]
});
string result = await dlgDestination.ShowAsync(_view);

View File

@@ -100,8 +100,8 @@ public sealed class ImageVerifyViewModel : ViewModelBase
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
_inputFormat = inputFormat;
_cancel = false;
ErrorList = new ObservableCollection<LbaModel>();
UnknownList = new ObservableCollection<LbaModel>();
ErrorList = [];
UnknownList = [];
VerifyImageEnabled = true;
VerifySectorsEnabled = true;
CloseVisible = true;
@@ -447,8 +447,8 @@ public sealed class ImageVerifyViewModel : ViewModelBase
if(VerifySectorsChecked)
{
var chkStopwatch = new Stopwatch();
List<ulong> failingLbas = new();
List<ulong> unknownLbas = new();
List<ulong> failingLbas = [];
List<ulong> unknownLbas = [];
await Dispatcher.UIThread.InvokeAsync(() =>
{

View File

@@ -108,7 +108,7 @@ public sealed class MainWindowViewModel : ViewModelBase
DecodeImageMediaTagsCommand = ReactiveCommand.Create(ExecuteDecodeImageMediaTagsCommand);
RefreshDevicesCommand = ReactiveCommand.Create(ExecuteRefreshDevicesCommand);
_view = view;
TreeRoot = new ObservableCollection<RootModel>();
TreeRoot = [];
ContentPanel = Greeting;
_imagesRoot = new ImagesRootModel

View File

@@ -125,8 +125,8 @@ public sealed class MediaDumpViewModel : ViewModelBase
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
DestinationCommand = ReactiveCommand.Create(ExecuteDestinationCommand);
PluginsList = new ObservableCollection<ImagePluginModel>();
Encodings = new ObservableCollection<EncodingModel>();
PluginsList = [];
Encodings = [];
// Defaults
StopOnError = false;
@@ -519,10 +519,13 @@ public sealed class MediaDumpViewModel : ViewModelBase
dlgMetadata.Filters?.Add(new FileDialogFilter
{
Name = UI.Dialog_Aaru_Metadata,
Extensions = new List<string>(new[]
{
".json"
})
Extensions =
[
..new[]
{
".json"
}
]
});
string[] result = dlgMetadata.ShowAsync(_view).Result;

View File

@@ -108,7 +108,7 @@ public sealed class MediaScanViewModel : ViewModelBase
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
StartVisible = true;
CloseVisible = true;
BlockMapList = new ObservableCollection<(ulong block, double duration)>();
BlockMapList = [];
// ChartPoints = new ObservableCollection<DataPoint>();
StepsX = double.NaN;