Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

29 lines
960 B

// ==========================================================================
// DefaultStreamNameResolver.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
namespace Squidex.Infrastructure.CQRS.Events
{
public sealed class DefaultStreamNameResolver : IStreamNameResolver
{
private const string Suffix = "DomainObject";
public string GetStreamName(Type aggregateType, Guid id)
{
var typeName = char.ToLower(aggregateType.Name[0]) + aggregateType.Name.Substring(1);
if (typeName.EndsWith(Suffix, StringComparison.Ordinal))
{
typeName = typeName.Substring(0, typeName.Length - Suffix.Length);
}
return $"{typeName}-{id}";
}
}
}