- 优化cs ToString函数实现,正确打印窗口类型数据

main
walon 2021-06-05 10:32:26 +08:00
parent 2f46d40ca3
commit 7e03fe7192
2 changed files with 41 additions and 2 deletions

View File

@ -26,9 +26,9 @@ namespace Luban.Job.Common.Defs
return type.Apply(CsDefineTypeName.Ins); return type.Apply(CsDefineTypeName.Ins);
} }
public static string CsToString(string filedName, TType type) public static string CsToString(string fieldName, TType type)
{ {
return $"{filedName}"; return type.Apply(CsToStringVisitor.Ins, fieldName);
} }
public static string CsConstValue(TType type, string value) public static string CsConstValue(TType type, string value)

View File

@ -0,0 +1,39 @@
using Luban.Job.Common.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Luban.Job.Common.TypeVisitors
{
public class CsToStringVisitor : DecoratorFuncVisitor<string, string>
{
public static CsToStringVisitor Ins { get; } = new CsToStringVisitor();
public override string DoAccept(TType type, string fieldName)
{
return fieldName;
}
public override string Accept(TArray type, string fieldName)
{
return $"Bright.Common.StringUtil.CollectionToString({fieldName})";
}
public override string Accept(TList type, string fieldName)
{
return $"Bright.Common.StringUtil.CollectionToString({fieldName})";
}
public override string Accept(TSet type, string fieldName)
{
return $"Bright.Common.StringUtil.CollectionToString({fieldName})";
}
public override string Accept(TMap type, string fieldName)
{
return $"Bright.Common.StringUtil.CollectionToString({fieldName})";
}
}
}