1. What's the best practice to store settings? I like using my own
class as I can choose how to serialize and store the data
If the purpose is similar to ApplicationSettings, I'd use
ApplicationSettings - simply as a time saver.
2. How do I validate the inserted data? Should the validation logic be
handled by the UI or the underlying business logic
An interesting one; obviously if you use ApplicationSettings you can't
do the latter, so it would have to be the former - but the latter is
generally preferable. If you *did* have your own class, then this
could be by exceptions from the property setters (which your UI must
handle) - or it could be via IDataErrorInfo (which some bindings [esp.
grids] will display automatically).
3. I don't think I can revert the changes using a business object, so
my idea is to create a copy of the original settings object and
overwrite it if the user confirms the operation.
Actually, some overly complex things are possible using
TransactionScopes ;-p But don't go there!
Yes - when using databinding, the object is generally updated quite
early, making it a pain to press Cancel. One option is to set the
Binding's DataSourceUpdateMode to Never and do it manually (when OK is
clicked) by using WriteValue().
Alternatively, look into the memento pattern, or take a snapshot using
either ICloneable or serialization; note the ICloneable is less
reliable as it is ambiguous over deep/shallow clone (serialization
will either be deep or will fail).
Marc
3. I don't think I can revert the changes using a business object, so
my idea is to create a copy of the original settings object and
overwrite it if the user confirms the operation.
Thanks a lot.
Andrea