我使用 CDK Material Drag and Drop 实用程序创建一个启用拖放功能的表单编辑器。
它工作正常,但cdkDropList在 a 中嵌套 acdkDropListGroup不起作用。我无法将任何内容拖到嵌套的下拉列表容器中。
<div class="container">
<div class="row" cdkDropListGroup>
<div class="col-2">
<div id="toolbox" cdkDropList>
...
</div>
</div>
<div class="col-10">
<div id="formContainer" cdkDropList>
...
<div class="row">
<div class="col-md-6" cdkDropList>
... column 1 content
</div>
<div class="col-md-6" cdkDropList>
... column 1 content
</div>
</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
测试使用:Automapper 10.1.2-alpha.0.4(MyGet Build)
我们希望将 DomainEvents 映射到没有任何基类的公共合约,并将它们发布到消息队列/主题。
由于它应该是动态映射,因此在映射到目标合约时我们不知道目标类型。
对于这种情况,我们在这篇文章中提供了以下解决方案: 如何使用 Automapper 将对象映射到未知的目标类型?如下:
public async Task Publish(DomainEvent domainEvent)
{
this.logger.LogInformation("Publishing domain event. Event - {event}", domainEvent.GetType().Name);
try
{
var publicEvent = this.MapToContract(domainEvent);
await this.publishEndpoint.Publish(publicEvent);
}
catch (Exception ex)
{
this.logger.LogError("Unexpected exception while publishing domain event.", ex);
}
}
private object MapToContract(object source)
{
var sourceType = source.GetType();
TypeMap? typeMap = null;
try
{
typeMap = this.mapper.ConfigurationProvider
.GetAllTypeMaps()
.SingleOrDefault(map => map.SourceType == sourceType);
}
catch (InvalidOperationException)
{
throw new Exception($"Multiple types for …Run Code Online (Sandbox Code Playgroud)