Unity 静态工厂扩展
我似乎无法在任何地方找到 Microsoft.Practices.Unity.StaticFactory.dll。
还有其他注册静态工厂的方法吗?
寻找类似的
容器.RegisterFactory(()=> FooFactory.CreateFoo());
I can't seem to find Microsoft.Practices.Unity.StaticFactory.dll anywhere.
Is there another way of registering a static factory?
Looking for something like this
container.RegisterFactory(()=> FooFactory.CreateFoo());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
StaticFactory.dll 作为 Unity 2.0 的一部分被纳入主程序集中。它通常非常有用,因此我们不想强迫人们为了获取它而携带单独的 DLL。
因此,您仍然可以使用现有的 API,只是不需要添加程序集引用。但是,我们已弃用旧的 API。可以添加扩展,但不执行任何操作,它已包含在容器中。现在,您可以通过以下方式在容器中注册工厂:
其中 c 是解析实例的容器。还有一个选项可以传递正在解析的类型和名称。
我们弃用了旧的 API,因为它使用起来非常尴尬,而且无论如何它都不再是一个扩展了。
StaticFactory.dll was rolled into the main assembly as part of Unity 2.0. It was generally useful enough that we didn't want to force people to carry around a separate DLL just to get it.
As such, you can still use the existing API, you just don't need to add the assembly reference. However, we've deprecated the old API. The extension can be added, but does nothing, it's already included in the container. And you can now register factories in the container by saying:
where c is the container that's resolving the instance. There's also an option to pass in the type and name being resolved as well.
We deprecated the old API because it was very awkward to use and it's not an extension anymore anyway.
RegisterFactory 方法是 StaticFactoryExtension 类,它已被弃用,您可以看到
如果您正在寻找工厂扩展,此线程应该会有所帮助。
我希望这有帮助。
谢谢,
达米安
The RegisterFactory method is part of the StaticFactoryExtension class, which is deprecated as you can see here.
If you are looking for factory extensions, this thread should be helpful.
I hope this helps.
Thanks,
Damian