Skip to content

Commit

Permalink
chore: Adjust existing usages
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Jan 6, 2025
1 parent 0514164 commit 1d09a11
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Uno.UWP/Devices/Geolocation/Geolocator.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void OnLocationChanged(Location location)
_location = location;

BroadcastStatusChanged(PositionStatus.Ready);
_owner._positionChangedWrapper.Event?.Invoke(_owner, new PositionChangedEventArgs(location.ToGeoPosition()));
_owner._positionChangedWrapper.Invoke(_owner, new PositionChangedEventArgs(location.ToGeoPosition()));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Uno.UWP/Devices/Geolocation/Geolocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public sealed partial class Geolocator
// Using ConcurrentDictionary as concurrent HashSet (https://stackoverflow.com/questions/18922985/concurrent-hashsett-in-net-framework), byte is throwaway
private static readonly ConcurrentDictionary<Geolocator, byte> _statusChangedSubscriptions = new ConcurrentDictionary<Geolocator, byte>();

private readonly StartStopEventWrapper<TypedEventHandler<Geolocator, StatusChangedEventArgs>> _statusChangedWrapper;
private readonly StartStopEventWrapper<TypedEventHandler<Geolocator, PositionChangedEventArgs>> _positionChangedWrapper;
private readonly StartStopTypedEventWrapper<Geolocator, StatusChangedEventArgs> _statusChangedWrapper;
private readonly StartStopTypedEventWrapper<Geolocator, PositionChangedEventArgs> _positionChangedWrapper;

private PositionAccuracy _desiredAccuracy = PositionAccuracy.Default;

Expand All @@ -33,11 +33,11 @@ public sealed partial class Geolocator
/// </summary>
public Geolocator()
{
_statusChangedWrapper = new StartStopEventWrapper<TypedEventHandler<Geolocator, StatusChangedEventArgs>>(
_statusChangedWrapper = new StartStopTypedEventWrapper<Geolocator, StatusChangedEventArgs>(
() => StartStatusChanged(),
() => StopStatusChanged(),
_syncLock);
_positionChangedWrapper = new StartStopEventWrapper<TypedEventHandler<Geolocator, PositionChangedEventArgs>>(
_positionChangedWrapper = new StartStopTypedEventWrapper<Geolocator, PositionChangedEventArgs>(
() => StartPositionChanged(),
() => StopPositionChanged(),
_syncLock);
Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWP/Devices/Sensors/ProximitySensor.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Windows.Devices.Sensors;

public partial class ProximitySensor
{
private readonly StartStopEventWrapper<TypedEventHandler<ProximitySensor, ProximitySensorReadingChangedEventArgs>> _readingChangedWrapper;
private readonly StartStopTypedEventWrapper<ProximitySensor, ProximitySensorReadingChangedEventArgs> _readingChangedWrapper;

private Sensor? _sensor;
private ProximitySensorListener? _listener;
Expand Down
8 changes: 4 additions & 4 deletions src/Uno.UWP/Gaming/Input/Gamepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ public partial class Gamepad : IGameController
{
private static readonly object _syncLock = new object();

private static readonly StartStopEventWrapper<EventHandler<Gamepad>> _gamepadAddedWrapper;
private static readonly StartStopEventWrapper<EventHandler<Gamepad>> _gamepadRemovedWrapper;
private static readonly StartStopEventWrapper<Gamepad> _gamepadAddedWrapper;
private static readonly StartStopEventWrapper<Gamepad> _gamepadRemovedWrapper;

static Gamepad()
{
_gamepadAddedWrapper = new StartStopEventWrapper<EventHandler<Gamepad>>(
_gamepadAddedWrapper = new StartStopEventWrapper<Gamepad>(
StartGamepadAdded, EndGamepadAdded, _syncLock);
_gamepadRemovedWrapper = new StartStopEventWrapper<EventHandler<Gamepad>>(
_gamepadRemovedWrapper = new StartStopEventWrapper<Gamepad>(
StartGamepadRemoved, EndGamepadRemoved, _syncLock);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Uno.UWP/Helpers/StartStopEventWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Uno.Helpers;

/// <summary>
/// Start stop wrapper for EventHandler<T> events.
/// Start stop wrapper for EventHandler`1 events.
/// </summary>
/// <typeparam name="TEventArgs">Event args type.</typeparam>
internal class StartStopEventWrapper<TEventArgs> : StartStopDelegateWrapper<EventHandler<TEventArgs>>
Expand Down
5 changes: 3 additions & 2 deletions src/Uno.UWP/Helpers/StartStopTypedEventWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
namespace Uno.Helpers;

/// <summary>
/// Start stop wrapper for TypedEventHandler<T> events.
/// Start stop wrapper for TypedEventHandler`2 events.
/// </summary>
/// <typeparam name="TEventArgs">Event args type.</typeparam>
/// <typeparam name="TSender">Sender type.</typeparam>
/// <typeparam name="TResult">Event args type.</typeparam>
internal class StartStopTypedEventWrapper<TSender, TResult> : StartStopDelegateWrapper<TypedEventHandler<TSender, TResult>>
{
/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/Uno.UWP/System/Power/PowerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public static partial class PowerManager
private static EnergySaverStatus? _lastEnergySaverStatus;
#endif

private readonly static StartStopEventWrapper<EventHandler<object>> _powerSupplyStatusChanged;
private readonly static StartStopEventWrapper<EventHandler<object>> _remainingChargePercentChanged;
private readonly static StartStopEventWrapper<EventHandler<object>> _batteryStatusChanged;
private readonly static StartStopEventWrapper<object> _powerSupplyStatusChanged;
private readonly static StartStopEventWrapper<object> _remainingChargePercentChanged;
private readonly static StartStopEventWrapper<object> _batteryStatusChanged;
#if __WASM__
private readonly static StartStopEventWrapper<EventHandler<object>> _remainingDischargeTimeChanged;
private readonly static StartStopEventWrapper<object> _remainingDischargeTimeChanged;
#endif
#if !__WASM__
private readonly static StartStopEventWrapper<EventHandler<object>> _energySaverStatusChanged;
private readonly static StartStopEventWrapper<object> _energySaverStatusChanged;
#endif

static PowerManager()
Expand Down

0 comments on commit 1d09a11

Please sign in to comment.