ExtendAttribute.cs 1.05 KB
using Rcs.Domain.Entities;

namespace Rcs.Domain.Extensions
{
    /// <summary>
    /// 用于标注协议名称和版本的特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
    public sealed class ProtocolInfoAttribute : Attribute
    {
        /// <summary>
        /// 协议名称
        /// </summary>
        public string Manufacturer { get; }

        /// <summary>
        /// 协议版本
        /// </summary>
        public string Version { get; }
        /// <summary>
        /// 协议主题
        /// </summary>
        public string Topic { get; set; }
        /// <summary>
        /// 设备类型
        /// </summary>
        public RobotType RobotType { get; set; }

        public ProtocolInfoAttribute(string protocolName, string version, string topic, RobotType robotType = RobotType.Forklift)
        {
            Manufacturer = protocolName;
            Version = version;
            Topic = topic;
            RobotType = robotType;
        }
    }
}