mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-12 03:57:32 +00:00
Merge remote-tracking branch 'origin/ConnectPro_v1.6' into ConnectPro_v1.7
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
00803fcd66
6 changed files with 72 additions and 1 deletions
|
|
@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
### Changed
|
||||
- Rewrote JsonItemWrapper serialization for JsonConvert friendliness
|
||||
|
||||
## [11.1.0] - 2020-05-19
|
||||
### Added
|
||||
- ScrollQueue - Added OnItemTrimmed event
|
||||
- Added DateTimeNullableEventArgs
|
||||
|
||||
## [11.0.0] - 2020-03-20
|
||||
### Added
|
||||
- Added Not null tag for ICDUriBuilder Constructor that takes a URI as an argument.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using ICD.Common.Properties;
|
||||
using NUnit.Framework;
|
||||
using ICD.Common.Utils.Collections;
|
||||
using ICD.Common.Utils.EventArguments;
|
||||
|
||||
namespace ICD.Common.Utils.Tests.Collections
|
||||
{
|
||||
|
|
@ -76,5 +77,43 @@ namespace ICD.Common.Utils.Tests.Collections
|
|||
|
||||
Assert.AreEqual(0, test.Peek());
|
||||
}
|
||||
|
||||
[Test, UsedImplicitly]
|
||||
public void OnItemTrimmedTest()
|
||||
{
|
||||
ScrollQueue<int> test = new ScrollQueue<int>(3);
|
||||
|
||||
int? removedItem = null;
|
||||
|
||||
test.OnItemTrimmed += (sender, args) => removedItem = args.Data;
|
||||
|
||||
test.Enqueue(1);
|
||||
test.Enqueue(2);
|
||||
test.Enqueue(3);
|
||||
|
||||
Assert.IsNull(removedItem, "Raised Early");
|
||||
|
||||
test.Enqueue(4);
|
||||
|
||||
Assert.True(removedItem.HasValue, "Not Raised");
|
||||
if (removedItem.HasValue)
|
||||
Assert.AreEqual(1, removedItem.Value, "Incorrect Value");
|
||||
|
||||
removedItem = null;
|
||||
|
||||
test.Enqueue(5);
|
||||
|
||||
Assert.True(removedItem.HasValue, "Not Raised");
|
||||
if (removedItem.HasValue)
|
||||
Assert.AreEqual(2, removedItem.Value, "Incorrect Value");
|
||||
|
||||
removedItem = null;
|
||||
|
||||
test.MaxSize = 4;
|
||||
|
||||
test.Enqueue(6);
|
||||
|
||||
Assert.False(removedItem.HasValue, "Raised Early");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ICD.Common.Properties;
|
||||
using ICD.Common.Utils.EventArguments;
|
||||
using ICD.Common.Utils.Extensions;
|
||||
|
||||
namespace ICD.Common.Utils.Collections
|
||||
{
|
||||
|
|
@ -15,6 +17,11 @@ namespace ICD.Common.Utils.Collections
|
|||
private readonly LinkedList<TContents> m_Collection;
|
||||
private int m_MaxSize;
|
||||
|
||||
/// <summary>
|
||||
/// Raised when an item is trimmed from the end of the queue.
|
||||
/// </summary>
|
||||
public event EventHandler<GenericEventArgs<TContents>> OnItemTrimmed;
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -141,7 +148,11 @@ namespace ICD.Common.Utils.Collections
|
|||
private void Trim()
|
||||
{
|
||||
while (Count > MaxSize)
|
||||
{
|
||||
TContents removed = m_Collection.First.Value;
|
||||
m_Collection.RemoveFirst();
|
||||
OnItemTrimmed.Raise(this, new GenericEventArgs<TContents>(removed));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
15
ICD.Common.Utils/EventArguments/DateTimeNullableEventArgs.cs
Normal file
15
ICD.Common.Utils/EventArguments/DateTimeNullableEventArgs.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
|
||||
namespace ICD.Common.Utils.EventArguments
|
||||
{
|
||||
public sealed class DateTimeNullableEventArgs : GenericEventArgs<DateTime?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public DateTimeNullableEventArgs(DateTime? data) : base(data)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -98,6 +98,7 @@
|
|||
<Compile Include="EventArguments\BoolEventArgs.cs" />
|
||||
<Compile Include="EventArguments\CharEventArgs.cs" />
|
||||
<Compile Include="EventArguments\DateTimeEventArgs.cs" />
|
||||
<Compile Include="EventArguments\DateTimeNullableEventArgs.cs" />
|
||||
<Compile Include="EventArguments\FloatEventArgs.cs" />
|
||||
<Compile Include="EventArguments\GenericEventArgs.cs" />
|
||||
<Compile Include="EventArguments\IGenericEventArgs.cs" />
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ using System.Reflection;
|
|||
[assembly: AssemblyCompany("ICD Systems")]
|
||||
[assembly: AssemblyProduct("ICD.Common.Utils")]
|
||||
[assembly: AssemblyCopyright("Copyright © ICD Systems 2020")]
|
||||
[assembly: AssemblyVersion("11.0.0.0")]
|
||||
[assembly: AssemblyVersion("11.1.0.0")]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue