[优化]优化代码规范
This commit is contained in:
parent
49114b711e
commit
99ee34b08f
@ -83,7 +83,7 @@ namespace 加载Dll
|
||||
|
||||
string pluginLocation = Path.GetFullPath(Path.Combine(root, 相对路径.Replace('\\', Path.DirectorySeparatorChar)));
|
||||
Console.WriteLine($"加载插件: {pluginLocation}");
|
||||
加载插件上下文 loadContext = new 加载插件上下文(pluginLocation);
|
||||
加载插件上下文 loadContext = new(pluginLocation);
|
||||
return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(pluginLocation)));
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ namespace 加载Dll
|
||||
{
|
||||
if (typeof(ICommand).IsAssignableFrom(type))
|
||||
{
|
||||
ICommand result = Activator.CreateInstance(type) as ICommand;
|
||||
ICommand? result = Activator.CreateInstance(type) as ICommand;
|
||||
if (result != null)
|
||||
{
|
||||
count++;
|
||||
|
@ -40,22 +40,6 @@ namespace 加载dll
|
||||
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
static Assembly LoadPlugin(string relativePath)
|
||||
{
|
||||
// Navigate up to the solution root
|
||||
string root = Path.GetFullPath(Path.Combine(
|
||||
Path.GetDirectoryName(
|
||||
Path.GetDirectoryName(
|
||||
Path.GetDirectoryName(
|
||||
Path.GetDirectoryName(
|
||||
Path.GetDirectoryName(typeof(Program).Assembly.Location)))))));
|
||||
|
||||
string pluginLocation = Path.GetFullPath(Path.Combine(root, relativePath.Replace('\\', Path.DirectorySeparatorChar)));
|
||||
Console.WriteLine($"Loading commands from: {pluginLocation}");
|
||||
加载插件上下文 loadContext = new 加载插件上下文(pluginLocation);
|
||||
return loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(pluginLocation)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user