mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
Initial .net 6 upgrades
This commit is contained in:
@ -1,37 +1,36 @@
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace SharedLibraryCore.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// This class provides a way to keep track of changes to an entity
|
||||
/// This class provides a way to keep track of changes to an entity
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of entity to keep track of changes to</typeparam>
|
||||
public class ChangeTracking<T>
|
||||
{
|
||||
ConcurrentQueue<T> Values;
|
||||
private readonly ConcurrentQueue<T> Values;
|
||||
|
||||
public ChangeTracking()
|
||||
{
|
||||
Values = new ConcurrentQueue<T>();
|
||||
}
|
||||
|
||||
public bool HasChanges => Values.Count > 0;
|
||||
|
||||
public void OnChange(T value)
|
||||
{
|
||||
if (Values.Count > 30)
|
||||
Values.TryDequeue(out T throwAway);
|
||||
{
|
||||
Values.TryDequeue(out var throwAway);
|
||||
}
|
||||
|
||||
Values.Enqueue(value);
|
||||
}
|
||||
|
||||
public T GetNextChange()
|
||||
{
|
||||
bool itemDequeued = Values.TryDequeue(out T val);
|
||||
return itemDequeued ? val : default(T);
|
||||
var itemDequeued = Values.TryDequeue(out var val);
|
||||
return itemDequeued ? val : default;
|
||||
}
|
||||
|
||||
public bool HasChanges => Values.Count > 0;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user