From 102302999c6abc734c4ca19415e9c3ea88cd82ad Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 22 Jul 2022 09:49:03 +0200 Subject: [PATCH] Added Clear method. --- .../Utilities/AvaloniaPropertyDictionary.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs b/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs index 79d52868e3..5c7d7d8605 100644 --- a/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs +++ b/src/Avalonia.Base/Utilities/AvaloniaPropertyDictionary.cs @@ -103,6 +103,22 @@ namespace Avalonia.Utilities ThrowDuplicate(); InsertEntry(new Entry(property, value), index); } + + /// + /// Removes all keys and values from the collection. + /// + /// + /// The Count property is set to 0, and references to other objects from elements of the + /// collection are also released. The capacity remains unchanged. + /// + public void Clear() + { + if (_entries is not null) + { + Array.Clear(_entries, 0, _entries.Length); + _entryCount = 0; + } + } /// /// Determines whether the collection contains the specified key.