タイトルにあるように、名前付きインスタンスも構成した場合、structuremapはデフォルトのインスタンスを返しません。
これが私のタイプ登録です:
/// <summary>
/// Initializes a new instance of the <see cref="CommandProcessingTypeRegistry"/> class.
/// </summary>
public CommandProcessingTypeRegistry()
{
For<ICommandProcessor>().Singleton().Use<CommandCoordinator>();
For<ICommandProcessor>().Singleton().Use<SystemCommandSwitch>().Named(typeof(SystemCommandSwitch).FullName);
For<ICommandProcessor>().Singleton().Use<TelephonyCommandSwitch>().Named(typeof(TelephonyCommandSwitch).FullName);
For<ICommandProcessor>().Singleton().Use<AudioCommandSwitch>().Named(typeof(AudioCommandSwitch).FullName);
For<ICommandProcessor>().Singleton().Use<TetraCommandSwitch>().Named(typeof(TetraCommandSwitch).FullName);
For<ICommandProcessor>().Singleton().Use<RadioCommandSwitch>().Named(typeof(RadioCommandSwitch).FullName);
For<ICommandProcessor>().Singleton().Use<SnapshotCommandSwitch>().Named(typeof(SnapshotCommandSwitch).FullName);
For<ICommandProcessor>().Singleton().Use<TakeNextCommandSwitch>().Named(typeof(TakeNextCommandSwitch).FullName);
}
そして、これは私がインスタンスを要求する方法です:
_commandProcessor = _container.GetInstance<ICommandProcessor>(); // _container is the structuremap IContainer instance
上記の行でCommandCoordinatorインスタンスが返されますが、代わりにTakeNextCommandSwitchインスタンスが返されます。私はここで何が間違っているのですか?