什么约定/成语/模式是您使用配置IOC容器使用新的流利接口 [英] What conventions/idioms/patterns are you using configuring IOC Containers using the new Fluent Interfaces

查看:161
本文介绍了什么约定/成语/模式是您使用配置IOC容器使用新的流利接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是在移动体大code城堡干线,其中包括新的流利接口配置容器的中间。由于该项目具有巨大的windsorConfig xml文件已经超出维护,我想我会开始利用这一新功能的优势。我知道其他容器(如StructureMap 2.0)还包含容器配置流利的接口,所以这个问题是没有根据的Windsor。

I am in the middle of moving over a large body of code to Castle Trunk which includes the new fluent interface for configuring the container. Since the project has a huge windsorConfig xml file that is beyond maintainable, I thought I would start to take advantage of this new feature. I know other containers (e.g. StructureMap 2.0) also contain fluent interfaces for container configuration, so this question isn't based around Windsor.

公约/成语/模式是您使用使用新的流利式接口容器配置什么我的问题是?

My question is what conventions/idioms/patterns are you using for container configuration using the new fluent style interfaces?

我首先想到的是要建立一个静态方法的地方(如ContainerConfig.Config),将加载所有的应用程序使用到容器的相关类型。我担心的是,最终该整体功能将最终成为几乎不可维护的XML配置文件(减去尖括号税)。

My first thought was to create a static method somewhere (e.g. ContainerConfig.Config) that would load all the relevant types that the app uses into the container. My worry is eventually this monolithic function would end up being almost as unmaintainable as the xml config file (less the angle bracket tax).

我的第二个想法是要打破它,所以每个依赖程序集,按照惯例出口其默认配置。我可以看到这是由装配在内部使用层次结构非常有用。但对于外部使用类型应该有配置,甚至在内部定义的?

My second thought was to break it down so each dependent assembly, by convention exports its default configuration. I can see this been useful for hierarchies used internally by the assembly. But for types used externally should there configuration even be defined internally?

我越觉得关于它的更多的问题,我似乎提高。是什么就可以了你的想法?

The more I thought about it the more questions I seemed to raise. What are your thoughts on it?

推荐答案

请深入了解在StructureMap 2.5。它提供了一些功能,可以显着降低来引导IOC容器的工作。它提供了一个约定优于配置技术(见下面的博客条目)

Take a deeper look at StructureMap 2.5. It offers several features to dramatically reduce the work to bootstrap the IOC container. It offers a convention over configuration technique (see the blog entries below)

请参阅从杰里米·米勒(StructureMap的作者)

See the following recent blog posts from Jeremy Miller (author of StructureMap)

<一个href="http://$c$cbetter.com/blogs/jeremy.miller/archive/2009/01/20/create-your-own-auto-registration-convention-with-structuremap.aspx"相对=nofollow>与StructureMap

Create your own Auto Registration Convention with StructureMap

        // Example from the blog post above
        var container = new Container(registry =>
        {
            registry.Scan(x =>
            {
                x.TheCallingAssembly();
                x.With<DefaultConventionScanner>();
            });
        });

<一个href="http://$c$cbetter.com/blogs/jeremy.miller/archive/2009/01/11/structuremap-2-5-2-is-released.aspx"相对=nofollow> StructureMap 2.5.2发布

这篇关于什么约定/成语/模式是您使用配置IOC容器使用新的流利接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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