views:

124

answers:

2

How do you know if a value was passed in on a property that does not have the [Required] flag.

What will be the value of an string that is not required and was not passed in? If it is an empty string then how do you know the difference from a empty string sent by the caller?

A: 

You can't tell the difference. Both will be null if the task doesnt set a default value in the task constructor.

I don't know if it should make a difference to the custom task. If a parameter is null or empty --- String.IsNullOrEmpty() --- then the task should branch into the default logic for that particular value.

Adam
+1  A: 

If you need to know if a value was set or not then you can make a flag in your property for example

public MyTask : Task
{
    private string mName;
    private bool mNameSet;

    public string Name
    {
        get{return mName;}
        set
        {
            mName = value;
            mNameSet = true;
        }
    }

... MORE HERE

}

So you can just check the mNameSet flag to see if the property was set or not. Sayed Ibrahim Hashimi

Sayed Ibrahim Hashimi