com.alicizax.unity.framework/Editor/UI/IUIGeneratorHelper.cs
2025-11-07 20:47:57 +08:00

32 lines
1.0 KiB
C#

using System;
namespace AlicizaX.UI.Editor
{
public interface IUIGeneratorHelper
{
string GetPrivateComponentByNameRule(string regexName, string componetName, EBindType bindType);
string GetPublicComponentByNameRule(string variableName);
}
public class DefaultUIGeneratorHelper : IUIGeneratorHelper
{
public string GetPrivateComponentByNameRule(string regexName, string componentName, EBindType bindType)
{
string endPrefix = bindType == EBindType.ListCom ? "List" : string.Empty;
int endNameIndex = componentName.IndexOf(
UIGenerateConfiguration.Instance.UIGenerateCommonData.ComCheckEndName,
StringComparison.Ordinal);
string componentSuffix = endNameIndex >= 0 ? componentName.Substring(endNameIndex + 1) : componentName;
return $"m{regexName}{componentSuffix}{endPrefix}";
}
public string GetPublicComponentByNameRule(string variableName)
{
return variableName.Substring(1);
}
}
}