Implement object params to GetSignalRMessage
This commit is contained in:
parent
e3917c0036
commit
8b11faf10d
|
|
@ -12,6 +12,7 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||||
<PackageReference Include="MessagePack" Version="2.5.168" />
|
<PackageReference Include="MessagePack" Version="2.5.168" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ public static class SerializeObjectExtensions
|
||||||
{
|
{
|
||||||
private static readonly JsonSerializerSettings Options = new()
|
private static readonly JsonSerializerSettings Options = new()
|
||||||
{
|
{
|
||||||
|
//TypeNameHandling = TypeNameHandling.All,
|
||||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||||
NullValueHandling = NullValueHandling.Ignore
|
NullValueHandling = NullValueHandling.Ignore
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,50 @@ using MessagePack;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using AyCode.Core.Interfaces;
|
using AyCode.Core.Interfaces;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace AyCode.Services.SignalRs;
|
namespace AyCode.Services.SignalRs;
|
||||||
|
|
||||||
public class IdMessage
|
public class IdMessage
|
||||||
{
|
{
|
||||||
public List<Guid> Ids { get; private set; } = [];
|
public List<string> Ids { get; private set; } = [];
|
||||||
|
|
||||||
public IdMessage()
|
public IdMessage()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public IdMessage(params Guid[] ids) : this()
|
public IdMessage(IEnumerable<object> ids) : this()
|
||||||
{
|
{
|
||||||
Ids.AddRange(ids);
|
//Ids.AddRange(ids);
|
||||||
|
Ids.AddRange(ids.Select(x =>
|
||||||
|
{
|
||||||
|
string item;
|
||||||
|
|
||||||
|
//if (x is Expression expr)
|
||||||
|
//{
|
||||||
|
// string aa = string.Empty;
|
||||||
|
// var serializer = new ExpressionSerializer(new JsonSerializer());
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// aa = serializer.SerializeText(expr);
|
||||||
|
// }
|
||||||
|
// catch(Exception ex)
|
||||||
|
// {
|
||||||
|
// Console.WriteLine(ex);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// item = (new[] { aa }).ToJson();
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
item = (new[] { x }).ToJson();
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IdMessage(IEnumerable<Guid> ids) : this(ids.Cast<object>().ToArray())
|
||||||
|
{ }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return string.Join("; ", Ids);
|
return string.Join("; ", Ids);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue