Pergunta

I have a class that wraps an API. The methods are all API calls. In the constructor it logs in to the API and stores a session token as part of the private class data. All the actual API calls then use that token to make the individual calls.

The API also has a logout call that more or less ends the session. My question is where should I do the logout call? Something with a finalizer? I'm currently using some sort of simple IDisposable implementation but that doesn't really feel like it's the best/proper way.

Foi útil?

Solução

Your object should implement IDisposable and you should call logout in your Dispose method because this is the expected way to deal with non-memory related resources in .Net.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top