EditorAttribute的别名

时间:2010-04-05 14:50:46

标签: c# attributes

有没有办法为EditorAttribute创建一个更短的别名?而不是:

    [EditorAttribute(typeof<ColorPickerDialogPropertyValueEditor>, typeof<DialogPropertyValueEditor>)]
    public Color4 Color { get; set; }

我想写:

    using ColorPicker = EditorAttribute(typeof<ColorPickerDialogPropertyValueEditor>, typeof<DialogPropertyValueEditor>)
    [ColorPicker]
    public Color4 Color { get; set; }

不幸的是,EditorAttribute类是密封的,因此我无法继承它。

1 个答案:

答案 0 :(得分:2)

我只看到一种方式:

using CPDPEditor = YourNamespace.ColorPickerDialogPropertyValueEditor;
using DPEditor = YourNamespace.DialogPropertyValueEditor;

...

[Editor(typeof(CPDPEditor), typeof(DPEditor))]

或许AttributeProvider会帮助你(不知道怎么做)

相关问题