如何通过当前用户的信息在DDD的所有图层图层、用户、信息、DDD

由网友(衬你风流倜傥)分享简介:类似的问题已经被问过,但不完全一样(除非我错过了它)Similar questions have been asked before but not quite the same (unless I missed it)我想通过我的服务,域,域事件通过IUserInfo类的实例,域名事件处理程序... I wan...

类似的问题已经被问过,但不完全一样(除非我错过了它)

Similar questions have been asked before but not quite the same (unless I missed it)

我想通过我的服务,域,域事件通过IUserInfo类的实例,域名事件处理程序...

I want to pass IUserInfo class instance through my Service, Domain , Domain Events, Domain Event Handlers...

请告诉我是这样做的最佳方式。

Whats is the best way to do it.

我应该

通过注册它注入它使用的IoC 对Httpcontext.Current.session [的currentUser]的实例;

Inject it using IoC by registering it against instance of Httpcontext.Current.session["CurrentUser"];

将数据添加到当前线程。

Add the data to Current Thread.

任何其他方式

我停留在域名事件处理程序,我想使用的审计数据,以及发送电子邮件。

I am stuck at Domain Event Handlers where I want to use the data for auditing as well as sending emails.

我希望能够从几乎任何地方使用的currentUser信息在我的应用程序。

I want to be able to use the CurrentUser information from almost anywhere in my application.

使用线程的线程池,我怀疑,如果线程的重用会重置数据。如果没有,请shopw我如何使用线程来传递IUSER实例。

With threading as threads are pooled I am skeptical if the reuse of threads will reset the data. If not please shopw me how to use threading to pass IUser instance.

问候,

推荐答案

我使用的IoC做过这种事情。这样做的好处是,它是非常测试 - 你可以存根出你的用户信息进行测试 - 合理可读性和易于遵循

I've done this kind of thing before using IoC. The benefit of this is that it's very testable -- you can stub out your user info for testing -- and reasonably readable and easy to follow.

阅读全文

相关推荐

最新文章