1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Used new collection-initialization

This commit is contained in:
DarthAffe 2025-02-08 12:07:48 +01:00
parent 654a7624cd
commit 47770c00b8
4 changed files with 7 additions and 7 deletions

View File

@ -43,7 +43,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo; IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo;
/// <inheritdoc /> /// <inheritdoc />
public IList<IColorCorrection> ColorCorrections { get; } = new List<IColorCorrection>(); public IList<IColorCorrection> ColorCorrections { get; } = [];
/// <summary> /// <summary>
/// Gets or sets if the device needs to be flushed on every update. /// Gets or sets if the device needs to be flushed on every update.
@ -63,7 +63,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
#region Indexer #region Indexer
/// <inheritdoc /> /// <inheritdoc />
Led? IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led? led) ? led : null; Led? IRGBDevice.this[LedId ledId] => LedMapping.GetValueOrDefault(ledId);
/// <inheritdoc /> /// <inheritdoc />
Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundary.Contains(location)); Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundary.Contains(location));

View File

@ -20,7 +20,7 @@ public sealed class ListLedGroup : AbstractLedGroup
/// <summary> /// <summary>
/// Gets the list containing the <see cref="Led"/> of this <see cref="ListLedGroup"/>. /// Gets the list containing the <see cref="Led"/> of this <see cref="ListLedGroup"/>.
/// </summary> /// </summary>
private readonly IList<Led> _groupLeds = new List<Led>(); private readonly IList<Led> _groupLeds = [];
#endregion #endregion
@ -142,7 +142,7 @@ public sealed class ListLedGroup : AbstractLedGroup
public override IList<Led> ToList() public override IList<Led> ToList()
{ {
lock (_groupLeds) lock (_groupLeds)
return new List<Led>(_groupLeds); return [.._groupLeds];
} }
protected override IDisposable ToListUnsafe(out IList<Led> leds) protected override IDisposable ToListUnsafe(out IList<Led> leds)

View File

@ -20,8 +20,8 @@ public sealed class RGBSurface : AbstractBindable, IDisposable
private readonly Stopwatch _deltaTimeCounter; private readonly Stopwatch _deltaTimeCounter;
private readonly IList<IRGBDevice> _devices = new List<IRGBDevice>(); private readonly IList<IRGBDevice> _devices = [];
private readonly IList<IUpdateTrigger> _updateTriggers = new List<IUpdateTrigger>(); private readonly IList<IUpdateTrigger> _updateTriggers = [];
private readonly List<ILedGroup> _ledGroups = []; private readonly List<ILedGroup> _ledGroups = [];
/// <summary> /// <summary>

View File

@ -68,7 +68,7 @@ public sealed class CustomUpdateData : ICustomUpdateData
/// <returns>The value represented by the specified key.</returns> /// <returns>The value represented by the specified key.</returns>
public object? this[string key] public object? this[string key]
{ {
get => _data.TryGetValue(key, out object? data) ? data : default; get => _data.GetValueOrDefault(key);
set => _data[key] = value; set => _data[key] = value;
} }