improvements

This commit is contained in:
Loretta 2025-11-21 07:20:35 +01:00
parent e0666027b3
commit a724fce2f6
2 changed files with 14 additions and 6 deletions

View File

@ -5,7 +5,7 @@ using System.ComponentModel;
namespace AyCode.Core.Helpers namespace AyCode.Core.Helpers
{ {
public interface IAcFastObservableCollection public interface IAcObservableCollection
{ {
public void AddRange(IEnumerable other); public void AddRange(IEnumerable other);
public void Replace(IEnumerable other); public void Replace(IEnumerable other);
@ -13,17 +13,25 @@ namespace AyCode.Core.Helpers
public void Synchronize(NotifyCollectionChangedEventArgs args); public void Synchronize(NotifyCollectionChangedEventArgs args);
} }
public interface IAcFastObservableCollection<T> : IAcFastObservableCollection public interface IAcObservableCollection<T> : IAcObservableCollection
{ {
public void Replace(IEnumerable<T> other); public void Replace(IEnumerable<T> other);
public void Sort(IComparer<T> comparer); public void Sort(IComparer<T> comparer);
public void SortAndReplace(IEnumerable<T> other, IComparer<T> comparer); public void SortAndReplace(IEnumerable<T> other, IComparer<T> comparer);
} }
public class AcFastObservableCollection<T> : ObservableCollection<T>, IAcFastObservableCollection<T> public class AcObservableCollection<T> : ObservableCollection<T>, IAcObservableCollection<T>
{ {
private bool _suppressChangedEvent; private bool _suppressChangedEvent;
public AcObservableCollection() : base()
{ }
public AcObservableCollection(List<T> list) : base(list)
{ }
public AcObservableCollection(IEnumerable<T> collection) : base(collection)
{ }
public void Replace(IEnumerable<T> other) public void Replace(IEnumerable<T> other)
{ {
_suppressChangedEvent = true; _suppressChangedEvent = true;

View File

@ -204,9 +204,9 @@ namespace AyCode.Services.Server.SignalRs
public bool HasWorkingReferenceList { get; private set; } public bool HasWorkingReferenceList { get; private set; }
public void SetWorkingReferenceList(TIList workingIList) public void SetWorkingReferenceList(TIList? workingIList)
{ {
if (workingIList == null!) return; //throw new ArgumentNullException(nameof(workingList)); if (workingIList == null) return; //throw new ArgumentNullException(nameof(workingList));
Monitor.Enter(_syncRoot); Monitor.Enter(_syncRoot);
@ -267,7 +267,7 @@ namespace AyCode.Services.Server.SignalRs
{ {
switch (destination) switch (destination)
{ {
case IAcFastObservableCollection dest: case IAcObservableCollection dest:
dest.AddRange(source); dest.AddRange(source);
break; break;
case List<TDataItem> dest: case List<TDataItem> dest: