public void Dispose() { _crypto?.Dispose(); _client?.Dispose(); ListenerCancellation?.Cancel(false); ListenerCancellation?.Dispose(); }
public static void TestObjectDisposed() { AesKey key = new AesKey(); AesIV iv = new AesIV(); AesCrypto crypto = new AesCrypto(key, iv, CipherMode.CBC, PaddingMode.None); crypto.Dispose(); Assert.Throws <ObjectDisposedException>(() => { crypto.Decrypt(new byte[16]); }); Assert.Throws <ObjectDisposedException>(() => { crypto.Encrypt(new byte[16]); }); Assert.Throws <ObjectDisposedException>(() => { crypto.CreateDecryptingTransform(); }); Assert.Throws <ObjectDisposedException>(() => { crypto.CreateEncryptingTransform(); }); }
private void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_dataCrypto != null) { _dataCrypto.Dispose(); _dataCrypto = null; } if (_reader != null) { _reader.Dispose(); _reader = null; } } _disposed = true; }