Appearance
枚举类型属性
如果属性的类型是枚举,那么在设计器中会以下拉列表的形式提供给用户编辑
csharp
public class MyPluginServerCommand : Command, ICommandExecutableInServerSideAsync
{
public UserType MyProperty1 { get; set; }
public async Task<ExecuteResult> ExecuteAsync(IServerCommandExecuteContext dataContext)
{
return new ExecuteResult();
}
public override CommandScope GetCommandScope()
{
return CommandScope.ExecutableInServer;
}
}
public enum UserType
{
Student,
Teacher,
Worker
}在设计器中效果如下

自定义枚举项目显示名称, 可以通过标注 Description 实现
csharp
public class MyPluginServerCommand : Command, ICommandExecutableInServerSideAsync
{
public UserType MyProperty1 { get; set; }
public async Task<ExecuteResult> ExecuteAsync(IServerCommandExecuteContext dataContext)
{
return new ExecuteResult();
}
public override CommandScope GetCommandScope()
{
return CommandScope.ExecutableInServer;
}
}
public enum UserType
{
[Description("学生")]
Student,
[Description("教师")]
Teacher,
[Description("工人")]
Worker
}效果
更新: 2022-12-06 11:56:51
原文: https://www.yuque.com/robert-bh51n/ea8l6c/pdvnoxhbfli6hi0g