Use field instead of property

This commit is contained in:
1hitsong 2022-09-19 17:57:03 -04:00
parent df85b2fe65
commit 3ba8218e45

View File

@ -18,6 +18,8 @@ public class LrcLyricProvider : ILyricProvider
{ {
private readonly ILogger<LrcLyricProvider> _logger; private readonly ILogger<LrcLyricProvider> _logger;
private static readonly IReadOnlyList<string> _acceptedTimeFormats = new string[] { "HH:mm:ss", "H:mm:ss", "mm:ss", "m:ss" };
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LrcLyricProvider"/> class. /// Initializes a new instance of the <see cref="LrcLyricProvider"/> class.
/// </summary> /// </summary>
@ -39,8 +41,6 @@ public class LrcLyricProvider : ILyricProvider
/// <inheritdoc /> /// <inheritdoc />
public IReadOnlyCollection<string> SupportedMediaTypes { get; } = new[] { "lrc", "elrc" }; public IReadOnlyCollection<string> SupportedMediaTypes { get; } = new[] { "lrc", "elrc" };
private static readonly IReadOnlyList<string> _acceptedTimeFormats = new string[] { "HH:mm:ss", "H:mm:ss", "mm:ss", "m:ss" };
/// <summary> /// <summary>
/// Opens lyric file for the requested item, and processes it for API return. /// Opens lyric file for the requested item, and processes it for API return.
/// </summary> /// </summary>
@ -83,8 +83,7 @@ public class LrcLyricProvider : ILyricProvider
foreach (string metaDataRow in metaDataRows) foreach (string metaDataRow in metaDataRows)
{ {
int colonCount = metaDataRow.Count(f => (f == ':')); if (!metaDataRow.Contains(':', StringComparison.OrdinalIgnoreCase))
if (colonCount == 0)
{ {
continue; continue;
} }
@ -157,7 +156,7 @@ public class LrcLyricProvider : ILyricProvider
if (metaData.TryGetValue("length", out var length) && !string.IsNullOrEmpty(length)) if (metaData.TryGetValue("length", out var length) && !string.IsNullOrEmpty(length))
{ {
if (DateTime.TryParseExact(length, AcceptedTimeFormats, null, DateTimeStyles.None, out var value)) if (DateTime.TryParseExact(length, _acceptedTimeFormats.ToArray(), null, DateTimeStyles.None, out var value))
{ {
lyricMetadata.Length = value.TimeOfDay.Ticks; lyricMetadata.Length = value.TimeOfDay.Ticks;
} }