|
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Data; |
4 | 4 | using System.Linq; |
| 5 | +using System.Reflection; |
5 | 6 | using System.Runtime.CompilerServices; |
6 | 7 | using System.Text; |
7 | 8 | using System.Threading.Tasks; |
|
16 | 17 | using Vertex.Abstractions.Snapshot; |
17 | 18 | using Vertex.Abstractions.Storage; |
18 | 19 | using Vertex.Protocol; |
| 20 | +using Vertex.Runtime.Actor.Attributes; |
19 | 21 | using Vertex.Runtime.Event; |
20 | 22 | using Vertex.Runtime.Exceptions; |
21 | 23 | using Vertex.Runtime.Options; |
@@ -67,8 +69,18 @@ public class VertexActor<TPrimaryKey, T> : ActorBase<TPrimaryKey>, IVertexActor |
67 | 69 | /// <returns></returns> |
68 | 70 | protected virtual async ValueTask DependencyInjection() |
69 | 71 | { |
70 | | - this.VertexOptions = this.ServiceProvider.GetService<IOptionsMonitor<ActorOptions>>().Get(this.ActorType.FullName); |
71 | | - this.ArchiveOptions = this.ServiceProvider.GetService<IOptionsMonitor<ArchiveOptions>>().Get(this.ActorType.FullName); |
| 72 | + var optionPolicy = this.ActorType.GetCustomAttribute<VertexPolicyAttribute>(true); |
| 73 | + if (optionPolicy != default) |
| 74 | + { |
| 75 | + this.VertexOptions = this.ServiceProvider.GetService<IOptionsMonitor<ActorOptions>>().Get(optionPolicy.OptionPolicy); |
| 76 | + this.ArchiveOptions = this.ServiceProvider.GetService<IOptionsMonitor<ArchiveOptions>>().Get(optionPolicy.ArchiveOptionPolicy); |
| 77 | + } |
| 78 | + else |
| 79 | + { |
| 80 | + this.VertexOptions = this.ServiceProvider.GetService<IOptionsMonitor<ActorOptions>>().CurrentValue; |
| 81 | + this.ArchiveOptions = this.ServiceProvider.GetService<IOptionsMonitor<ArchiveOptions>>().CurrentValue; |
| 82 | + } |
| 83 | + |
72 | 84 | this.Logger = (ILogger)this.ServiceProvider.GetService(typeof(ILogger<>).MakeGenericType(this.ActorType)); |
73 | 85 | this.Serializer = this.ServiceProvider.GetService<ISerializer>(); |
74 | 86 | this.EventTypeContainer = this.ServiceProvider.GetService<IEventTypeContainer>(); |
|
0 commit comments