如果属性的类型是枚举,那么在设计器中会以下拉列表的形式提供给用户编辑。
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 实现。
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 }
效果: