/// <summary> /// Raises the <see cref="Renaming"/> event. /// </summary> /// <param name="e">The <see cref="DeclarationRenamingEventArgs"/> which /// indicate the old and new name of the <see cref="IntermediateTypeBase{TTypeIdentifier, TType, TIntermediateType}"/> and /// whether the change should take place.</param> protected virtual void OnRenaming(DeclarationRenamingEventArgs e) { var renaming = this.Renaming; if (renaming != null) { renaming(this, e); } }
/// <summary> /// Instructs the <see cref="IntermediateDeclarationBase{TIdentifier}"/> /// that the <paramref name="name"/> has been changed. /// </summary> /// <param name="name">The <see cref="String"/> /// value representing the new name of the /// <see cref="IntermediateDeclarationBase{TIdentifier}"/>.</param> protected virtual void OnSetName(string name) { if (name == this.name) { return; } DeclarationRenamingEventArgs renaming = new DeclarationRenamingEventArgs(this.name, name); this.OnRenaming(renaming); if (!renaming.Change) { return; } var oldIdentifier = this.UniqueIdentifier; AssignName(name); this.OnIdentifierChanged(oldIdentifier, DeclarationChangeCause.Name); this.OnRenamed(new DeclarationNameChangedEventArgs(renaming.OldName, renaming.NewName)); }
/// <summary> /// Implementation which sets the name of the <see cref="IntermediateTypeBase{TTypeIdentifier, TType, TIntermediateType}"/>. /// </summary> /// <param name="value">The <see cref="String"/> value representing the unique /// name of the type within the current context.</param> protected virtual void OnSetName(string value) { if (value == this.name) { return; } if (this.IsNameLocked) { throw new InvalidOperationException("Name is read-only."); } var uniqueIdentifier = this.UniqueIdentifier; DeclarationRenamingEventArgs renaming = new DeclarationRenamingEventArgs(this.name, value); this.OnRenaming(renaming); if (!renaming.Change) { return; } AssignName(value); this.OnRenamed(new DeclarationNameChangedEventArgs(renaming.OldName, renaming.NewName)); this.OnIdentifierChanged(uniqueIdentifier, DeclarationChangeCause.Name); }