-
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.
* Allow multiple assemblies * Add tests * Add configuration helpers * Generate diagrams Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
6cefad4
commit c3a06c1
Showing
11 changed files
with
134 additions
and
20 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
```mermaid | ||
classDiagram | ||
DependencyTree --> DependencyTreeConfig | ||
DependencyTreeConfig --> Assembly | ||
DependencyTreeConfig --> IConfiguration | ||
``` |
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
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
<img src="http://yuml.me/diagram/scruffy/class/[DependencyTree]->[DependencyTreeConfig], [DependencyTreeConfig]->[Assembly], [DependencyTreeConfig]->[IConfiguration]" /> | ||
<img src="http://yuml.me/diagram/scruffy/class/[DependencyTree]->[DependencyTreeConfig]" /> |
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
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
41 changes: 41 additions & 0 deletions
41
src/Lively/Configuration/DependencyTreeConfigExtensions.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,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Reflection; | ||
using Lively.Resolvers; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Lively | ||
{ | ||
public static class DependencyTreeConfigExtensions | ||
{ | ||
public static IConfiguration EmptyConfiguration() | ||
{ | ||
var cfgBuilder = new ConfigurationBuilder(); | ||
return cfgBuilder.Build(); | ||
} | ||
|
||
// public static IConfiguration ConfigurationFromJsonFile(string assemblyConfigLocation) | ||
// { | ||
// var cfgBuilder = new ConfigurationBuilder(); | ||
// cfgBuilder.AddJsonFile(assemblyConfigLocation, optional: false, reloadOnChange: false); | ||
// return cfgBuilder.Build(); | ||
// } | ||
|
||
public static IEnumerable<Assembly> GetAllAssembliesInDirectory( | ||
string path, | ||
Func<string, bool> patternMatchingFn = null) | ||
{ | ||
patternMatchingFn ??= _ => true; | ||
foreach (var file in Directory.GetFiles(path)) | ||
{ | ||
var split = file.Split("."); | ||
var fileEnding = split[split.Length - 1]; | ||
if (fileEnding == "dll" && patternMatchingFn(file)) | ||
{ | ||
yield return Assembly.LoadFrom(file); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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
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 |
---|---|---|
@@ -1,14 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using Microsoft.Extensions.Configuration; | ||
|
||
namespace Lively.Resolvers | ||
{ | ||
public class StartupInterfaceResolverConfig | ||
{ | ||
public Assembly Assembly { get; set; } | ||
public IReadOnlyList<Assembly> Assemblies { get; set; } | ||
public IConfiguration Configuration { get; set; } | ||
public HashSet<string> SkipTypes { get; set; } | ||
public string StartupName { get; set; } = "Startup"; | ||
|
||
public IEnumerable<Type> AssemblyTypes => Assemblies.SelectMany(a => a.GetTypes()); | ||
} | ||
} |