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)
{
Feed.SaveXml(path);
return;
}
var openPgp = OpenPgpFactory.CreateDefault();
using (var stream = new MemoryStream())
{
Feed.SaveXml(stream, stylesheet: @"feed.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, @"feed");
}
}
#endregion