diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 07663f3..311c468 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -43,7 +43,7 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice DeviceInfo; /// - public IList ColorCorrections { get; } = new List(); + public IList ColorCorrections { get; } = []; /// /// Gets or sets if the device needs to be flushed on every update. @@ -63,7 +63,7 @@ public abstract class AbstractRGBDevice : Placeable, IRGBDevice - Led? IRGBDevice.this[LedId ledId] => LedMapping.TryGetValue(ledId, out Led? led) ? led : null; + Led? IRGBDevice.this[LedId ledId] => LedMapping.GetValueOrDefault(ledId); /// Led? IRGBDevice.this[Point location] => LedMapping.Values.FirstOrDefault(x => x.Boundary.Contains(location)); diff --git a/RGB.NET.Core/Groups/ListLedGroup.cs b/RGB.NET.Core/Groups/ListLedGroup.cs index 4bca2fb..511cdad 100644 --- a/RGB.NET.Core/Groups/ListLedGroup.cs +++ b/RGB.NET.Core/Groups/ListLedGroup.cs @@ -20,7 +20,7 @@ public sealed class ListLedGroup : AbstractLedGroup /// /// Gets the list containing the of this . /// - private readonly IList _groupLeds = new List(); + private readonly IList _groupLeds = []; #endregion @@ -142,7 +142,7 @@ public sealed class ListLedGroup : AbstractLedGroup public override IList ToList() { lock (_groupLeds) - return new List(_groupLeds); + return [.._groupLeds]; } protected override IDisposable ToListUnsafe(out IList leds) diff --git a/RGB.NET.Core/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs index 5c3387f..2de9c13 100644 --- a/RGB.NET.Core/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -20,8 +20,8 @@ public sealed class RGBSurface : AbstractBindable, IDisposable private readonly Stopwatch _deltaTimeCounter; - private readonly IList _devices = new List(); - private readonly IList _updateTriggers = new List(); + private readonly IList _devices = []; + private readonly IList _updateTriggers = []; private readonly List _ledGroups = []; /// diff --git a/RGB.NET.Core/Update/CustomUpdateData.cs b/RGB.NET.Core/Update/CustomUpdateData.cs index 0d85aa7..bce97f3 100644 --- a/RGB.NET.Core/Update/CustomUpdateData.cs +++ b/RGB.NET.Core/Update/CustomUpdateData.cs @@ -68,7 +68,7 @@ public sealed class CustomUpdateData : ICustomUpdateData /// The value represented by the specified key. public object? this[string key] { - get => _data.TryGetValue(key, out object? data) ? data : default; + get => _data.GetValueOrDefault(key); set => _data[key] = value; }