PC Review


Reply
Thread Tools Rate Thread

Attributes and Validation

 
 
=?Utf-8?B?RnJhbmNpcyBSZWVk?=
Guest
Posts: n/a
 
      13th Apr 2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom attributes on controls fail validation =?Utf-8?B?RG90Y29t?= Microsoft ASP .NET 1 21st Nov 2005 01:16 AM
Re: button attributes disable validation Tim Meagher Microsoft C# .NET 0 31st Aug 2005 07:57 PM
W3C Validation Checker and FP attributes (help please) =?Utf-8?B?TWFyZ2FyZXQ=?= Microsoft Frontpage 1 26th May 2005 04:44 PM
button.Attributes.Add does not work after I added Validation control on the page Bruce Microsoft VB .NET 0 16th Oct 2003 03:44 AM
button.Attributes.Add does not work after I added Validation control on the page Bruce Microsoft VB .NET 1 15th Oct 2003 10:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 PM.