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.
 
 
 
 
 

33 lines
1.1 KiB

// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschränkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System;
namespace Squidex.Infrastructure.States
{
public sealed class DefaultStreamNameResolver : IStreamNameResolver
{
private static readonly string[] Suffixes = { "Grain", "DomainObject", "State" };
public string GetStreamName(Type aggregateType, string id)
{
var typeName = char.ToLower(aggregateType.Name[0]) + aggregateType.Name.Substring(1);
foreach (var suffix in Suffixes)
{
if (typeName.EndsWith(suffix, StringComparison.Ordinal))
{
typeName = typeName.Substring(0, typeName.Length - suffix.Length);
break;
}
}
return $"{typeName}-{id}";
}
}
}