/// <summary> /// Removes all keys and values from the <see cref=" /// EditorDictionary"/>. /// </summary> public void Clear() { var values = new List <IEditor>(Values); Editors.Clear(); foreach (var value in values) { var e = new EditorEventArgs(value); EditorSelector.OnEditorRemoved(e); } }
/// <summary> /// Raises the <see cref="EditorAdded"/> event and sets <see /// cref="CurrentEditor"/> to the newly added <see cref="IEditor"/>. /// </summary> /// <param name="e"> /// An <see cref="EditorEventArgs"/> that contains the event data. /// </param> protected virtual void OnEditorAdded(EditorEventArgs e) { if (e is null) { throw new ArgumentNullException(nameof(e)); } EditorAdded?.Invoke(this, e); CurrentEditor = e.Editor; }
/// <summary> /// Raises the <see cref="EditorRemoved"/> event and sets <see /// cref="CurrentEditor"/> to <see langword="null"/> if it is the <see /// cref="IEditor"/> that was removed. /// </summary> /// <param name="e"> /// An <see cref="EditorEventArgs"/> that contains the event data. /// </param> protected virtual void OnEditorRemoved(EditorEventArgs e) { if (e is null) { throw new ArgumentNullException(nameof(e)); } EditorRemoved?.Invoke(this, e); if (CurrentEditor == e.Editor) { CurrentEditor = null; } }
/// <inheritdoc/> /// bool ICollection <PathEditorPair> .Remove(PathEditorPair item) { var itemWithActualKey = new PathEditorPair( GetFullPath(item.Key), item.Value); if (IDictionary.Remove(itemWithActualKey)) { var e = new EditorEventArgs(item.Value); EditorSelector.OnEditorRemoved(e); return(true); } return(false); }
/// <summary> /// Removes the <see cref="IEditor"/> with the specified file path /// key. /// </summary> /// <param name="key"> /// The file path of the <see cref="IEditor"/> to remove. /// </param> /// <returns> /// <see langword="true"/> if the <see cref="IEditor"/> is /// successfully found and removed; otherwise <see /// langword="false"/>. /// </returns> /// <exception cref="ArgumentException"> /// <paramref name="key"/> is a zero-length string, contains only /// whitespace, or contains one or more of the invalid characters /// defined in <see cref=" GetInvalidPathChars"/>. /// <para/> /// -or- /// <para/> /// The system could not retrieve the absolute path. /// </exception> /// <exception cref="System.Security.SecurityException"> /// The caller does not have the required permissions. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="key"/> is <see langword="null"/>. /// </exception> /// <exception cref="NotSupportedException"> /// <paramref name="key"/> contains a colon (":") that is not part /// of a volume identifier (for example, "c:\"). /// </exception> /// <exception cref="System.IO.PathTooLongException"> /// The specified path, file name, or both exceed the /// system-defined maximum length. /// </exception> public bool Remove(string key) { var actualKey = GetFullPath(key); if (Editors.TryGetValue(actualKey, out var value)) { Editors.Remove(actualKey); var e = new EditorEventArgs(value); EditorSelector.OnEditorRemoved(e); return(true); } return(false); }
/// <summary> /// Adds the specified file path key and <see cref="IEditor"/> /// value to the <see cref="EditorDictionary"/>. /// </summary> /// <param name="key"> /// The file path key of the <see cref="IEditor"/> to add. /// </param> /// <param name="value"> /// The <see cref="IEditor"/> of the element to add. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="key"/> is <see langword="null"/>. /// <para/> /// -or- /// <para/> /// <paramref name="value"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="key"/> is a zero-length string, contains only /// whitespace, or contains one or more of the invalid characters /// defined in <see cref=" GetInvalidPathChars"/>. /// <para/> /// -or- /// <para/> /// The system could not retrieve the absolute path. /// </exception> /// <exception cref="System.Security.SecurityException"> /// The caller does not have the required permissions. /// </exception> /// <exception cref="NotSupportedException"> /// <paramref name="key"/> contains a colon (":") that is not part /// of a volume identifier (for example, "c:\"). /// </exception> /// <exception cref="System.IO.PathTooLongException"> /// The specified path, file name, or both exceed the /// system-defined maximum length. /// </exception> public void Add(string key, IEditor value) { if (value is null) { throw new ArgumentNullException(nameof(value)); } var actualKey = GetFullPath(key); Editors.Add(actualKey, value); var e = new EditorEventArgs(value); EditorSelector.OnEditorAdded(e); }
/// <summary> /// Raises the <see cref="CurrentEditorChanged"/> event. /// </summary> /// <param name="e"> /// An <see cref="EditorEventArgs"/> that contains the event data. /// </param> protected virtual void OnCurrentEditorChanged(EditorEventArgs e) { CurrentEditorChanged?.Invoke(this, e); }