Skip to content

Commit 8af681a

Browse files
committed
🚀 feat(events): 添加序列化支持到多个事件类
1 parent 1485d43 commit 8af681a

8 files changed

Lines changed: 30 additions & 7 deletions

File tree

examples/Transfer.Client/Transfer.Client.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Sdk Name="Microsoft.Build.CentralPackageVersions" />
33
<PropertyGroup>
44
<IsPackable>false</IsPackable>
5+
<OutputType>Exe</OutputType>
56
</PropertyGroup>
67
<ItemGroup>
78
<PackageReference Include="Microsoft.Orleans.CodeGenerator" />

src/Vertex.Abstractions/Event/EventUnit.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public class EventUnit<TPrimaryKey>
1414

1515
[Id(1)]
1616
public EventMeta Meta { get; set; }
17-
17+
18+
[Id(3)]
1819
public IEvent Event { get; set; }
1920
}
2021
}

test/Vertex.Runtime.Test/Biz/Events/ErrorTestEvent.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
using Vertex.Abstractions.Event;
1+
using Orleans;
2+
using Vertex.Abstractions.Event;
23

34
namespace Vertex.Runtime.Test.Events
45
{
56
[EventName(nameof(ErrorTestEvent))]
7+
[GenerateSerializer]
68
public class ErrorTestEvent : IEvent
79
{
810
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
using Vertex.Abstractions.Event;
1+
using Orleans;
2+
using Vertex.Abstractions.Event;
23

34
namespace Vertex.Runtime.Test.Events
45
{
56
[EventName(nameof(TopupEvent))]
7+
[GenerateSerializer]
68
public class TopupEvent : IEvent
79
{
10+
[Id(0)]
811
public decimal Amount { get; set; }
912

13+
[Id(1)]
1014
public decimal Balance { get; set; }
1115
}
1216
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
using Vertex.Abstractions.Event;
1+
using Orleans;
2+
using Vertex.Abstractions.Event;
23

34
namespace Vertex.Runtime.Test.Events
45
{
56
[EventName(nameof(TransferArrivedEvent))]
7+
[GenerateSerializer]
68
public class TransferArrivedEvent : IEvent
79
{
10+
[Id(0)]
811
public decimal Amount { get; set; }
912

13+
[Id(1)]
1014
public decimal Balance { get; set; }
1115
}
1216
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
using Vertex.Abstractions.Event;
1+
using Orleans;
2+
using Vertex.Abstractions.Event;
23

34
namespace Vertex.Runtime.Test.Events
45
{
56
[EventName(nameof(TransferEvent))]
7+
[GenerateSerializer]
68
public class TransferEvent : IEvent
79
{
10+
[Id(0)]
811
public long ToId { get; set; }
912

13+
[Id(1)]
1014
public decimal Amount { get; set; }
1115

16+
[Id(2)]
1217
public decimal Balance { get; set; }
1318
}
1419
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
using Vertex.Abstractions.Event;
1+
using Orleans;
2+
using Vertex.Abstractions.Event;
23

34
namespace Vertex.Runtime.Test.Events
45
{
56
[EventName(nameof(TransferRefundsEvent))]
7+
[GenerateSerializer]
68
public class TransferRefundsEvent : IEvent
79
{
10+
[Id(0)]
811
public decimal Amount { get; set; }
912

13+
[Id(1)]
1014
public decimal Balance { get; set; }
1115
}
1216
}

test/Vertex.Runtime.Test/Serialization/NoNamedEvent.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using Vertex.Abstractions.Event;
1+
using Orleans;
2+
using Vertex.Abstractions.Event;
23

34
namespace Vertex.Runtime.Test.Serialization
45
{
6+
[GenerateSerializer]
57
public class NoNamedEvent : IEvent
68
{
79
}

0 commit comments

Comments
 (0)