(InputCryptoStream): new class derived from CryptoStream.

properly dispose transformations used by CryptoStream.
This commit is contained in:
morkt
2016-12-25 06:51:33 +04:00
parent a303a66501
commit b6f472ab25
14 changed files with 42 additions and 18 deletions

View File

@@ -137,4 +137,28 @@ namespace GameRes.Formats
return b;
}
}
/// <summary>
/// CryptoStream that disposes transformation object upon close.
/// </summary>
public class InputCryptoStream : CryptoStream
{
ICryptoTransform m_transform;
public InputCryptoStream (Stream input, ICryptoTransform transform)
: base (input, transform, CryptoStreamMode.Read)
{
m_transform = transform;
}
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
if (disposing && m_transform != null)
{
m_transform.Dispose();
m_transform = null;
}
}
}
}