【发布时间】:2021-01-18 18:00:49
【问题描述】:
我正在尝试根据我在 yaml 文件的输出中获得的值来格式化对象的属性名称。我正在使用 yamldotnet 库。以下是我的课程
State.cs
public class State
{
public string name { get; set; }
public List<Operation> operations { get; set; }
}
Operation.cs
public class Operation
{
public string name { get; set; }
public string type { get; set; }
}
在状态类中,我有操作列表。序列化后,我得到以下 yaml 输出:
states:
- name: uPError
operations:
- name: switch on uP
type: entry
- name: switch off uP
type: exit
- name: test Do
type: do
但我打算显示的格式如下:
states:
- name: uPError
entryActions: [switch on uP]
exitActions: [switch off uP]
doActions: [test Do]
我正在获取类型及其名称,根据类型,我需要将其更改为 entryAction、exitActions 或 doActions 和然后附加相应的名称。如何实现上述预期格式?提前致谢。
【问题讨论】:
标签: c# .net yaml yamldotnet