CallbackValidator
namespace System.Configuration
{
public sealed class CallbackValidator : ConfigurationValidatorBase
{
private readonly ValidatorCallback _callback;
private readonly Type _type;
public CallbackValidator(Type type, ValidatorCallback callback)
: this(callback)
{
if (type == (Type)null)
throw new ArgumentNullException("type");
_type = type;
}
internal CallbackValidator(ValidatorCallback callback)
{
if (callback == null)
throw new ArgumentNullException("callback");
_type = null;
_callback = callback;
}
public override bool CanValidate(Type type)
{
if (!(type == _type))
return _type == (Type)null;
return true;
}
public override void Validate(object value)
{
_callback(value);
}
}
}