抽象工場を統一の射出資金として使用しますか?
質問
一部のコントローラーインスタンスで注射用に登録されている抽象的な工場があります。その抽象的な工場を登録して、注入工場として使用できますか?
これが私が持っているものです:
public interface ILevelFactory
{
Levels Create();
}
.RegisterType<ILevelFactory, LevelFactory>()
.RegisterType<Levels>(new InjectionFactory((c) => StaticLevelFactory.GetLevels()))
望ましい状況:
.RegisterType<ILevelFactory, LevelFactory>()
.RegisterType<Levels>(*** look up and use ILevelFactory ***)
要するに、私はstaticlevelfactoryを取り除きたいです。
解決
iLevelfactoryが適切に登録されている場合:
RegisterType<Levels>(new InjectionFactory((c) => c.Resolve<ILevelFactory>().GetLevels()))
所属していません StackOverflow