Unity Static Factory Extension

瘦欲@ 提交于 2019-12-03 13:55:46

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:

  container.RegisterType<IFoo, Foo>(new InjectionFactory(c => new Foo());

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.

Damian Schenkelman

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!