public void Save([NotNull] string path, [CanBeNull] string passphrase = null)
{
#region Sanity checks
if (string.IsNullOrEmpty(path)) throw new ArgumentNullException(nameof(path));
#endregion
if (SecretKey == null)
{
Catalog.SaveXml(path);
return;
}
var openPgp = OpenPgpFactory.CreateDefault();
using (var stream = new MemoryStream())
{
Catalog.SaveXml(stream, stylesheet: @"catalog.xsl");
stream.Position = 0;
FeedUtils.SignFeed(stream, SecretKey, passphrase, openPgp);
stream.CopyToFile(path);
}
string directory = Path.GetDirectoryName(path);
if (directory != null)
{
openPgp.DeployPublicKey(SecretKey, directory);
FeedUtils.DeployStylesheet(directory, @"catalog");
}
}
#endregion