Hi
Hi I and currently coding a very large project and find myself always
putting the same validation code inside my functions. I was wondering if it's
possible to add an attribute to any method that simply validates all the
parameters sent to the method to see if they are not null, or not an empty
string. If a parameter is null, I want to throw an ArgumentNullException with
the parameter name, and if a parameter is an empty string I want to throw an
ArgumentException with the parameter name.
[NotNullOrEmpty]
public void DoSomething(string name, string description)
{
...
}
[NotNullOrEmpty]
public void DoSomethingElse(string color, string application, string shape)
{
...
}
etc
I would really appreciate it if someone could help me out on how to write
such an attribute, or at least point me to some resources explaining how to
implement it. I look forward to hearing from you.
Cheers
Francis
|