A
Albert Tollkuçi
I have created a class ValidationResult which
looks like:
class ValidationResult
{
ValidationStatus Status;
ValidationItemCollection Items;
}
The ValidationItem is defined as below:
class ValidationItem
{
ValidationStatus Staus;
string Code; // Error code usually, but can be a warning, info or sth
else
string Message;
}
ValidationStatus is an enumeration which for the moment is defined as:
enum ValidationStatus
{
Success,
Failed
// Later can be added Warning, Info etc.
}
Now the problem is how to pass the ValidationResult object to the UI. I see
3 options:
1. throw an exeception which has a property of type ValidationResult. The UI
then can catch the exception and proceed. Looks a bit messy to me...
Pros: Force the UI to handel the validation.
Cons: Looks like a bad design. UI code would be messy...
2. Fire an event on a "global" object accessible from both UI and
components. "Recomment" the UI to attach an event handler...
Pros: UI code should be better organized...
Cons: UI is not forced to handle the event...
3. Use some kind of queue to add the ValidationResult objects from the
components and poll them from the UI.
Pros: ?
Cons: ?
Any thoughts are welcome.
Thanx,
Albert
looks like:
class ValidationResult
{
ValidationStatus Status;
ValidationItemCollection Items;
}
The ValidationItem is defined as below:
class ValidationItem
{
ValidationStatus Staus;
string Code; // Error code usually, but can be a warning, info or sth
else
string Message;
}
ValidationStatus is an enumeration which for the moment is defined as:
enum ValidationStatus
{
Success,
Failed
// Later can be added Warning, Info etc.
}
Now the problem is how to pass the ValidationResult object to the UI. I see
3 options:
1. throw an exeception which has a property of type ValidationResult. The UI
then can catch the exception and proceed. Looks a bit messy to me...
Pros: Force the UI to handel the validation.
Cons: Looks like a bad design. UI code would be messy...
2. Fire an event on a "global" object accessible from both UI and
components. "Recomment" the UI to attach an event handler...
Pros: UI code should be better organized...
Cons: UI is not forced to handle the event...
3. Use some kind of queue to add the ValidationResult objects from the
components and poll them from the UI.
Pros: ?
Cons: ?
Any thoughts are welcome.
Thanx,
Albert