diff --git a/e2e/Wpf/HelloWorld.Bootstraper/HelloWorld.Bootstrapper.csproj b/e2e/Wpf/HelloWorld.Bootstraper/HelloWorld.Bootstrapper.csproj
index db818883..ed94d416 100644
--- a/e2e/Wpf/HelloWorld.Bootstraper/HelloWorld.Bootstrapper.csproj
+++ b/e2e/Wpf/HelloWorld.Bootstraper/HelloWorld.Bootstrapper.csproj
@@ -2,7 +2,7 @@
WinExe
- netcoreapp3.1
+ net462
true
HelloWorld
@@ -15,6 +15,10 @@
+
+
+
+
@@ -24,4 +28,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/e2e/Wpf/HelloWorld.Core/HelloWorld.Core.csproj b/e2e/Wpf/HelloWorld.Core/HelloWorld.Core.csproj
index dda708b0..9d21d902 100644
--- a/e2e/Wpf/HelloWorld.Core/HelloWorld.Core.csproj
+++ b/e2e/Wpf/HelloWorld.Core/HelloWorld.Core.csproj
@@ -1,7 +1,7 @@
- netcoreapp3.1
+ netcoreapp3.1;net462
true
diff --git a/e2e/Wpf/HelloWorld/App.config b/e2e/Wpf/HelloWorld/App.config
new file mode 100644
index 00000000..8adf738e
--- /dev/null
+++ b/e2e/Wpf/HelloWorld/App.config
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/e2e/Wpf/HelloWorld/App.xaml.cs b/e2e/Wpf/HelloWorld/App.xaml.cs
index 70beeb03..1f9e03d6 100644
--- a/e2e/Wpf/HelloWorld/App.xaml.cs
+++ b/e2e/Wpf/HelloWorld/App.xaml.cs
@@ -23,8 +23,21 @@ namespace HelloWorld
protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
- base.ConfigureModuleCatalog(moduleCatalog);
moduleCatalog.AddModule();
}
+
+ //to test various module catalogs:
+ //1. Comment out ConfigureModuleCatalog
+ //2. Remove the project reference to the module project
+ //3. Make sure the Modules directory exists in the output path when debugging
+ //4. Uncomment CreateModuleCatalog to test other modules catalogs
+ //protected override IModuleCatalog CreateModuleCatalog()
+ //{
+ // return new ConfigurationModuleCatalog();
+
+ // return new DirectoryModuleCatalog() { ModulePath = "Modules" };
+
+ // return new XamlResourceCatalog("ModuleCatalog.xaml");
+ //}
}
}
diff --git a/e2e/Wpf/HelloWorld/HelloWorld.csproj b/e2e/Wpf/HelloWorld/HelloWorld.csproj
index 52282b4d..4f9a8de7 100644
--- a/e2e/Wpf/HelloWorld/HelloWorld.csproj
+++ b/e2e/Wpf/HelloWorld/HelloWorld.csproj
@@ -2,7 +2,7 @@
WinExe
- netcoreapp3.1
+ netcoreapp3.1;net462
true
HelloWorld
HelloWorld
@@ -14,12 +14,21 @@
prism-sandbox.ico
+
+
+
+
-
+
+
+
+
+ MSBuild:Compile
+
\ No newline at end of file
diff --git a/e2e/Wpf/HelloWorld/ModuleCatalog.xaml b/e2e/Wpf/HelloWorld/ModuleCatalog.xaml
new file mode 100644
index 00000000..66c8c448
--- /dev/null
+++ b/e2e/Wpf/HelloWorld/ModuleCatalog.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/e2e/Wpf/Modules/HelloWorld.Modules.ModuleA/HelloWorld.Modules.ModuleA.csproj b/e2e/Wpf/Modules/HelloWorld.Modules.ModuleA/HelloWorld.Modules.ModuleA.csproj
index fe60d44d..f0fa11d5 100644
--- a/e2e/Wpf/Modules/HelloWorld.Modules.ModuleA/HelloWorld.Modules.ModuleA.csproj
+++ b/e2e/Wpf/Modules/HelloWorld.Modules.ModuleA/HelloWorld.Modules.ModuleA.csproj
@@ -1,7 +1,7 @@
- netcoreapp3.1
+ netcoreapp3.1;net462
true
@@ -10,5 +10,7 @@
-
+
+
+
diff --git a/src/Prism.Core/Modularity/ModuleCatalogBase.cs b/src/Prism.Core/Modularity/ModuleCatalogBase.cs
index 4a78d3a6..6133cf9e 100644
--- a/src/Prism.Core/Modularity/ModuleCatalogBase.cs
+++ b/src/Prism.Core/Modularity/ModuleCatalogBase.cs
@@ -28,7 +28,7 @@ namespace Prism.Modularity
public class ModuleCatalogBase : IModuleCatalog
{
private ModuleCatalogItemCollection _items { get; }
- private bool isLoaded;
+ private bool _isLoaded;
///
/// Initializes a new instance of the class.
@@ -91,7 +91,7 @@ namespace Prism.Modularity
///
public virtual void Load()
{
- isLoaded = true;
+ _isLoaded = true;
InnerLoad();
}
@@ -179,7 +179,7 @@ namespace Prism.Modularity
/// When validation of the fails, because this method calls .
public virtual void Initialize()
{
- if (!isLoaded)
+ if (!_isLoaded)
{
Load();
}
diff --git a/src/Wpf/Prism.Wpf/Modularity/ConfigurationModuleCatalog.Desktop.cs b/src/Wpf/Prism.Wpf/Modularity/ConfigurationModuleCatalog.Desktop.cs
index 0af53ef9..552f64de 100644
--- a/src/Wpf/Prism.Wpf/Modularity/ConfigurationModuleCatalog.Desktop.cs
+++ b/src/Wpf/Prism.Wpf/Modularity/ConfigurationModuleCatalog.Desktop.cs
@@ -1,9 +1,6 @@
-
-
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.IO;
using System.Linq;
using Prism.Properties;
@@ -20,7 +17,7 @@ namespace Prism.Modularity
///
public ConfigurationModuleCatalog()
{
- this.Store = new ConfigurationStore();
+ Store = new ConfigurationStore();
}
///
@@ -33,28 +30,17 @@ namespace Prism.Modularity
///
protected override void InnerLoad()
{
- if (this.Store == null)
+ if (Store == null)
{
throw new InvalidOperationException(Resources.ConfigurationStoreCannotBeNull);
}
- this.EnsureModulesDiscovered();
- }
-
- private static string GetFileAbsoluteUri(string filePath)
- {
- UriBuilder uriBuilder = new UriBuilder();
- uriBuilder.Host = String.Empty;
- uriBuilder.Scheme = Uri.UriSchemeFile;
- uriBuilder.Path = Path.GetFullPath(filePath);
- Uri fileUri = uriBuilder.Uri;
-
- return fileUri.ToString();
+ EnsureModulesDiscovered();
}
private void EnsureModulesDiscovered()
{
- ModulesConfigurationSection section = this.Store.RetrieveModuleConfigurationSection();
+ ModulesConfigurationSection section = Store.RetrieveModuleConfigurationSection();
if (section != null)
{
diff --git a/src/Wpf/Prism.Wpf/Modularity/ModuleCatalog.cs b/src/Wpf/Prism.Wpf/Modularity/ModuleCatalog.cs
index 00bfea64..e795dc97 100644
--- a/src/Wpf/Prism.Wpf/Modularity/ModuleCatalog.cs
+++ b/src/Wpf/Prism.Wpf/Modularity/ModuleCatalog.cs
@@ -72,5 +72,21 @@ namespace Prism.Modularity
return null;
}
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected string GetFileAbsoluteUri(string filePath)
+ {
+ UriBuilder uriBuilder = new UriBuilder();
+ uriBuilder.Host = String.Empty;
+ uriBuilder.Scheme = Uri.UriSchemeFile;
+ uriBuilder.Path = Path.GetFullPath(filePath);
+ Uri fileUri = uriBuilder.Uri;
+
+ return fileUri.ToString();
+ }
}
}
diff --git a/src/Wpf/Prism.Wpf/Modularity/ModuleInfoGroup.cs b/src/Wpf/Prism.Wpf/Modularity/ModuleInfoGroup.cs
index f6fdbf76..9f515d8f 100644
--- a/src/Wpf/Prism.Wpf/Modularity/ModuleInfoGroup.cs
+++ b/src/Wpf/Prism.Wpf/Modularity/ModuleInfoGroup.cs
@@ -17,7 +17,7 @@ namespace Prism.Modularity
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public class ModuleInfoGroup : IModuleInfoGroup
{
- private readonly Collection modules = new Collection();
+ private readonly Collection _modules = new Collection();
///
/// Gets or sets the for the whole group. Any classes that are
@@ -46,9 +46,16 @@ namespace Prism.Modularity
public void Add(IModuleInfo item)
{
ForwardValues(item);
- modules.Add(item);
+ _modules.Add(item);
}
+ internal void UpdateModulesRef()
+ {
+ foreach(var module in _modules)
+ {
+ module.Ref = Ref;
+ }
+ }
///
/// Forwards and properties from this
@@ -75,7 +82,7 @@ namespace Prism.Modularity
///
/// Removes all s from the .
///
- public void Clear() => modules.Clear();
+ public void Clear() => _modules.Clear();
///
/// Determines whether the contains a specific value.
@@ -84,7 +91,7 @@ namespace Prism.Modularity
///
/// true if is found in the ; otherwise, false.
///
- public bool Contains(IModuleInfo item) => modules.Contains(item);
+ public bool Contains(IModuleInfo item) => _modules.Contains(item);
///
/// Copies the elements of the to an , starting at a particular index.
@@ -106,7 +113,7 @@ namespace Prism.Modularity
///
public void CopyTo(IModuleInfo[] array, int arrayIndex)
{
- modules.CopyTo(array, arrayIndex);
+ _modules.CopyTo(array, arrayIndex);
}
///
@@ -116,7 +123,7 @@ namespace Prism.Modularity
///
/// The number of elements contained in the .
///
- public int Count => modules.Count;
+ public int Count => _modules.Count;
///
/// Gets a value indicating whether the is read-only.
@@ -133,7 +140,7 @@ namespace Prism.Modularity
///
/// true if was successfully removed from the ; otherwise, false. This method also returns false if is not found in the original .
///
- public bool Remove(IModuleInfo item) => modules.Remove(item);
+ public bool Remove(IModuleInfo item) => _modules.Remove(item);
///
/// Returns an enumerator that iterates through the collection.
@@ -141,7 +148,7 @@ namespace Prism.Modularity
///
/// A that can be used to iterate through the collection.
///
- public IEnumerator GetEnumerator() => modules.GetEnumerator();
+ public IEnumerator GetEnumerator() => _modules.GetEnumerator();
///
/// Returns an enumerator that iterates through a collection.
@@ -199,7 +206,7 @@ namespace Prism.Modularity
///
/// The index of if found in the list; otherwise, -1.
///
- public int IndexOf(object value) => modules.IndexOf((IModuleInfo)value);
+ public int IndexOf(object value) => _modules.IndexOf((IModuleInfo)value);
///
/// Inserts an item to the at the specified index.
@@ -227,7 +234,7 @@ namespace Prism.Modularity
if (!(value is IModuleInfo moduleInfo))
throw new ArgumentException(Resources.ValueMustBeOfTypeModuleInfo, nameof(value));
- modules.Insert(index, moduleInfo);
+ _modules.Insert(index, moduleInfo);
}
///
@@ -259,7 +266,7 @@ namespace Prism.Modularity
///
/// The is read-only.
///
- public void RemoveAt(int index) => modules.RemoveAt(index);
+ public void RemoveAt(int index) => _modules.RemoveAt(index);
///
/// Gets or sets the at the specified index.
@@ -293,7 +300,7 @@ namespace Prism.Modularity
/// The type of the source cannot be cast automatically to the type of the destination .
///
void ICollection.CopyTo(Array array, int index) =>
- ((ICollection)modules).CopyTo(array, index);
+ ((ICollection)_modules).CopyTo(array, index);
///
/// Gets a value indicating whether access to the is synchronized (thread safe).
@@ -301,7 +308,7 @@ namespace Prism.Modularity
///
/// true if access to the is synchronized (thread safe); otherwise, false.
///
- public bool IsSynchronized => ((ICollection)modules).IsSynchronized;
+ public bool IsSynchronized => ((ICollection)_modules).IsSynchronized;
///
/// Gets an object that can be used to synchronize access to the .
@@ -310,7 +317,7 @@ namespace Prism.Modularity
///
/// An object that can be used to synchronize access to the .
///
- public object SyncRoot => ((ICollection)modules).SyncRoot;
+ public object SyncRoot => ((ICollection)_modules).SyncRoot;
///
/// Determines the index of a specific item in the .
@@ -319,7 +326,7 @@ namespace Prism.Modularity
///
/// The index of if found in the list; otherwise, -1.
///
- public int IndexOf(IModuleInfo item) => modules.IndexOf(item);
+ public int IndexOf(IModuleInfo item) => _modules.IndexOf(item);
///
/// Inserts an item to the at the specified index.
@@ -329,7 +336,7 @@ namespace Prism.Modularity
///
/// is not a valid index in the .
///
- public void Insert(int index, IModuleInfo item) => modules.Insert(index, item);
+ public void Insert(int index, IModuleInfo item) => _modules.Insert(index, item);
///
/// Gets or sets the at the specified index.
@@ -337,8 +344,8 @@ namespace Prism.Modularity
/// The at the specified index
public IModuleInfo this[int index]
{
- get => modules[index];
- set => modules[index] = value;
+ get => _modules[index];
+ set => _modules[index] = value;
}
}
}
diff --git a/src/Wpf/Prism.Wpf/Modularity/XamlResourceCatalog.cs b/src/Wpf/Prism.Wpf/Modularity/XamlResourceCatalog.cs
new file mode 100644
index 00000000..675c6de4
--- /dev/null
+++ b/src/Wpf/Prism.Wpf/Modularity/XamlResourceCatalog.cs
@@ -0,0 +1,57 @@
+using System;
+
+namespace Prism.Modularity
+{
+ ///
+ /// A catalog built from a XAML file.
+ ///
+ public class XamlResourceCatalog : ModuleCatalog
+ {
+ private readonly Uri _resourceUri;
+
+ ///
+ /// Creates an instance of a XamlResourceCatalog.
+ ///
+ /// The name of the XAML file
+ public XamlResourceCatalog(string fileName)
+ : this(new Uri(fileName, UriKind.Relative))
+ {
+ }
+
+ ///
+ /// Creates an instance of a XamlResourceCatalog.
+ ///
+ /// The pack url of the XAML file resource
+ public XamlResourceCatalog(Uri resourceUri)
+ {
+ _resourceUri = resourceUri;
+ }
+
+ ///
+ /// Loads the catalog from the XAML file.
+ ///
+ protected override void InnerLoad()
+ {
+ var catalog = ModuleCatalog.CreateFromXaml(_resourceUri);
+
+ foreach(IModuleCatalogItem item in catalog.Items)
+ {
+ if (item is ModuleInfo mi)
+ {
+ if (!string.IsNullOrWhiteSpace(mi.Ref))
+ mi.Ref = GetFileAbsoluteUri(mi.Ref);
+ }
+ else if (item is ModuleInfoGroup mg)
+ {
+ if (!string.IsNullOrWhiteSpace(mg.Ref))
+ {
+ mg.Ref = GetFileAbsoluteUri(mg.Ref);
+ mg.UpdateModulesRef();
+ }
+ }
+
+ Items.Add(item);
+ }
+ }
+ }
+}