是.
Assembly commandAssembly = Assembly.Load("some/path")
var commands = new List<ICommand>();
foreach (Type type in commandAssembly.GetTypes())
{
if (type.GetInterface(typeof(ICommand).FullName) != null)
{
commands.Add((ICommand)Activator.CreateInstance(type));
}
}
Run Code Online (Sandbox Code Playgroud)
但是,您可能会遇到有关装配加载的一些限制.你不能只从任何地方加载程序集,否则你可以重新实现COM DLL地狱之类的东西.
| 归档时间: |
|
| 查看次数: |
1892 次 |
| 最近记录: |