(client) feat:实现定义数据的ToString输出
This commit is contained in:
@ -1,13 +1,14 @@
|
||||
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class Define
|
||||
public abstract class Define
|
||||
{
|
||||
public string defName;
|
||||
public string label;
|
||||
public string discription;
|
||||
public string description;
|
||||
public string packID;
|
||||
/// <summary>
|
||||
/// 初始化方法,根据传入的 XML 元素 (<paramref name="xmlDef"/>) 进行处理。
|
||||
@ -34,9 +35,24 @@ namespace Data
|
||||
{
|
||||
defName = xmlDef.Element("defName")?.Value;
|
||||
label = xmlDef.Element("label")?.Value;
|
||||
discription = xmlDef.Element("discription")?.Value;
|
||||
description = xmlDef.Element("description")?.Value;
|
||||
return false;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
// 定义对齐格式(左对齐,固定宽度)
|
||||
const int labelWidth = -15; // 标签左对齐,占15字符
|
||||
const int valueWidth = -30; // 值左对齐,占30字符
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine($"{"DefName:",labelWidth}{defName,valueWidth}");
|
||||
sb.AppendLine($"{"Label:",labelWidth}{label,valueWidth}");
|
||||
sb.AppendLine($"{"Description:",labelWidth}{description,valueWidth}");
|
||||
sb.AppendLine($"{"PackID:",labelWidth}{packID,valueWidth}");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user