Exemple #1
0
 public void Dispose()
 {
     _crypto?.Dispose();
     _client?.Dispose();
     ListenerCancellation?.Cancel(false);
     ListenerCancellation?.Dispose();
 }
Exemple #2
0
        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();
            });
        }
Exemple #3
0
        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;
        }