SignalRServer InvokeMethodByMessageTag is in progress...
This commit is contained in:
parent
4f736312cc
commit
0fd78ba482
|
|
@ -19,7 +19,7 @@ public static class SerializeObjectExtensions
|
||||||
public static string ToJson<T>(this T source) => JsonConvert.SerializeObject(source, Options);
|
public static string ToJson<T>(this T source) => JsonConvert.SerializeObject(source, Options);
|
||||||
public static string ToJson<T>(this IQueryable<T> source) where T : class, IAcSerializableToJson => JsonConvert.SerializeObject(source, Options);
|
public static string ToJson<T>(this IQueryable<T> source) where T : class, IAcSerializableToJson => JsonConvert.SerializeObject(source, Options);
|
||||||
public static string ToJson<T>(this IEnumerable<T> source) where T : class, IAcSerializableToJson => JsonConvert.SerializeObject(source, Options);
|
public static string ToJson<T>(this IEnumerable<T> source) where T : class, IAcSerializableToJson => JsonConvert.SerializeObject(source, Options);
|
||||||
|
|
||||||
public static T? JsonTo<T>(this string json)
|
public static T? JsonTo<T>(this string json)
|
||||||
{
|
{
|
||||||
if (json.StartsWith("\"") && json.EndsWith("\"")) json = Regex.Unescape(json).TrimStart('"').TrimEnd('"');
|
if (json.StartsWith("\"") && json.EndsWith("\"")) json = Regex.Unescape(json).TrimStart('"').TrimEnd('"');
|
||||||
|
|
@ -27,6 +27,12 @@ public static class SerializeObjectExtensions
|
||||||
return JsonConvert.DeserializeObject<T>(json, Options);
|
return JsonConvert.DeserializeObject<T>(json, Options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static object? JsonTo(this string json, Type toType)
|
||||||
|
{
|
||||||
|
if (json.StartsWith("\"") && json.EndsWith("\"")) json = Regex.Unescape(json).TrimStart('"').TrimEnd('"');
|
||||||
|
|
||||||
|
return JsonConvert.DeserializeObject(json, toType, Options);
|
||||||
|
}
|
||||||
|
|
||||||
public static byte[] ToMessagePack(this object message) => MessagePackSerializer.Serialize(message);
|
public static byte[] ToMessagePack(this object message) => MessagePackSerializer.Serialize(message);
|
||||||
public static byte[] ToMessagePack(this object message, MessagePackSerializerOptions options) => MessagePackSerializer.Serialize(message, options);
|
public static byte[] ToMessagePack(this object message, MessagePackSerializerOptions options) => MessagePackSerializer.Serialize(message, options);
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,18 @@ using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace AyCode.Services.SignalRs;
|
namespace AyCode.Services.SignalRs;
|
||||||
|
|
||||||
|
public class SignalPostJsonMessage
|
||||||
|
{
|
||||||
|
[Key(0)]
|
||||||
|
public string PostDataJson { get; set; }
|
||||||
|
|
||||||
|
public SignalPostJsonMessage()
|
||||||
|
{}
|
||||||
|
protected SignalPostJsonMessage(string postDataJson) => PostDataJson = postDataJson;
|
||||||
|
}
|
||||||
|
|
||||||
[MessagePackObject]
|
[MessagePackObject]
|
||||||
public class SignalPostJsonDataMessage<TPostDataType> : ISignalPostMessage<TPostDataType> where TPostDataType : class
|
public class SignalPostJsonDataMessage<TPostDataType> : SignalPostJsonMessage, ISignalPostMessage<TPostDataType> where TPostDataType : class
|
||||||
{
|
{
|
||||||
[IgnoreMember]
|
[IgnoreMember]
|
||||||
private TPostDataType? _postData;
|
private TPostDataType? _postData;
|
||||||
|
|
@ -25,12 +35,11 @@ public class SignalPostJsonDataMessage<TPostDataType> : ISignalPostMessage<TPost
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Key(0)]
|
public SignalPostJsonDataMessage() : base()
|
||||||
public string PostDataJson { get; set; }
|
{}
|
||||||
|
|
||||||
public SignalPostJsonDataMessage(){}
|
|
||||||
public SignalPostJsonDataMessage(TPostDataType postData) => PostData = postData;
|
public SignalPostJsonDataMessage(TPostDataType postData) => PostData = postData;
|
||||||
public SignalPostJsonDataMessage(string postDataJson) => PostDataJson = postDataJson;
|
public SignalPostJsonDataMessage(string postDataJson) : base(postDataJson)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
[MessagePackObject]
|
[MessagePackObject]
|
||||||
|
|
@ -75,8 +84,12 @@ public sealed class SignalResponseJsonMessage : ISignalResponseMessage<string>
|
||||||
Status = status;
|
Status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignalResponseJsonMessage(SignalResponseStatus status, object? responseData) : this(status, responseData.ToJson())
|
public SignalResponseJsonMessage(SignalResponseStatus status, object? responseData) : this(status)
|
||||||
{ }
|
{
|
||||||
|
if (responseData is string)
|
||||||
|
ResponseData = responseData as string;
|
||||||
|
else ResponseData = responseData.ToJson();
|
||||||
|
}
|
||||||
|
|
||||||
public SignalResponseJsonMessage(SignalResponseStatus status, string? responseDataJson) : this(status)
|
public SignalResponseJsonMessage(SignalResponseStatus status, string? responseDataJson) : this(status)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue