Ich versuche, ein LightInject Bootstrap-Programm für Prism zu erstellen, habe ich den Code des NinjectBootstrapper
(source) kopiert und ersetzt Ninject des IKernel
mit LightInject der IServiceContainer
. Ich habe auch eine LightInjectServiceLocatorAdapter
(Ninject version) erstellt und registriert.Erstellen eines LightInject Bootstrapper für Prism, fehlende Registrierung der Region Adapter
Der Registrierungs- und Service-Locator-Adapter funktioniert. Ich sehe, dass die Klasse RegionAdapterMappings
erfolgreich aus dem Service-Locator abgerufen wird. Im Schritt ConfigureRegionAdapterMappings
des Bootstrappers wird eine Instanz der Klasse SelectorRegionAdapter
vom Service-Locator angefordert. Dies schlägt fehl. Die Klasse wurde nie registriert. Ich kann keinen Hinweis darauf in der NinjectBootstrapper
finden. Wie wird diese Klasse vom Ninject Bootstrapper abgerufen?
Ich habe versucht, manuell die Klasse Registrierung (und ein paar weitere Region Adapter und die DelayedRegionCreationBehavior
), aber dann nicht Prism mit einem UpdateRegionsException
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Prism.Regions.Behaviors.RegionCreationException: An exception occurred while creating a region with name 'Menu'. The exception was: System.Collections.Generic.KeyNotFoundException: The IRegionAdapter for the type System.Windows.Controls.ContentControl is not registered in the region adapter mappings. You can register an IRegionAdapter for this control by overriding the ConfigureRegionAdapterMappings method in the bootstrapper.
ich Ihre eigenen jede Quelle des Umgang mit nicht finden kann, die Schaffung Hinzufügen DI-Container und ich habe keine Ahnung, welchen Schritt ich verpasse. Was mache ich falsch?
Ich konfiguriere meine ServiceContainer
so (das Ninject entspricht der ConfigureKernel
Methode).
protected virtual void ConfigureServiceContainer()
{
this.ServiceContainer.RegisterInstance<IServiceContainer>(this.ServiceContainer);
this.ServiceContainer.RegisterInstance(this.Logger);
this.ServiceContainer.RegisterInstance(this.ModuleCatalog);
if (!this.useDefaultConfiguration)
return;
this.ServiceContainer.Register<IServiceLocator, LightInjectServiceLocatorAdapter>();
this.ServiceContainer.Register<IModuleInitializer, ModuleInitializer>();
this.ServiceContainer.Register<IModuleManager, ModuleManager>();
this.ServiceContainer.Register<RegionAdapterMappings, RegionAdapterMappings>();
// The following 4 registrations are not in the NinjectBootstrapper
this.ServiceContainer.Register<SelectorRegionAdapter, SelectorRegionAdapter>();
this.ServiceContainer.Register<ItemsControlRegionAdapter, ItemsControlRegionAdapter>();
this.ServiceContainer.Register<ContentControlRegionAdapter, ContentControlRegionAdapter>();
this.ServiceContainer.Register<DelayedRegionCreationBehavior, DelayedRegionCreationBehavior>();
this.ServiceContainer.Register<IRegionManager, RegionManager>();
this.ServiceContainer.Register<IEventAggregator, EventAggregator>();
this.ServiceContainer.Register<IRegionViewRegistry, RegionViewRegistry>();
this.ServiceContainer.Register<IRegionBehaviorFactory, RegionBehaviorFactory>();
this.ServiceContainer.Register<IRegionNavigationJournalEntry, RegionNavigationJournalEntry>();
this.ServiceContainer.Register<IRegionNavigationJournal, RegionNavigationJournal>();
this.ServiceContainer.Register<IRegionNavigationService, RegionNavigationService>();
this.ServiceContainer.Register<IRegionNavigationContentLoader, RegionNavigationContentLoader>();
}
Ich sehe zwei enge Stimmen, aber ich verstehe nicht den Grund warum? Irgendwelche Kommentare dazu? –