use prim ctor and fixed warnings: LauncherCallbacks, LauncherController

This commit is contained in:
CWX
2025-01-18 13:34:00 +00:00
parent d7031c53f1
commit b23735bb94
2 changed files with 10 additions and 21 deletions
+6 -17
View File
@@ -8,24 +8,13 @@ using Core.Utils;
namespace Core.Callbacks;
[Injectable]
public class LauncherCallbacks
public class LauncherCallbacks(
HttpResponseUtil _httpResponseUtil,
LauncherController _launcherController,
SaveServer _saveServer,
Watermark _watermark
)
{
protected HttpResponseUtil _httpResponseUtil;
protected LauncherController _launcherController;
protected SaveServer _saveServer;
protected Watermark _watermark;
public LauncherCallbacks(
HttpResponseUtil httpResponse,
LauncherController launcherController,
SaveServer saveServer,
Watermark watermark)
{
_httpResponseUtil = httpResponse;
_launcherController = launcherController;
_saveServer = saveServer;
_watermark = watermark;
}
public string Connect()
{
return _httpResponseUtil.NoBody(_launcherController.Connect());
+4 -4
View File
@@ -99,16 +99,16 @@ public class LauncherController
return result;
}
public Info? Find(string sessionId)
public Info? Find(string? sessionId)
{
return _saveServer.GetProfiles().TryGetValue(sessionId, out var profile) ? profile.ProfileInfo : null;
return sessionId is not null && _saveServer.GetProfiles().TryGetValue(sessionId, out var profile) ? profile.ProfileInfo : null;
}
public string? Login(LoginRequestData info)
public string? Login(LoginRequestData? info)
{
foreach (var kvp in _saveServer.GetProfiles()) {
var account = _saveServer.GetProfile(kvp.Key).ProfileInfo;
if (info.Username == account.Username) {
if (info?.Username == account?.Username) {
return kvp.Key;
}
}