public void MustThrowDuplicateModuleExceptionIfTheModuleIsRegisteredInMoreThanOnceCatalog() { var catalog = new CompositeModuleCatalog(); var firstCatalog = new ModuleCatalog(); firstCatalog.AddModule(new ModuleInfo("ModuleA", typeof(ModuleA).FullName)); catalog.Add(firstCatalog); var secondCatalog = new ModuleCatalog(); secondCatalog.AddModule(new ModuleInfo("ModuleA", typeof(ModuleA).FullName)); catalog.Add(secondCatalog); ExceptionTester.CallMethodAndExpectException <DuplicateModuleException>(() => catalog.Initialize()); }
/// <summary> /// Creates a <see cref="ModuleCatalog" /> from XAML. /// </summary> /// <param name="xamlStream"><see cref="Stream" /> that contains the XAML declaration of the catalog.</param> /// <returns>An instance of <see cref="ModuleCatalog" /> built from the XAML.</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="xamlStream" /> is <c>null</c>.</exception> public static ModuleCatalog CreateFromXaml(Stream xamlStream) { Argument.IsNotNull("xamlStream", xamlStream); // Note: create custom module catalog that users can use prism example xaml code as well var moduleCatalog = new ModuleCatalog(); var temporaryModuleCatalog = XamlReader.Load(xamlStream) as IModuleCatalog; if (temporaryModuleCatalog != null) { foreach (var module in temporaryModuleCatalog.Modules) { moduleCatalog.AddModule(module); } } return(moduleCatalog); }