Unityを使用してアプリサーバー上のサービスを管理していますが、何らかの理由で「GetAllInstances」メソッドを機能させることができません。奇妙なことに、同じタイプの「GetInstance」は正常に機能しているようです。
構成は次のとおりです。
<alias alias="IService" type="Atom.Server.Infrastructure.Interface.Service.IService, Atom.Server.Infrastructure.Interface"/>
<alias alias="IAtomCommandService" type="Atom.CommandServer.AtomCommandService.Interface.IAtomCommandService, Atom.CommandServer.AtomCommandService.Interface"/>
<alias alias="AtomCommandService" type="Atom.CommandServer.AtomCommandService.AtomCommandService, Atom.CommandServer.AtomCommandService"/>
<register type="IService" mapTo="AtomCommandService">
<lifetime type="Singleton"/>
</register>
<register type="IAtomCommandService" mapTo="AtomCommandService">
<lifetime type="Singleton"/>
</register>
サーバーの起動時に、IServiceの構成済みインスタンスをすべて取得して初期化できるようにする必要があるという考え方です。
IUnityContainer container = ConfigureUnityContainer();
UnityServiceLocator locator = new UnityServiceLocator(container);
var single = locator.GetInstance<IService>();
var all = locator.GetAllInstances<IService>().ToList();
私が言うように、シングルは機能しますが、getallは何も返しません。構成からIAtomCommandServiceマッピングを削除し、IServiceを使用しただけでも、機能しません。私がこれでどこが間違っているのかについてのアイデアはありますか?