null checks
This commit is contained in:
@@ -2,13 +2,14 @@
|
|||||||
using OwnChar.Manager.Exceptions;
|
using OwnChar.Manager.Exceptions;
|
||||||
using OwnChar.Model;
|
using OwnChar.Model;
|
||||||
using Pilz.Cryptography;
|
using Pilz.Cryptography;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace OwnChar.Manager;
|
namespace OwnChar.Manager;
|
||||||
|
|
||||||
public class OwnCharManager
|
public class OwnCharManager
|
||||||
{
|
{
|
||||||
// User
|
// User
|
||||||
public bool IsLoggedIn => CurrentUser != null;
|
public bool IsLoggedIn => CurrentUser != null && DataManager != null;
|
||||||
public UserAccount? CurrentUser { get; private set; }
|
public UserAccount? CurrentUser { get; private set; }
|
||||||
|
|
||||||
// Data Provider
|
// Data Provider
|
||||||
@@ -26,6 +27,7 @@ public class OwnCharManager
|
|||||||
Characters = new(this);
|
Characters = new(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MemberNotNull(nameof(CurrentUser), nameof(DataManager))]
|
||||||
internal protected void CheckLogin()
|
internal protected void CheckLogin()
|
||||||
{
|
{
|
||||||
if (!IsLoggedIn)
|
if (!IsLoggedIn)
|
||||||
@@ -36,6 +38,7 @@ public class OwnCharManager
|
|||||||
/// Tries to login on the given data provider.
|
/// Tries to login on the given data provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Returns <see cref="true"/> if the login was successfull and <see cref="false"/> if not.</returns>
|
/// <returns>Returns <see cref="true"/> if the login was successfull and <see cref="false"/> if not.</returns>
|
||||||
|
[MemberNotNullWhen(true, nameof(CurrentUser), nameof(DataManager))]
|
||||||
public bool Login(IDataManager? proxy, string? username, SecureString? password)
|
public bool Login(IDataManager? proxy, string? username, SecureString? password)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(proxy, nameof(proxy));
|
ArgumentNullException.ThrowIfNull(proxy, nameof(proxy));
|
||||||
|
|||||||
Reference in New Issue
Block a user