Fix TypeNameHelper

This commit is contained in:
Sipke Schoorstra 2022-04-27 19:49:25 +02:00
parent 44859f3c16
commit 4a3dbcb245

View file

@ -1,12 +1,20 @@
using System.Reflection;
using Elsa.Attributes;
namespace Elsa.Helpers;
public static class TypeNameHelper
{
public static string? GenerateNamespace(Type activityType) => activityType.Namespace;
public static string? GenerateNamespace(Type activityType)
{
var activityAttr = activityType.GetCustomAttribute<ActivityAttribute>();
return activityAttr?.Namespace ?? activityType.Namespace;
}
public static string GenerateTypeName(Type type, string? ns)
{
var typeName = type.Name;
var activityAttr = type.GetCustomAttribute<ActivityAttribute>();
var typeName = activityAttr?.TypeName ?? type.Name;
return ns != null ? $"{ns}.{typeName}" : typeName;
}