/////////////////////////////////////////////////////////////////////////////
// File Description : 验证实体类
// Copyright : joyin
// -------------------------------------------------------------------------
// Date Created : Mar 26, 2010
// Author : jiangxinjun
//
/////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;
namespace HH.AMS.Entitys.Common
{
///
/// 验证实体类
///
/// 需要验证的实体类类型
public class ValidatorEntity
{
private TEntity entity;
private List errorMsgs;
///
/// 错误信息
///
public List ErrorMessages
{
get
{
if (errorMsgs == null)
{
errorMsgs = new List();
}
return errorMsgs;
}
}
///
/// 构造函数
///
///
public ValidatorEntity(TEntity entity)
{
this.entity = entity;
}
///
/// 验证
///
/// 错误成立条件
/// 如果错误成立,显示的错误信息
///
public ValidatorEntity Validate(Predicate predicate, string errorMsg)
{
if (predicate != null && predicate(entity))
{
this.ErrorMessages.Add(errorMsg);
}
return this;
}
}
}