質問

一部のコントローラーインスタンスで注射用に登録されている抽象的な工場があります。その抽象的な工場を登録して、注入工場として使用できますか?

これが私が持っているものです:

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()))
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top