[]
        
(Showing Draft Content)

折叠高级属性

此特性为活字格V10.0.0.0新增的特性。

当服务端命令属性特别多时,默认会在属性面板上显示服务端命令的所有属性。但是如果有一些属性不太常用,会大幅提高用户的学习成本。

通过标注AdvancedPropertyAttribute可以轻松解决这个问题。

设计时代码:

    public class MyPluginServerCommand : Command, ICommandExecutableInServerSideAsync
    {
        public string MyProperty { get; set; }
        public string MyProperty1 { get; set; }

        [AdvancedProperty]
        [DefaultValue(null)]
        public string MyProperty2 { get; set; }

        [AdvancedProperty]
        [DefaultValue(null)]
        public string MyProperty3 { get; set; }

        public async Task<ExecuteResult> ExecuteAsync(IServerCommandExecuteContext dataContext)
        {
            return new ExecuteResult();
        }

        public override CommandScope GetCommandScope()
        {
            return CommandScope.ExecutableInServer;
        }
    }

设计器效果:

expand3

如果用户修改过高级属性中的值,选择服务端命令后,高级设置会自动展开;如果用户没有设置过任何高级属性中的值,选中服务端命令时,高级属性会默认折叠。

折叠对象属性

设计时代码:

    public class MyPluginServerCommand : Command, ICommandExecutableInServerSideAsync
    {
        [ObjectProperty(ObjType = typeof(MyObj))]
        public MyObj MyProperty { get; set; }

        public async Task<ExecuteResult> ExecuteAsync(IServerCommandExecuteContext dataContext)
        {
            return new ExecuteResult();
        }

        public override CommandScope GetCommandScope()
        {
            return CommandScope.ExecutableInServer;
        }
    }

    public class MyObj : ObjectPropertyBase
    {
        public string MyProperty { get; set; }
        public string MyProperty1 { get; set; }

        [AdvancedProperty]
        [DefaultValue(null)]
        public string MyProperty2 { get; set; }

        [AdvancedProperty]
        [DefaultValue(null)]
        public string MyProperty3 { get; set; }
    }

设计器效果:

image

折叠对象列表属性

设计时代码:

    public class MyPluginServerCommand : Command, ICommandExecutableInServerSideAsync
    {
        [ObjectListProperty(ItemType = typeof(MyObj))]
        public List<INamedObject> MyProperty { get; set; }

        public async Task<ExecuteResult> ExecuteAsync(IServerCommandExecuteContext dataContext)
        {
            return new ExecuteResult();
        }

        public override CommandScope GetCommandScope()
        {
            return CommandScope.ExecutableInServer;
        }
    }

    public class MyObj : ObjectPropertyBase, INamedObject
    {
        public string Name { get; set; }
        public string MyProperty { get; set; }
        public string MyProperty1 { get; set; }

        [AdvancedProperty]
        [DefaultValue(null)]
        public string MyProperty2 { get; set; }

        [AdvancedProperty]
        [DefaultValue(null)]
        public string MyProperty3 { get; set; }
    }

设计器效果:

image