[优化]优化代码规范

This commit is contained in:
优雅的母鸡 2023-02-28 13:05:11 +08:00
parent 49114b711e
commit 99ee34b08f
2 changed files with 2 additions and 18 deletions

View File

@ -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++;

View File

@ -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)));
}
}
}