| 12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- namespace TeamAAS.Communication.Attributes
- {
- /// <summary>
- /// 通讯设备特性标记。实现 ICommunication 的设备类必须标记本特性,
- /// 反射加载时会根据 DisplayName 生成下拉选项,按 Category 分组。
- /// 新增设备只需:实现 ICommunication + 加本特性,无需改动任何现有代码。
- /// </summary>
- [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
- public sealed class CommunicationAttribute : Attribute
- {
- /// <summary>显示名称,如"三菱 PLC"</summary>
- public string DisplayName { get; }
- /// <summary>分类,如"PLC"、"仪器",用于下拉框分组,默认 PLC</summary>
- public string Category { get; }
- /// <summary>说明</summary>
- public string Description { get; }
- /// <summary>
- /// 品牌专属调试页类型(必须是 <c>System.Windows.FrameworkElement</c> 的子类,且建议实现
- /// <c>TeamAAS.Communication.UI.ICommunicationDebugPage</c> 以接收通讯设备实例)。
- /// 为 null(默认)时,宿主使用通用的通讯测试面板。
- /// 用法:[Communication("三菱 PLC", "PLC", DebugPageType = typeof(MitsubishiDebugPage))]
- /// </summary>
- public Type DebugPageType { get; set; }
- public CommunicationAttribute(string displayName, string category = "PLC", string description = "")
- {
- DisplayName = displayName;
- Category = category;
- Description = description;
- }
- }
- }
|