/// <summary> /// Removes all items from the <see cref="ObservableMasterSlaveCollection{T}" />. /// </summary> /// <returns>An array containing the original collection items.</returns> /// <remarks>On concurrent collections, this method is write-synchronized.</remarks> protected override T[] ClearInternal() { ThrowIfCurrentObjectDisposed(); T[] originalArray; using (WriteLock()) { var container = (MultiListMasterSlaveListAdapter <T>)InternalListContainer; IncreaseIgnoreMustResetCounter(container.SlavesCount + 1); originalArray = new T[container.MasterCount]; container.MasterCopyTo( originalArray, 0); InternalListContainer.Clear(); PushUndoLevel(new ClearStateChange <T>(originalArray)); } RaiseCollectionReset(); RaisePropertyChanged(nameof(Count)); ContentsMayHaveChanged(); return(originalArray); }