forked from PrismLibrary/Prism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working on .NET Core 3 module catalog
- Loading branch information
1 parent
ff9641a
commit 805eca4
Showing
2 changed files
with
80 additions
and
20 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
Source/Wpf/Prism.Wpf/Modularity/DirectoryModuleCatalog.Core.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#if NETCOREAPP3_0 | ||
|
||
using Prism.Properties; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Prism.Modularity | ||
{ | ||
public class DirectoryModuleCatalog : ModuleCatalog | ||
{ | ||
/// <summary> | ||
/// Directory containing modules to search for. | ||
/// </summary> | ||
public string ModulePath { get; set; } | ||
|
||
/// <summary> | ||
/// Drives the main logic of building the child domain and searching for the assemblies. | ||
/// </summary> | ||
protected override void InnerLoad() | ||
{ | ||
if (string.IsNullOrEmpty(this.ModulePath)) | ||
throw new InvalidOperationException(Resources.ModulePathCannotBeNullOrEmpty); | ||
|
||
if (!Directory.Exists(this.ModulePath)) | ||
throw new InvalidOperationException( | ||
string.Format(CultureInfo.CurrentCulture, Resources.DirectoryNotFound, this.ModulePath)); | ||
|
||
AppDomain appDomain = AppDomain.CurrentDomain; | ||
|
||
try | ||
{ | ||
List<string> loadedAssemblies = new List<string>(); | ||
|
||
var assemblies = from Assembly assembly in AppDomain.CurrentDomain.GetAssemblies() | ||
where !(assembly is System.Reflection.Emit.AssemblyBuilder) | ||
&& assembly.GetType().FullName != "System.Reflection.Emit.InternalAssemblyBuilder" | ||
&& !String.IsNullOrEmpty(assembly.Location) | ||
select assembly.Location; | ||
|
||
loadedAssemblies.AddRange(assemblies); | ||
|
||
//Type loaderType = typeof(InnerModuleInfoLoader); | ||
|
||
//if (loaderType.Assembly != null) | ||
//{ | ||
// var loader = (InnerModuleInfoLoader)appDomain.CreateInstanceFrom(loaderType.Assembly.Location, loaderType.FullName).Unwrap(); | ||
// loader.LoadAssemblies(loadedAssemblies); | ||
// this.Items.AddRange(loader.GetModuleInfos(this.ModulePath)); | ||
//} | ||
} | ||
catch | ||
{ | ||
//do nothing | ||
} | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters