using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; namespace APT.Infrastructure.Core { [AttributeUsage(AttributeTargets.Class, Inherited = true)] public class UnionKeyAttribute : Attribute { private string _unionKey = string.Empty; public string UnionKey { get { return _unionKey; } } public UnionKeyAttribute(string unionKey) { _unionKey = unionKey; } } [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class CUniqueAttribute : Attribute { private string _displayName = string.Empty; private bool _isCheckOrg = false; private bool _isCheckEmpty = true; public string DisplayName { get { return _displayName; } } public bool IsCheckOrg { get { return _isCheckOrg; } } public bool IsCheckEmpty { get { return _isCheckEmpty; } } public CUniqueAttribute() : this(string.Empty) { } public CUniqueAttribute(bool isCheckOrg) : this(string.Empty, isCheckOrg) { } public CUniqueAttribute(string displayName) : this(displayName, false) { } public CUniqueAttribute(string displayName, bool isCheckOrg) : this(displayName, isCheckOrg, true) { } public CUniqueAttribute(string displayName, bool isCheckOrg, bool isCheckEmpty) : base() { _displayName = displayName; _isCheckOrg = isCheckOrg; _isCheckEmpty = isCheckEmpty; } } /// /// 枚举属性 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class EnumNameAttribute : Attribute { private string _enumName = string.Empty; public string EnumName { get { return _enumName; } } public EnumNameAttribute(string enumName) : base() { _enumName = enumName; } } /// /// 枚举项排序索引小标 属性 /// [AttributeUsage(AttributeTargets.All, Inherited = true)] public class EnumSortIndexAttribute : Attribute { private int _sortIndex = 0; public int SortIndex { get { return _sortIndex; } } public EnumSortIndexAttribute() : base() { } public EnumSortIndexAttribute(int sortIndex) : base() { _sortIndex = sortIndex; } } /// /// 枚举项排序索引小标 属性 /// [AttributeUsage(AttributeTargets.All, Inherited = true)] public class IgnoreT4Attribute : Attribute { public IgnoreT4Attribute() : base() { } } [AttributeUsage(AttributeTargets.All, Inherited = true)] public class DataRuleFieldAttribute : Attribute { private string _fileName = ""; public DataRuleFieldAttribute(string fileName) : base() { _fileName = fileName; } public string FileName { get { return _fileName; } } } /// /// 枚举属性 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class CodeRuleAttribute : Attribute { private int[] _codeRuleTypes = null; private bool _isCheckState = true; public bool IsCheckState { get { return _isCheckState; } } public int[] CodeRuleTypes { get { return _codeRuleTypes; } } public CodeRuleAttribute(params int[] codeRuleTypes) : this(true, codeRuleTypes) { } public CodeRuleAttribute(bool isCheckState, params int[] codeRuleTypes) : base() { _isCheckState = isCheckState; _codeRuleTypes = codeRuleTypes; } } /// /// 数据记录 /// [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)] public sealed class DataRecordAttribute : Attribute { /// /// 数据记录 /// /// 数据方向 public DataRecordAttribute(DataDirection direction) { Direction = direction; } /// /// 数据方向 /// public DataDirection Direction { get; set; } } public class OperateCodeAttribute : Attribute { /// /// 初始化一个类型的新实例 /// public OperateCodeAttribute(String code) { Code = code; } /// /// 获取 操作符 /// public String Code { get; private set; } } /// /// 首字母简称属性 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class AcronymFieldAttribute : Attribute { private string _acronymFieldName = null; public string AcronymFieldName { get { return _acronymFieldName; } } public AcronymFieldAttribute(string acronymFieldName) : base() { _acronymFieldName = acronymFieldName; } } /// /// 编辑表单显示字段属性 /// 用于定义字段是否显示在编辑表单中 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class FormFieldEditAttribute : Attribute { private string _displayName; private int _num; /// /// 字段显示文本 /// [Description("字段显示文本")] public string DisplayName { get { return _displayName; } } /// /// 顺序索引 /// [Description("顺序索引")] public int Num { get { return _num; } } /// /// /// /// 字段显示文本 /// 顺序索引 public FormFieldEditAttribute(string diplayName, int num) : base() { _displayName = diplayName; _num = num; } /// /// /// /// 字段显示文本 public FormFieldEditAttribute(string diplayName) : this(diplayName, 0) { } public FormFieldEditAttribute() : this(string.Empty) { } } /// /// 列表表单显示字段属性 /// 用于定义字段是否显示在列表表单中 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class FormFieldTableAttribute : Attribute { private string _displayName; private int _num; /// /// 字段显示文本 /// [Description("字段显示文本")] public string DisplayName { get { return _displayName; } } /// /// 顺序索引 /// [Description("顺序索引")] public int Num { get { return _num; } } /// /// /// /// 字段显示文本 /// 顺序索引 public FormFieldTableAttribute(string displayName, int num) : base() { _displayName = displayName; _num = num; } /// /// /// /// 字段显示文本 public FormFieldTableAttribute(string displayName) : this(displayName, 0) { } public FormFieldTableAttribute(int num) : this(string.Empty, num) { } public FormFieldTableAttribute() : this(string.Empty) { } } /// /// 树表单显示字段属性 /// 用于定义字段是否显示在树表单中 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class FormFieldTreeAttribute : Attribute { private string _displayName; private int _num; /// /// 字段显示文本 /// [Description("字段显示文本")] public string DisplayName { get { return _displayName; } } /// /// 顺序索引 /// [Description("顺序索引")] public int Num { get { return _num; } } /// /// /// /// 字段显示文本 /// 顺序索引 public FormFieldTreeAttribute(string displayName, int num) : base() { _displayName = displayName; _num = num; } /// /// /// /// 字段显示文本 public FormFieldTreeAttribute(string displayName) : this(displayName, 0) { } public FormFieldTreeAttribute(int num) : this(string.Empty, num) { } public FormFieldTreeAttribute() : this(string.Empty) { } } /// /// 列表单显示查询字段属性 /// 用于定义字段是否显示在列表表单查询中 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class FormFieldQueryAttribute : Attribute { private string _displayName; private int _num; /// /// 字段显示文本 /// [Description("字段显示文本")] public string DisplayName { get { return _displayName; } } /// /// 顺序索引 /// [Description("顺序索引")] public int Num { get { return _num; } } /// /// /// /// 字段显示文本 public FormFieldQueryAttribute(string displayName, int num) : base() { _displayName = displayName; _num = num; } /// /// /// /// 字段显示文本 public FormFieldQueryAttribute(string displayName) : this(displayName, 0) { } public FormFieldQueryAttribute(int num) : this(string.Empty, num) { } public FormFieldQueryAttribute() : this(string.Empty) { } } /// /// 编辑表单显示字段属性 /// 用于定义字段是否显示在编辑表单中 /// [AttributeUsage(AttributeTargets.Class, Inherited = true)] public class FormClassEditAttribute : Attribute { private string _displayName; /// /// 字段显示文本 /// [Description("字段显示文本")] public string DisplayName { get { return _displayName; } } /// /// /// /// 字段显示文本 public FormClassEditAttribute(string diplayName) : base() { _displayName = diplayName; } public FormClassEditAttribute() : this(string.Empty) { } } /// /// 列表表单显示字段属性 /// 用于定义字段是否显示在列表表单中 /// [AttributeUsage(AttributeTargets.Class, Inherited = true)] public class FormClassTableAttribute : Attribute { private string _displayName; /// /// 字段显示文本 /// [Description("字段显示文本")] public string DisplayName { get { return _displayName; } } /// /// /// /// 字段显示文本 public FormClassTableAttribute(string displayName) : base() { _displayName = displayName; } public FormClassTableAttribute() : this(string.Empty) { } } /// /// 树表单显示字段属性 /// 用于定义字段是否显示在树表单中 /// [AttributeUsage(AttributeTargets.Class, Inherited = true)] public class FormClassTreeAttribute : Attribute { private string _displayName; /// /// 字段显示文本 /// [Description("字段显示文本")] public string DisplayName { get { return _displayName; } } /// /// /// /// 字段显示文本 public FormClassTreeAttribute(string displayName) : base() { _displayName = displayName; } public FormClassTreeAttribute() : this(string.Empty) { } } /// /// 字段长度属性 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class DataFieldLengthAttribute : Attribute { private int _length = 0; /// /// 字段长度 /// [Description("字段长度")] public int Length { get { return _length; } } /// /// /// /// 字段长度 public DataFieldLengthAttribute(int length) : base() { _length = length; } } /// /// 字段忽略属性 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class DataFieldIngoreAttribute : Attribute { public DataFieldIngoreAttribute() : base() { } } /// /// 类索引属性 /// 用于联合索引 /// [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)] public class DataClassIndexAttribute : Attribute { private string[] _fields = null; bool _isUnique = false; /// /// 索引字段列表 /// [Description("索引字段列表")] public string[] Fields { get { return _fields; } } /// /// 是否唯一索引 /// [Description("是否唯一索引")] public bool IsUnique { get { return _isUnique; } } /// /// /// /// 索引字段列表 /// 是否唯一索引 public DataClassIndexAttribute(string[] fields, bool isUnique) : base() { if (fields == null || fields.Length == 0) throw new Exception("参数异常"); _fields = fields; _isUnique = isUnique; } /// /// /// /// 索引字段列表 public DataClassIndexAttribute(string[] fields) : this(fields, false) { } } /// /// 字段索引属性 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class DataFieldIndexAttribute : Attribute { bool _isUnique = false; string[] _fields = null; /// /// 是否唯一索引 /// [Description("是否唯一索引")] public bool IsUnique { get { return _isUnique; } } [Description("是否唯一索引")] public string[] Fields { get { return _fields; } } /// /// /// /// 是否唯一索引 public DataFieldIndexAttribute(bool isUnique,params string[] fields) : base() { _isUnique = isUnique; _fields = fields; } public DataFieldIndexAttribute() : this(false) { } } /// /// 字段必填属性 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class DataFieldRequireAttribute : Attribute { private bool _isRequire = true; /// /// 是否必填 /// public bool IsRequire { get { return _isRequire; } } /// /// /// /// 是否必填 public DataFieldRequireAttribute(bool isRequire) : base() { _isRequire = isRequire; } public DataFieldRequireAttribute() : this(true) { } } /// /// 字段外键属性 /// 在外键ID字段上使用 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class DataFieldForeignKeyAttribute : Attribute { private string _navFieldName = null; private string _masterFieldName = string.Empty; private bool _isOneOnOne = false; /// /// 导航字段名称 /// [Description("导航字段名称")] public string NavFieldName { get { return _navFieldName; } } /// /// 主表导航字段名称 /// [Description("主表导航字段名称")] public string MasterFieldName { get { return _masterFieldName; } } /// /// 主表导航字段名称 /// [Description("是否一对一")] public bool IsOneOnOne { get { return _isOneOnOne; } } /// /// /// /// 导航字段名称 /// 主表导航字段名称 /// 是否1对1 public DataFieldForeignKeyAttribute(string navFieldName, string masterFieldName, bool isOneOnOne = false) : base() { if (string.IsNullOrEmpty(navFieldName)) throw new Exception("参数异常"); _navFieldName = navFieldName; _masterFieldName = masterFieldName; _isOneOnOne = isOneOnOne; } /// /// /// /// 导航字段名称 /// 是否1对1 public DataFieldForeignKeyAttribute(string navFieldName, bool isOneOnOne = false) : this(navFieldName, string.Empty, isOneOnOne) { } } /// /// 字段外键属性 /// 在主表的外键导航属性上使用 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class DataFieldForeignKeyForMasterAttribute : Attribute { private string _navFieldName = null; private string _idFieldName = null; private bool _isOneOnOne = false; /// /// 导航字段名称 /// [Description("导航字段名称")] public string NavFieldName { get { return _navFieldName; } } /// /// ID字段名称 /// [Description("ID字段名称")] public string IdFieldName { get { return _idFieldName; } } /// /// 主表导航字段名称 /// [Description("是否一对一")] public bool IsOneOnOne { get { return _isOneOnOne; } } /// /// /// /// ID字段名称 /// 导航字段名称 /// 是否一对一 public DataFieldForeignKeyForMasterAttribute(string idFieldName, string navFieldName, bool isOneOnOne = false) : base() { if (string.IsNullOrEmpty(idFieldName)) throw new Exception("参数异常"); _navFieldName = navFieldName; _idFieldName = idFieldName; _isOneOnOne = isOneOnOne; } /// /// /// /// ID字段名称 /// 是否一对一 public DataFieldForeignKeyForMasterAttribute(string idFieldName, bool isOneOnOne = false) : this(idFieldName, string.Empty, isOneOnOne) { } } /// ///获取方法的描述 /// [AttributeUsage(AttributeTargets.Method, Inherited = true)] public class FuctionDescAttribute : Attribute { private string _fucName = null; private string[] _paramterDesc ; /// /// 导航字段名称 /// [Description("函数名")] public string FucName { get { return _fucName; } } /// /// 参数说明 /// [Description("参数说明")] public string[] ParamterDesc { get { return _paramterDesc; } } /// /// 构造函数 /// /// 方法描述 /// 参数描述 public FuctionDescAttribute(string fucName, params string[] paramterDesc) : base() { _fucName = fucName; _paramterDesc = paramterDesc; } } /// /// 字段外键属性 /// 在外键ID字段上使用 /// [AttributeUsage(AttributeTargets.Property, Inherited = true)] public class UnionForeignKeyAttribute : Attribute { private string _unionKeyName = null; private string _masterFieldName = string.Empty; /// /// 导航字段名称 /// [Description("导航字段名称")] public string UnionKeyName { get { return _unionKeyName; } } /// /// 主表导航字段名称 /// [Description("主表导航字段名称")] public string MasterFieldName { get { return _masterFieldName; } } /// /// /// /// 导航字段名称 /// 主表导航字段名称 public UnionForeignKeyAttribute(string unionKeyName, string masterFieldName) : base() { if (string.IsNullOrEmpty(unionKeyName)) throw new Exception("参数异常"); _unionKeyName = unionKeyName; _masterFieldName = masterFieldName; } /// /// /// /// 导航字段名称 public UnionForeignKeyAttribute(string navFieldName) : this(navFieldName, string.Empty) { } } }