I use the context service as a singletone in the app. What do you think, is this a good way to initialize and use context the way like this (see below) is it better just to use it as disposable? See examples below and write the comments
1. Check if the context doesn't exist and to create it
public ClientContext GetContext(string url)
{
if (_clientContext == null) {
AuthenticationManager authManager = new AuthenticationManager(
_tenantConfig.ClientId,
_tenantConfig.Certificate,
_tenantConfig.TenantId);
_clientContext = authManager.GetContext(url);
}
return _clientContext;
}
2. Make it disposable
public async Task<ClientContext> CreateContextAsync(string url)
{
var authManager = new AuthenticationManager(
_tenantConfig.ClientId,
_tenantConfig.Certificate,
_tenantConfig.TenantId);
return await authManager.GetContextAsync(url);
}

PostgreSQL in Docker: when DBeaver lies (and psql saves the day)
SharePoint onPrem: Create ContentType with the specific ID
Send props from Child class component to Parent state component in React App