Fixed IDisposable implementation and usage.
- Implement IDisposable interface correctly, with sealed classes where possible for simplicity. - Add using statement around undisposed local variables.
This commit is contained in:
@@ -17,7 +17,7 @@ using OpenRA.Primitives;
|
||||
|
||||
namespace OpenRA.Irc
|
||||
{
|
||||
public class IrcClient : IDisposable
|
||||
public sealed class IrcClient : IDisposable
|
||||
{
|
||||
public static readonly IrcClient Instance = new IrcClient();
|
||||
|
||||
@@ -252,14 +252,15 @@ namespace OpenRA.Irc
|
||||
|
||||
ConnectionState = IrcConnectionState.Disconnecting;
|
||||
OnDisconnecting();
|
||||
connection.Close();
|
||||
if (connection != null)
|
||||
connection.Close();
|
||||
ConnectionState = IrcConnectionState.Disconnected;
|
||||
OnDisconnect();
|
||||
LocalUser = null;
|
||||
connection = null;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user