Asp.net INotifyPropertyChanged的域对象 [英] Asp.net INotifyPropertyChanged on domain objects

查看:127
本文介绍了Asp.net INotifyPropertyChanged的域对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在asp.net中域对象实现INotifyPropertyChanged和火灾关闭的属性setter PropertyChanged事件?

What happens if a domain object in asp.net implements INotifyPropertyChanged and fires off the PropertyChanged event on the property setters?

我有两个silverlight的公共域层的WebForms系统。 Silverlight的让所有的魔法绑定,域现在确实财产通知。

I have a common domain layer for both a silverlight a WebForms system. For silverlight to get all the binding magic, the domain now does property notifications.

我的web表单系统似乎并没有受到影响(一切仍然有效),但我很担心,事情正在发生,我不明白幕后。

My webforms system doesn't seem to be affected (everything still works) but I am worried that something is happening behind the scenes that I don't understand.

我可以做,它扩展了原来的域对象,并覆盖性能做的通知,但是这是必要的silverlight的特定领域层?即我在加入code额外的一层没有理由。

I could make a silverlight specific domain layer that extends the original domain objects, and overrides the properties to do notifications, but is this necessary? i.e. am I adding an extra layer of code for no reason.

我的污染性与ComponentModel东西域不觉得难看。

Polluting my domain with ComponentModel stuff does feel ugly.

推荐答案

没有错,很可能会发生,但它是不是最好的方法。

Nothing wrong will probably happen, but it is not the best approach..

我可以做,它扩展了原来的域对象,并覆盖性能做的通知,但是这是必要的silverlight的特定领域层?即是我加入code额外的一层没有理由。

I could make a silverlight specific domain layer that extends the original domain objects, and overrides the properties to do notifications, but is this necessary? i.e. am I adding an extra layer of code for no reason.

要指出的第一件事是,你在Silverlight UI应该不会被绑定到域对象。事实上,你的看法绑定到视图模型,这个视图模型应该包含模型。

First thing to point out is that your UI in Silverlight should not be bound to Domain Objects. In fact, your views are bound to a ViewModel, and this viewmodel should contain Models.

UI模型!=域模型

我的污染性与ComponentModel东西域不觉得难看。

Polluting my domain with ComponentModel stuff does feel ugly.

如果你在你的领域模型添加presentation逻辑,业务逻辑层可以成为一个烂摊子,因为它是耦合到presentation层你失去抽象。试想一下,在2年内,你移动到另一个Web框架,需要特殊的逻辑模型中,你会在业务对象添加更多的逻辑是什么?

If you add presentation logic in your Domain Models, your business logic layer can become a mess and you lose abstraction since it's coupled to the presentation layer. Just imagine that in 2 years you move to another web framework that needs special logic in the models, will you add more logic in the business objects?

在我看来领域模型应该从其他层中分离和不应该依赖于技术(在这种情况下,到Silverlight的)

In my opinion Domain Models should be isolated from other layers and should not be dependant on a technology (in this case, to Silverlight)

我想补充一点,将改变你的域对象Silverlight的模式一个新层。这看起来可能是一个开销,但这样一来你的系统将是干净,清晰的隔离层。

I would add a new layer that would transform your domain objects to Silverlight Models. This might look as an overhead, but this way your system will be clean and with clear isolated layers.

有一些工具可以帮助你做到这一点映射没有太多的精力,比如 AutoMapper

There are tools that can help you to do this mappings without much effort, for example AutoMapper

这篇关于Asp.net INotifyPropertyChanged的域对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆