Heres the listing for the Bar Validator which handles the fact that the Bar method is overloaded and limits input to an integer between 0 and 5000

[Serializable]

class BarValidator : IParamValidator {

public bool Validate(object[] args) {

// Bar is overloaded. We care about only the // version that has arguments, if ( args.Length != 0 )

// First param is x. Limit to integer between 0 and 5000. int x = (int)args[0];

string err = String.Format(

"BarValidator detected illegal 'x' parameter " + "value of '{0}'.\nLegal values: 0 <= x <= 5000.", x);

throw new ArgumentException(err);

return true;

0 0

Post a comment