English 中文(简体)
将DI集装箱纳入域层。 领域活动
原标题:Integrating DI container within domain layer. Domain events

Following the article: http://www.udidahan.com/2009/06/14/domain-events-salvation/ we can see that DomainEvents implemantation uses DI container

public static IContainer Container { get; set; }

and then

if(Container != null) {
    foreach(var handler in Container.ResolveAll<Handles<T>>()) handler.Handle(args);
}

如果我把DI集装箱放在同一个组装的I储存域物体内,或者我能够将<代码>的存储器外部化/脱射。 正式批准;Handles<T>>? (在我以前的经验中,我把所有<条码>与放在<条码>上。

从技术上讲,我只熟悉Ninject DI集装箱,但可能理解这个概念,因此,你的建议/指示得到赞赏。

Thanks!

最佳回答

No it is not necessary. I d make DomainEvents and its methods non-static and use the container to create it. A decent container will create and initialize the Handles and their dependencies and allow you to call the event handlers without any reference to the container.

唯一的渔获量是活动操作者的登记。 为此,我使用Boots Capper,以举出I UnityRegistration and configure UNITY的例子。 我开始使用CommonserviceLocator,以减少依赖性。 甚至最近,我转而去了教育、青年和体育部,以便一起取消注册班。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签