コード例 #1
0
        /// <summary>
        /// Saves <see cref="Feed"/> to an XML file, adds the default stylesheet and signs it with <see cref="Publish.SignedFeed.SecretKey"/> (if specified).
        /// </summary>
        /// <remarks>Writing and signing the feed file are performed as an atomic operation (i.e. if signing fails an existing file remains unchanged).</remarks>
        /// <param name="path">The file to save in.</param>
        /// <exception cref="IOException">A problem occurs while writing the file.</exception>
        /// <exception cref="UnauthorizedAccessException">Write access to the file is not permitted.</exception>
        /// <exception cref="KeyNotFoundException">The specified <see cref="Publish.SignedFeed.SecretKey"/> could not be found on the system.</exception>
        /// <exception cref="WrongPassphraseException"><see cref="Passphrase"/> was incorrect.</exception>
        public void Save([NotNull] string path)
        {
            SignedFeed.Save(path, Passphrase);

            Path = path;
            Reset();
        }
コード例 #2
0
        /// <summary>
        /// Saves feed to an XML file, adds the default stylesheet and signs it with <see cref="Publish.SignedFeed.SecretKey"/> (if specified).
        /// </summary>
        /// <remarks>Writing and signing the feed file are performed as an atomic operation (i.e. if signing fails an existing file remains unchanged).</remarks>
        /// <param name="path">The file to save to.</param>
        /// <exception cref="IOException">A problem occurred while writing the file.</exception>
        /// <exception cref="UnauthorizedAccessException">Write access to the file is not permitted.</exception>
        /// <exception cref="KeyNotFoundException">The specified <see cref="Publish.SignedFeed.SecretKey"/> could not be found on the system.</exception>
        /// <exception cref="WrongPassphraseException"><see cref="Passphrase"/> was incorrect.</exception>
        public override void Save(string path)
        {
            SignedFeed.Save(path, Passphrase);

            Path = path;
            ClearUndo();
        }
コード例 #3
0
        (string.IsNullOrEmpty(Path) && Target.Elements.Count != 0);                               // Generated programmatically

        /// <summary>
        /// Starts with an existing feed.
        /// </summary>
        /// <param name="signedFeed">The feed to be edited.</param>
        public FeedEditing(SignedFeed signedFeed)
            : base(signedFeed.Feed)
        {
            SignedFeed = signedFeed ?? throw new ArgumentNullException(nameof(signedFeed));

            // Keep Target and SignedFeed in sync even if Target is replaced with a new object
            TargetUpdated += () => SignedFeed = new SignedFeed(Target, SignedFeed.SecretKey);
        }
コード例 #4
0
        /// <summary>
        /// Starts with a <see cref="Feed"/> that has not been saved on disk yet.
        /// </summary>
        /// <param name="signedFeed">The feed to be edited.</param>
        public FeedEditing([NotNull] SignedFeed signedFeed)
        {
            #region Sanity checks
            if (signedFeed == null)
            {
                throw new ArgumentNullException(nameof(signedFeed));
            }
            #endregion

            Changed    = true; // Makes sure remind the user to save before closing
            SignedFeed = signedFeed;
        }
コード例 #5
0
        /// <summary>
        /// Starts with a <see cref="Feed"/> loaded from a file.
        /// </summary>
        /// <param name="signedFeed">The feed to be edited.</param>
        /// <param name="path">The path of the file the <paramref name="signedFeed"/> was loaded from.</param>
        public FeedEditing([NotNull] SignedFeed signedFeed, [NotNull] string path)
        {
            #region Sanity checks
            if (signedFeed == null)
            {
                throw new ArgumentNullException(nameof(signedFeed));
            }
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            #endregion

            Path       = path;
            SignedFeed = signedFeed;
        }
コード例 #6
0
 /// <summary>
 /// Loads a feed from an XML file (feed).
 /// </summary>
 /// <param name="path">The file to load from.</param>
 /// <returns>A <see cref="FeedEditing"/> containing the loaded feed.</returns>
 /// <exception cref="IOException">A problem occurred while reading the file.</exception>
 /// <exception cref="UnauthorizedAccessException">Read access to the file is not permitted.</exception>
 /// <exception cref="InvalidDataException">A problem occurred while deserializing the XML data.</exception>
 public new static FeedEditing Load(string path)
 => new FeedEditing(SignedFeed.Load(path))
 {
     Path = path
 };
コード例 #7
0
 /// <summary>
 /// Starts with an empty <see cref="Feed"/>.
 /// </summary>
 public FeedEditing()
 {
     SignedFeed = new SignedFeed(new Feed());
 }
コード例 #8
0
 public static FeedEditing Load([NotNull] string path)
 {
     return(new FeedEditing(SignedFeed.Load(path), path));
 }