improvements
This commit is contained in:
parent
a724fce2f6
commit
a67bd4f698
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
{
|
||||
|
|
@ -226,6 +226,8 @@ namespace AyCode.Services.Server.SignalRs
|
|||
}
|
||||
}
|
||||
|
||||
public TIList GetReferenceInnerList() => InnerList;
|
||||
|
||||
private object[]? GetContextParams()
|
||||
{
|
||||
var parameters = new List<object>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue