Compare commits
2 Commits
e0666027b3
...
a67bd4f698
| Author | SHA1 | Date |
|---|---|---|
|
|
a67bd4f698 | |
|
|
a724fce2f6 |
|
|
@ -34,6 +34,7 @@ public static class SerializeObjectExtensions
|
|||
{
|
||||
if (json.StartsWith("\"") && json.EndsWith("\"")) json = Regex.Unescape(json).TrimStart('"').TrimEnd('"');
|
||||
|
||||
//JsonConvert.PopulateObject(json, existingObject);
|
||||
return JsonConvert.DeserializeObject<T>(json, options ?? Options);
|
||||
}
|
||||
|
||||
|
|
@ -44,6 +45,12 @@ public static class SerializeObjectExtensions
|
|||
return JsonConvert.DeserializeObject(json, toType, options ?? Options);
|
||||
}
|
||||
|
||||
public static void JsonTo(this string json, object target, JsonSerializerSettings? options = null)
|
||||
{
|
||||
if (json.StartsWith("\"") && json.EndsWith("\"")) json = Regex.Unescape(json).TrimStart('"').TrimEnd('"');
|
||||
|
||||
JsonConvert.PopulateObject(json, target, options ?? Options);
|
||||
}
|
||||
/// <summary>
|
||||
/// Using JSON
|
||||
/// </summary>
|
||||
|
|
@ -52,7 +59,17 @@ public static class SerializeObjectExtensions
|
|||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
[return: NotNullIfNotNull(nameof(src))]
|
||||
public static TDestination? CloneTo<TDestination>(this object? src, JsonSerializerSettings? options = null) where TDestination : class => src?.ToJson(options).JsonTo<TDestination>(options);
|
||||
public static TDestination? CloneTo<TDestination>(this object? src, JsonSerializerSettings? options = null) where TDestination : class
|
||||
=> src?.ToJson(options).JsonTo<TDestination>(options);
|
||||
|
||||
/// <summary>
|
||||
/// Using JSON
|
||||
/// </summary>
|
||||
/// <param name="src"></param>
|
||||
/// <param name="target"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public static void CopyTo(this object? src, object target, JsonSerializerSettings? options = null) => src?.ToJson(options).JsonTo(target, options);
|
||||
|
||||
//public static string ToJson(this Expression source) => JsonConvert.SerializeObject(source, Options);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.ComponentModel;
|
|||
|
||||
namespace AyCode.Core.Helpers
|
||||
{
|
||||
public interface IAcFastObservableCollection
|
||||
public interface IAcObservableCollection
|
||||
{
|
||||
public void AddRange(IEnumerable other);
|
||||
public void Replace(IEnumerable other);
|
||||
|
|
@ -13,17 +13,25 @@ namespace AyCode.Core.Helpers
|
|||
public void Synchronize(NotifyCollectionChangedEventArgs args);
|
||||
}
|
||||
|
||||
public interface IAcFastObservableCollection<T> : IAcFastObservableCollection
|
||||
public interface IAcObservableCollection<T> : IAcObservableCollection
|
||||
{
|
||||
public void Replace(IEnumerable<T> other);
|
||||
public void Sort(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;
|
||||
|
||||
public AcObservableCollection() : base()
|
||||
{ }
|
||||
public AcObservableCollection(List<T> list) : base(list)
|
||||
{ }
|
||||
|
||||
public AcObservableCollection(IEnumerable<T> collection) : base(collection)
|
||||
{ }
|
||||
|
||||
public void Replace(IEnumerable<T> other)
|
||||
{
|
||||
_suppressChangedEvent = true;
|
||||
|
|
@ -160,7 +160,7 @@ namespace AyCode.Services.Server.SignalRs
|
|||
|
||||
[Serializable]
|
||||
[DebuggerDisplay("Count = {Count}")]
|
||||
public abstract class AcSignalRDataSource<TDataItem, TId, TIList> : IList<TDataItem>, IList, IReadOnlyList<TDataItem>
|
||||
public abstract class AcSignalRDataSource<TDataItem, TId, TIList> : IList<TDataItem>, IList, IReadOnlyList<TDataItem>
|
||||
where TDataItem : class, IId<TId> where TId : struct
|
||||
where TIList : class, IList<TDataItem>
|
||||
{
|
||||
|
|
@ -204,9 +204,9 @@ namespace AyCode.Services.Server.SignalRs
|
|||
|
||||
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);
|
||||
|
||||
|
|
@ -226,6 +226,8 @@ namespace AyCode.Services.Server.SignalRs
|
|||
}
|
||||
}
|
||||
|
||||
public TIList GetReferenceInnerList() => InnerList;
|
||||
|
||||
private object[]? GetContextParams()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
|
|
@ -267,7 +269,7 @@ namespace AyCode.Services.Server.SignalRs
|
|||
{
|
||||
switch (destination)
|
||||
{
|
||||
case IAcFastObservableCollection dest:
|
||||
case IAcObservableCollection dest:
|
||||
dest.AddRange(source);
|
||||
break;
|
||||
case List<TDataItem> dest:
|
||||
|
|
|
|||
Loading…
Reference in New Issue