StructureMap单例 [英] StructureMap singleton

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

问题描述

这两个等价吗?

1)var store = new DocumentStore();

1) var store = new DocumentStore();

        For<IDocumentStore>().Use(store);

2)var store = new DocumentStore();

2) var store = new DocumentStore();

        For<IDocumentStore>().Singleton().Use(store);

        For< IDocumentStore>().AlwaysUnique().Use(store);

这两个文档都将返回没有重复实例的文档存储单例吗?

Will both of these return singleton instance of documentstore with no duplicate instances?

推荐答案

当您提供实例而不是类型时,总是会出现单例行为.

You will always get singleton behavior when you provide an instance instead of just a type.

这篇关于StructureMap单例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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