在上一篇中我们讲了特性Attribute如何声明使用,
为什么我们声明的特性不像EF--MVC--WCF-WebService--UnitTest--IOC--AOP--SuperSocket里面的特性一样,具有申请的效果,
其,原因是因为我们需要在中间加一个反射控制器,来过滤Filter标记特性的类、方法、属性等;
接下来我们讲解下,特性Attribute的应用实战。
1 特性封装提供额外信息Remark封装
2 特性封装提供额外行为Validate验证
特性封装提供额外信息Remark封装
我们这里需要先准备一个枚举 UserState
UserState.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atttibute
{
public enum UserState
{
/// <summary>
/// 正常状态
/// </summary>
Normal = 0,
/// <summary>
/// 已冻结
/// </summary>