diff --git a/CHANGELOG.md b/CHANGELOG.md index 00fe3e9..633de62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] + ### Added - Added Get and Set extensions to PropertyInfo in SIMPLSHARP to mimic overloads avaliable in NETSTANDARD + - Added Collection extensions for setting and adding ranges of items + +### Changed + - Repeater changed to use configured callbacks instead of a dumb event + - Scheduled action callbacks allow a TimeSpan to be returned to delay actions ## [12.1.0] - 2020-07-14 ### Added diff --git a/ICD.Common.Utils/Extensions/CollectionExtensions.cs b/ICD.Common.Utils/Extensions/CollectionExtensions.cs new file mode 100644 index 0000000..40fe177 --- /dev/null +++ b/ICD.Common.Utils/Extensions/CollectionExtensions.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using ICD.Common.Properties; + +namespace ICD.Common.Utils.Extensions +{ + public static class CollectionExtensions + { + /// + /// Clears the collection and adds the given range of items. + /// + /// + /// + /// + public static void SetRange([NotNull] this ICollection extends, [NotNull] IEnumerable range) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + if (range == null) + throw new ArgumentNullException("range"); + + extends.Clear(); + extends.AddRange(range); + } + + /// + /// Adds the given range of items to the collection. + /// + /// + /// + /// + public static void AddRange([NotNull] this ICollection extends, [NotNull] IEnumerable range) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + if (range == null) + throw new ArgumentNullException("range"); + + foreach (T item in range) + extends.Add(item); + } + } +} diff --git a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj index 368f8c0..14ef513 100644 --- a/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj +++ b/ICD.Common.Utils/ICD.Common.Utils_SimplSharp.csproj @@ -109,6 +109,7 @@ PreserveNewest +