小编Cpt*_*low的帖子

如何在Service Fabric中获取数据包的路径?

我在我的SF服务(称为WebSvc)的PackageRoot下创建了一个包含License.xml文件的数据包,如下所示:

ApplicationTypePackageRoot - > WebSvcPkg - > Data - > License.xml

现在在我的C#代码中,我想获得License.xml文件的完整路径.这该怎么做?

c# deployment azure-service-fabric

3
推荐指数
1
解决办法
1006
查看次数

如何在使用 DDD 的 CQRS 架构中使用 sagas?

我正在使用 DDD 设计 CQRS 应用程序,并且想知道如何实现以下场景:

  • 一个Participant聚合可以被多个引用ParticipantEntry聚合
  • anAddParticipantInfoCommand发送到 Command 端,其中包含Participantand one 的所有信息ParticipantEntry(类似于 an Orderand one OrderLineItem

应该在哪里实现检查 Participant 是否已经存在的逻辑,如果它不存在,则创建 Participant?

  • 是否应该在 Saga 中完成,首先检查域模型是否存在Participant,如果没有找到,则发出AddParticipantCommand一个AddParticipantEntry命令,然后发出包含Participant ID?
  • 这应该完全由域模型本身的聚合根完成吗?

domain-driven-design cqrs nservicebus-sagas

1
推荐指数
1
解决办法
1403
查看次数

如何在C#中获取泛型类的子类型

我有一个通用的方法

public async Task Save<T>(T aggregate) where T : AggregateRoot
Run Code Online (Sandbox Code Playgroud)

从这个方法我调用另一个泛型方法

var indexRegistrations = IndexRegistrar.GetAll<T>();
Run Code Online (Sandbox Code Playgroud)

现在在第二个通用方法中,我想得到真正的类型T,它是一个子类型AggregateRoot:

public static List<IndexRegistration> GetAll<T>() where T : AggregateRoot
{
    return _register.FindAll(r => r.aggregateType == typeof(T));
}
Run Code Online (Sandbox Code Playgroud)

但是,typeof(T)总是返回AggregateRoot.

我怎样才能得到真实的类型(=子类型AggregateRoot)T

c# generics

1
推荐指数
1
解决办法
1493
查看次数