public void Encrypt (CryptographyContext ctx)
{
if (ctx == null)
throw new ArgumentNullException (nameof (ctx));
if (Body == null)
throw new InvalidOperationException ("No message body has been set.");
var recipients = GetMessageRecipients (true);
if (recipients.Count == 0)
throw new InvalidOperationException ("No recipients have been set.");
if (ctx is SecureMimeContext) {
Body = ApplicationPkcs7Mime.Encrypt ((SecureMimeContext) ctx, recipients, Body);
} else if (ctx is OpenPgpContext) {
Body = MultipartEncrypted.Encrypt ((OpenPgpContext) ctx, recipients, Body);
} else {
throw new ArgumentException ("Unknown type of cryptography context.", nameof (ctx));
}
}