Skip to content

Commit

Permalink
Remove CurrentAssemblyDirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Oct 14, 2017
1 parent 968291f commit 11a7450
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added
- Ninject for .NET Core can now load extensions automatically
- The executing assembly's directory is considered as one of the base directories

## [3.3.1] - 2017-10-05

Expand Down
17 changes: 10 additions & 7 deletions src/Ninject/Modules/ModuleLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace Ninject.Modules
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Ninject.Components;
using Ninject.Infrastructure;

Expand All @@ -21,8 +20,6 @@ namespace Ninject.Modules
/// </summary>
public class ModuleLoader : NinjectComponent, IModuleLoader
{
private static readonly string CurrentAssemblyDirectory = Path.GetDirectoryName(new Uri(typeof(ModuleLoader).Assembly.CodeBase).LocalPath);

/// <summary>
/// Initializes a new instance of the <see cref="ModuleLoader"/> class.
/// </summary>
Expand Down Expand Up @@ -56,8 +53,15 @@ public void LoadModules(IEnumerable<string> patterns)
var extension = fileGroup.Key;
var plugin = plugins.Where(p => p.SupportedExtensions.Contains(extension)).FirstOrDefault();

Console.WriteLine(fileGroup.Key);

if (plugin != null)
{
foreach (var f in fileGroup)
{
Console.WriteLine(f);
}

plugin.LoadModules(fileGroup);
}
}
Expand All @@ -79,14 +83,13 @@ private static IEnumerable<string> NormalizePaths(string path)

private static IEnumerable<string> GetBaseDirectories()
{
var baseDirectory = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
var searchPath = AppDomain.CurrentDomain.RelativeSearchPath;

return (string.IsNullOrEmpty(searchPath)
return string.IsNullOrEmpty(searchPath)
? new[] { baseDirectory }
: searchPath.Split(new[] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries)
.Select(path => Path.Combine(baseDirectory, path)))
.Concat(new[] { CurrentAssemblyDirectory }).Distinct();
.Select(path => Path.Combine(baseDirectory, path));
}
}
}

0 comments on commit 11a7450

Please sign in to comment.