private void tag_ValueChanging(FileTag sender, FileTagEventArgs e) { FileTag newTag = new FileTag(e.NewValue); // Don't allow the tag to be change into a value that already exists if (this.tags.Exists(newTag.Compare)) { e.Cancel = true; throw new InvalidOperationException(string.Format( "Can't change tag value from '{1}' to '{0}' because the tag '{0}' already exists in the file's tags list", e.NewValue, e.OldValue)); } // Raise event (removeTag and addTag) if (this.TagRemoved != null) { FileWithTagsEventArgs e2 = new FileWithTagsEventArgs(sender); this.TagRemoved(this, e2); } if (this.TagAdded != null) { FileWithTagsEventArgs e2 = new FileWithTagsEventArgs(newTag); this.TagAdded(this, e2); } }
// Handles ValueChanging event for any tag in any file private void tag_ValueChanging(FileTag sender, FileTagEventArgs e) { if (this.currentAction == DatabaseAction.Idle) throw new InvalidOperationException("This object is read-only"); }