using System; using System.Runtime.InteropServices; namespace DeviceRepair.Models.Attr { /// /// DOM转换时bool型转换特性 /// [Serializable] [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] [ComVisible(true)] public sealed class BoolConverterAttribute : Attribute { #region Fields /// /// 转换类型 /// public Type ConvertType { get; set; } public string[] BoolString { get; set; } #endregion #region Ctor /// /// Ctor /// public BoolConverterAttribute(string boolString) { if (string.IsNullOrEmpty(boolString)) { throw new ArgumentNullException(); } BoolString = boolString.Split(','); if (BoolString.Length != 2) { throw new ArgumentException("BooleanString格式不符合规定"); } } public BoolConverterAttribute() : this("1,0") { ConvertType = typeof(string); } #endregion #region Property #endregion } }