• 自定义特性。配合枚举使用棒棒哒


     1 /// <summary>
     2 /// 自定义特性,比系统的display增加了一些参数 Created by ZhangQC 2015.08.19
     3 /// </summary>
     4 [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property,
     5 AllowMultiple = false, Inherited = false)]
     6 public sealed class CustomAttribute:Attribute
     7 {
     8 
     9 public string Name { get; set; }
    10 
    11 public object Value { get; set; }
    12 
    13 public object Value1 { get; set; }
    14 
    15 public object Value2 { get; set; }
    16 
    17 
    18 /// <summary>
    19 /// 无参构造函数(Enum写法[Custom(Name="xx",Value=xx1,Value1=xx2,Value2=xx3)]) Created by ZhangQC 2015.08.19
    20 /// </summary>
    21 public CustomAttribute()
    22 {
    23 }
    24 
    25 /// <summary>
    26 /// 有参构造函数(Enum写法[Custom("xx",xx1,xx2,xx3)]) Created by ZhangQC 2015.08.19
    27 /// </summary>
    28 /// <param name="name"></param>
    29 /// <param name="value"></param>
    30 /// <param name="value1"></param>
    31 /// <param name="value2"></param>
    32 public CustomAttribute(string name,object value,object value1,object value2)
    33 {
    34 this.Name = name;
    35 this.Value = value;
    36 this.Value1 = value1;
    37 this.Value2 = value2;
    38 }
    39 
    40 /// <summary>
    41 /// 有参构造函数(Enum写法[Custom("xx")]) Created by ZhangQC 2015.08.19
    42 /// </summary>
    43 /// <param name="name"></param>
    44 public CustomAttribute(string name)
    45 {
    46 this.Name = name;
    47 }
    48 
    49 /// <summary>
    50 /// 有参构造函数(Enum写法[Custom("xx",xx1)]) Created by ZhangQC 2015.08.19
    51 /// </summary>
    52 /// <param name="name"></param>
    53 /// <param name="value"></param>
    54 public CustomAttribute(string name, object value)
    55 {
    56 this.Name = name;
    57 this.Value = value;
    58 }
    59 /// <summary>
    60 /// 有参构造函数(Enum写法[Custom("xx",xx1,xx2)]) Created by ZhangQC 2015.08.19
    61 /// </summary>
    62 /// <param name="name"></param>
    63 /// <param name="value"></param>
    64 /// <param name="value1"></param>
    65 public CustomAttribute(string name, object value, object value1)
    66 {
    67 this.Name = name;
    68 this.Value = value;
    69 }
    70 
    71 }
  • 相关阅读:
    JVM -- Full GC触发条件总结以及解决策略
    java实现-图的相关操作
    Integer的intValue()方法
    Java transient关键字
    Redis 单线程模型介绍
    String类的intern()方法 -- 重用String对象,节省内存消耗
    数据库阿里连接池 druid配置详解
    redis 实现发布/订阅模式
    Redis实现队列
    redis 实现分布式锁
  • 原文地址:https://www.cnblogs.com/creater/p/6322019.html
Copyright © 2020-2023  润新知