Skip to content

Commit

Permalink
Use auto property
Browse files Browse the repository at this point in the history
  • Loading branch information
KubaZ2 committed Aug 25, 2024
1 parent 9083e01 commit 81fcb62
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions NetCord/Gateway/WebSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ public void Dispose()

private protected sealed class State : IDisposable
{
private ConnectionState? _connectionState;

public ConnectionState? ConnectionState => _connectionState;
public ConnectionState? ConnectionState { get; private set; }

public CancellationTokenProvider ClosedTokenProvider { get; } = new();

Expand All @@ -77,7 +75,7 @@ public void IndicateConnected(ConnectionState connectionState)
{
lock (ClosedTokenProvider)
{
if (_connectionState != connectionState)
if (ConnectionState != connectionState)
return;

_connectedCompletionSource.TrySetResult(connectionState);
Expand All @@ -88,7 +86,7 @@ public void IndicateReady(ConnectionState connectionState)
{
lock (ClosedTokenProvider)
{
if (_connectionState != connectionState)
if (ConnectionState != connectionState)
return;

_readyCompletionSource.TrySetResult(connectionState);
Expand All @@ -99,11 +97,11 @@ public bool TryIndicateConnecting(ConnectionState connectionState)
{
lock (ClosedTokenProvider)
{
var previousState = _connectionState;
var previousState = ConnectionState;
if (previousState is not null)
return false;

_connectionState = connectionState;
ConnectionState = connectionState;
}

return true;
Expand All @@ -113,14 +111,14 @@ public bool TryIndicateDisconnecting([MaybeNullWhen(false)] out ConnectionState
{
lock (ClosedTokenProvider)
{
var previousState = _connectionState;
var previousState = ConnectionState;
if (previousState is null || !previousState.TryIndicateDisconnecting())
{
connectionState = null;
return false;
}

_connectionState = null;
ConnectionState = null;
connectionState = previousState;

_readyCompletionSource.TrySetCanceled();
Expand All @@ -135,7 +133,7 @@ public bool TryIndicateDisconnecting([MaybeNullWhen(false)] out ConnectionState

public void Dispose()
{
_connectionState?.Dispose();
ConnectionState?.Dispose();
ClosedTokenProvider.Dispose();
}
}
Expand Down

0 comments on commit 81fcb62

Please sign in to comment.