/// <summary> /// Initializes a new instance of the <see cref="UpdateOperation"/> class /// that involves changes to more than one editing operation. /// </summary> /// <param name="revisions">The editing operations that were changed.</param> internal UpdateOperation(RevisedEdit[] revisions) : base() { if (revisions == null || revisions.Length == 0) throw new ArgumentException(); m_Revisions = revisions; m_IsApplied = false; }
/// <summary> /// Initializes a new instance of the <see cref="UpdateOperation"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal UpdateOperation(EditDeserializer editDeserializer) : base(editDeserializer) { if (editDeserializer.IsNextField(DataField.RevisedEdits)) { m_Revisions = editDeserializer.ReadPersistentArray<RevisedEdit>(DataField.RevisedEdits); } else { RevisedEdit rev = new RevisedEdit(editDeserializer); m_Revisions = new RevisedEdit[] { rev }; } m_IsApplied = false; }
/// <summary> /// Initializes a new instance of the <see cref="UpdateOperation"/> class /// using the data read from persistent storage. /// </summary> /// <param name="editDeserializer">The mechanism for reading back content.</param> internal UpdateOperation(EditDeserializer editDeserializer) : base(editDeserializer) { if (editDeserializer.IsNextField(DataField.RevisedEdits)) { m_Revisions = editDeserializer.ReadPersistentArray <RevisedEdit>(DataField.RevisedEdits); } else { RevisedEdit rev = new RevisedEdit(editDeserializer); m_Revisions = new RevisedEdit[] { rev }; } m_IsApplied = false; }
/// <summary> /// Remembers an additional revision is part of this operation. /// </summary> /// <param name="rev">The additional revision to append</param> /// <remarks>This method should be called only by the <see cref="UpdateUI"/> class /// in a situation where the user is fixing up a rollforward problem.</remarks> internal void AddRevisedEdit(RevisedEdit rev) { Array.Resize<RevisedEdit>(ref m_Revisions, m_Revisions.Length + 1); m_Revisions[m_Revisions.Length - 1] = rev; }
/// <summary> /// Remembers details for an updated edit. /// </summary> /// <param name="revisedEdit">The edit that is being revised</param> /// <param name="changes">The changes to apply</param> /// <returns>True if an update was recorded, false if the supplied change collection is empty (in that /// case, the user receives a warning message).</returns> /// <remarks>This will be called when the user has finished making changes to an old /// edit. The call comes from the UI for the revised edit, which goes on to call /// CommandUI.FinishCommand, which routes back to UpdateUI.FinishCommand when an /// update UI is in progress.</remarks> internal bool AddUpdate(Operation revisedEdit, UpdateItemCollection changes) { if (changes.Count == 0) { MessageBox.Show("You do not appear to have made any changes."); return false; } // Remember the revision that will be applied by ApplyRevision. In the vast majority of cases, // there should only be one revised edit per editing dialog. Currently, the only situation // where more than one revision is involved is an update where both sides of a subdivided line // get updated. var rev = new RevisedEdit(revisedEdit, changes); if (m_Revisions == null) { m_Revisions = new RevisedEdit[] { rev }; } else { Array.Resize<RevisedEdit>(ref m_Revisions, m_Revisions.Length + 1); m_Revisions[m_Revisions.Length - 1] = rev; } return true; }
/// <summary> /// Remembers an additional revision is part of this operation. /// </summary> /// <param name="rev">The additional revision to append</param> /// <remarks>This method should be called only by the <see cref="UpdateUI"/> class /// in a situation where the user is fixing up a rollforward problem.</remarks> internal void AddRevisedEdit(RevisedEdit rev) { Array.Resize <RevisedEdit>(ref m_Revisions, m_Revisions.Length + 1); m_Revisions[m_Revisions.Length - 1] = rev; }
/// <summary> /// Obtains the changes for a specific editing operation. /// </summary> /// <param name="op">The edit of interest</param> /// <returns>The corresponding changes (null if not found)</returns> internal UpdateItemCollection GetChanges(Operation op) { RevisedEdit rev = Array.Find <RevisedEdit>(m_Revisions, r => r.RevisedOperation == op); return(rev == null ? null : rev.Changes); }