From 93de24c7f5029a9ceb34ca72f05a7c5e1eb7c804 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 8 Feb 2024 11:15:45 +0200 Subject: [PATCH] Remove constructor setters --- DepotDownloader/CDNClientPool.cs | 14 ++++---------- DepotDownloader/Steam3Session.cs | 32 +++++++------------------------- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/DepotDownloader/CDNClientPool.cs b/DepotDownloader/CDNClientPool.cs index 6503d5fe..2ed0a086 100644 --- a/DepotDownloader/CDNClientPool.cs +++ b/DepotDownloader/CDNClientPool.cs @@ -20,12 +20,12 @@ namespace DepotDownloader public Client CDNClient { get; } public Server ProxyServer { get; private set; } - private readonly ConcurrentStack activeConnectionPool; - private readonly BlockingCollection availableServerEndpoints; + private readonly ConcurrentStack activeConnectionPool = []; + private readonly BlockingCollection availableServerEndpoints = []; - private readonly AutoResetEvent populatePoolEvent; + private readonly AutoResetEvent populatePoolEvent = new(true); private readonly Task monitorTask; - private readonly CancellationTokenSource shutdownToken; + private readonly CancellationTokenSource shutdownToken = new(); public CancellationTokenSource ExhaustedToken { get; set; } public CDNClientPool(Steam3Session steamSession, uint appId) @@ -34,12 +34,6 @@ namespace DepotDownloader this.appId = appId; CDNClient = new Client(steamSession.steamClient); - activeConnectionPool = new ConcurrentStack(); - availableServerEndpoints = []; - - populatePoolEvent = new AutoResetEvent(true); - shutdownToken = new CancellationTokenSource(); - monitorTask = Task.Factory.StartNew(ConnectionPoolMonitorAsync).Unwrap(); } diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index c6d6f6f2..9d4d8981 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -31,13 +30,12 @@ namespace DepotDownloader private set; } - public Dictionary AppTokens { get; private set; } - public Dictionary PackageTokens { get; private set; } - public Dictionary DepotKeys { get; private set; } - public ConcurrentDictionary> CDNAuthTokens { get; private set; } - public Dictionary AppInfo { get; private set; } - public Dictionary PackageInfo { get; private set; } - public Dictionary AppBetaPasswords { get; private set; } + public Dictionary AppTokens { get; } = []; + public Dictionary PackageTokens { get; } = []; + public Dictionary DepotKeys { get; } = []; + public Dictionary AppInfo { get; } = []; + public Dictionary PackageInfo { get; } = []; + public Dictionary AppBetaPasswords { get; } = []; public SteamClient steamClient; public SteamUser steamUser; @@ -64,7 +62,7 @@ namespace DepotDownloader readonly SteamUser.LogOnDetails logonDetails; // output - readonly Credentials credentials; + readonly Credentials credentials = new(); static readonly TimeSpan STEAM3_TIMEOUT = TimeSpan.FromSeconds(30); @@ -72,23 +70,7 @@ namespace DepotDownloader public Steam3Session(SteamUser.LogOnDetails details) { this.logonDetails = details; - this.authenticatedUser = details.Username != null || ContentDownloader.Config.UseQrCode; - this.credentials = new Credentials(); - this.bConnected = false; - this.bConnecting = false; - this.bAborted = false; - this.bExpectingDisconnectRemote = false; - this.bDidDisconnect = false; - this.seq = 0; - - this.AppTokens = []; - this.PackageTokens = []; - this.DepotKeys = []; - this.CDNAuthTokens = new ConcurrentDictionary>(); - this.AppInfo = []; - this.PackageInfo = []; - this.AppBetaPasswords = []; var clientConfiguration = SteamConfiguration.Create(config => config