Доработаны сервисы: уменьшенно кол-во создаваемых объектов

This commit is contained in:
2026-04-21 11:44:11 +03:00
parent 9c95e6b189
commit 58f21da19c
5 changed files with 80 additions and 78 deletions

View File

@@ -44,7 +44,28 @@ public class YandexApiService : IDisposable
if (decryptedToken == null)
return null;
return await _client.Authorize(decryptedToken);
return await AuthorizeAsync(decryptedToken);
}
/// <summary>
/// Авторизуется с помощью OAuth-токена.
/// </summary>
public async Task<bool> AuthAsync(string token)
{
return await AuthorizeAsync(token);
}
private async Task<bool> AuthorizeAsync(string token)
{
try
{
await _client.Api.Auth.AuthorizeAsync(token);
return true;
}
catch
{
return false;
}
}
/// <summary>
@@ -100,14 +121,6 @@ public class YandexApiService : IDisposable
return cookie?.Value;
}
/// <summary>
/// Авторизуется с помощью OAuth-токена.
/// </summary>
public async Task<bool> AuthorizeAsync(string token)
{
return await _client.Authorize(token);
}
public void Dispose()
{
_client.Dispose();