开发者

Is IDataErrorInfo a waste of memory?

I have a list of business objects (1000+) with 50 or so properties they have around 70 different validations that need to be performed. It seems like the way to go is to use a validation rule, but I really like IDataErrorInfo. Is it a waste of memory to have IDataErrorInfo defi开发者_开发知识库ned for every object while they use the same validation all along?

PS: I didn't post the code because it enormous and tedious to look at.


IDataErrorInfo just contains a pair of properties.
It has no per-instance overhead.

It's up to you to make an implementation that peforms well; the shouldn't be too hard.


I am a big fan of extending the built in ValidationRule class and using it directly in bindings, as opposed to using IDataErrorInfo.

Check my blog post here, see if it helps: Taking data binding, validation and MVVM to the next level - part 1. This concentrates on how to use it for validating a TextBox, but the exact same thing applies to any bindable element, i.e. columns on a DataGrid. The advantages it gives you is you can keep the validation code out of your viewmodel and model (if you are using that sort of pattern), the validation is reusable anywhere, and you can be quite granular with which validations are applied and where.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜