summary refs log tree commit diff
path: root/crypto/src/openpgp/WrappedGeneratorStream.cs
blob: 6f96dc9b87051f8c501b15dc1373bb58b3ad0e53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.IO;

using Org.BouncyCastle.Utilities.IO;

namespace Org.BouncyCastle.Bcpg.OpenPgp
{
	internal sealed class WrappedGeneratorStream
		: FilterStream
	{
		private IStreamGenerator m_generator;

		internal WrappedGeneratorStream(IStreamGenerator generator, Stream s)
			: base(s)
		{
			m_generator = generator ?? throw new ArgumentNullException(nameof(generator));
		}

        protected override void Dispose(bool disposing)
        {
			if (m_generator != null)
			{
				if (disposing)
				{
					m_generator.Close();
				}

				m_generator = null;
			}

			Detach(disposing);
		}
	}
}