是否可以在属性上分配属性并使用它来分配其他属性 – 这样做而不使用反射?
代码:
- public class CashierOut : BaseActivity
- {
- [Description("Flag indicates whether break to execution.")]
- [DefaultValue(false)]
- [MyCustomAttribute(ParameterGroups.Extended)]
- public bool CancelExecution { get; set; }
- [Description("Flag indicates whether allow exit before declation.")]
- [DefaultValue(true)]
- [MyCustomAttribute(ParameterGroups.Extended)]
- [DisplayName("Exit before declaration?")]
- public bool AllowExitBeforeDeclare { get; set; }
- }
我想做这样的事情:
- public class CashierOut : BaseActivity
- {
- [MyResourceCustom("CashierOut.CancelExecution")]
- public bool CancelExecution { get; set; }
- [MyResourceCustom("CashierOut.AllowExitBeforeDeclare")]
- public bool AllowExitBeforeDeclare { get; set; }
- }
- public sealed class MyResourceCustom : Attribute
- {
- public string ResourcePath { get; private set; }
- public ParameterGroupAttribute(string resourcePath)
- {
- ResourcePath = resourcePath;
- // Get attributes attributes value from external resource using the path.
- }
- }