4a46abc46d
set the maximum height of the add link to profile on client chat move change history into a seperate service move around AC penalty processing
43 lines
1016 B
C#
43 lines
1016 B
C#
using SharedLibraryCore.Interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace SharedLibraryCore.Helpers
|
|
{
|
|
/// <summary>
|
|
/// 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>
|
|
{
|
|
List<T> Values;
|
|
|
|
public ChangeTracking()
|
|
{
|
|
Values = new List<T>();
|
|
}
|
|
|
|
public void OnChange(T value)
|
|
{
|
|
lock (value)
|
|
{
|
|
// clear the first value when count max count reached
|
|
if (Values.Count > 30)
|
|
Values.RemoveAt(0);
|
|
Values.Add(value);
|
|
}
|
|
}
|
|
|
|
public T[] GetChanges() => Values.ToArray();
|
|
|
|
public bool HasChanges => Values.Count > 0;
|
|
|
|
public void ClearChanges()
|
|
{
|
|
lock (Values)
|
|
Values.Clear();
|
|
}
|
|
}
|
|
}
|