using RobotNet10.RobotApp.Client.Shared.Devices; namespace RobotNet10.RobotApp.Devices; /// /// Attribute để đánh dấu và cung cấp metadata cho các class kế thừa từ DeviceBase /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] public sealed class DeviceAttribute : Attribute { /// /// Loại thiết bị /// public DeviceType DeviceType { get; } /// /// Thương hiệu/nhà sản xuất của thiết bị (ví dụ: "PhenikaaX", "SICK", "Hokuyo", etc.) /// public string Brand { get; } /// /// Tên driver/implementation của thiết bị (ví dụ: "SickLMS100", "HokuyoUST10", "ModbusTCPClient", etc.) /// public string DriverName { get; } /// /// Mô tả ngắn về thiết bị (optional) /// public string? Description { get; set; } /// /// Version của driver (optional) /// public string Version { get; } /// /// Initializes a new instance of the DeviceAttribute class /// /// Loại thiết bị /// Thương hiệu/nhà sản xuất /// Tên driver/implementation /// Tên version/implementation /// Thrown when brand or driverName is null or empty public DeviceAttribute(DeviceType deviceType, string brand, string driverName, string version) { if (string.IsNullOrWhiteSpace(brand)) throw new ArgumentNullException(nameof(brand), "Brand cannot be null or empty"); if (string.IsNullOrWhiteSpace(driverName)) throw new ArgumentNullException(nameof(driverName), "DriverName cannot be null or empty"); if (string.IsNullOrWhiteSpace(version)) throw new ArgumentNullException(nameof(version), "Version cannot be null or empty"); DeviceType = deviceType; Brand = brand; DriverName = driverName; Version = version; } }