-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebAppTypeFinder.cs
70 lines (56 loc) · 1.98 KB
/
WebAppTypeFinder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Reflection;
namespace NetPro.TypeFinder
{
/// <summary>
/// Web程序域内 循环类型查找(在bin目录中)
/// </summary>
public class WebAppTypeFinder : AppDomainTypeFinder
{
#region Fields
private bool _ensureBinFolderAssembliesLoaded = true;
private bool _binFolderAssembliesLoaded;
#endregion
#region Ctor
public WebAppTypeFinder(INetProFileProvider fileProvider = null) : base(fileProvider)
{
}
#endregion
#region Properties
/// <summary>
/// Gets or sets whether assemblies in the bin folder of the web application should be specifically checked for being loaded on application load. This is need in situations where plugins need to be loaded in the AppDomain after the application been reloaded.
/// </summary>
public bool EnsureBinFolderAssembliesLoaded
{
get { return _ensureBinFolderAssembliesLoaded; }
set { _ensureBinFolderAssembliesLoaded = value; }
}
#endregion
#region Methods
/// <summary>
/// Gets a physical disk path of \Bin directory
/// </summary>
/// <returns>The physical path. E.g. "c:\inetpub\wwwroot\bin"</returns>
public virtual string GetBinDirectory()
{
return AppContext.BaseDirectory;
}
/// <summary>
/// Get assemblies
/// </summary>
/// <returns>Result</returns>
public override IList<Assembly> GetAssemblies()
{
if (EnsureBinFolderAssembliesLoaded && !_binFolderAssembliesLoaded)
{
_binFolderAssembliesLoaded = true;
var binPath = GetBinDirectory();
//binPath = _webHelper.MapPath("~/bin");
LoadMatchingAssemblies(binPath);
}
return base.GetAssemblies();
}
#endregion
}
}