NFinal.Common.Plugin 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NFinal.Common.Plugin --version 1.0.1
NuGet\Install-Package NFinal.Common.Plugin -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NFinal.Common.Plugin" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NFinal.Common.Plugin --version 1.0.1
#r "nuget: NFinal.Common.Plugin, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NFinal.Common.Plugin as a Cake Addin
#addin nuget:?package=NFinal.Common.Plugin&version=1.0.1

// Install NFinal.Common.Plugin as a Cake Tool
#tool nuget:?package=NFinal.Common.Plugin&version=1.0.1

插件极简使用,快速扩展你的项目

  • 1分钟快速掌握对插件的加载,运行以及卸载操作.
  • 插件之间可通过自定义公共目录的方式共享程序集

极简使用方法

1.创建插件项目,自定义入口类

```csharp
public class FastService
{
    public void Run(string name)
    {
        Console.WriteLine($"Hi!{name}");
    }
}
```

2.安装nuget包NFinal.Common.Plugin.调用插件程序集

```csharp
static void Main(string[] args)
{
    //安装并使用
    PluginWrapper pluginWrapper =
        new PluginWrapper(new PluginInfo()
        {
            AssemblyName = "插件程序集名",
            ClassName = "插件类全名",
            Name = "插件名",
            PluginFolder = @"插件程序集目录"
        });
	//不返回实例,该实例对象由pluginWrapper控制生命周期
	//可以保证插件始终能够正常卸载
    pluginWrapper.New();
    pluginWrapper.Execute("Run","Li Lei");
    //卸载
    pluginWrapper.UnInstall();
}
```

一般使用方法:

1.自定义插件接口或父类

```csharp
public interface BaseService
{
    void Run();
}
```

2.创建插件项目并实现该接口或父类

```csharp
public class SimpleService : BaseService
{
    public void Run(string name)
    {
        Console.WriteLine($"Hello {name}!");
    }
}
```

3.创建主项目用于加载插件

```csharp
static void Main(string[] args)
{
    //安装并使用
    PluginWrapper<BaseService> pluginWrapper =
        new PluginWrapper<BaseService>(new PluginInfo()
        {
            AssemblyName = "插件程序集名",
            ClassName = "插件类全名",
            Name = "插件名",
            CommonAssemblyFolder="插件共享文件目录",
            PluginFolder = @"插件程序集目录"
        });
	//接口方式,可调用返回对象,该实例不能赋值给其它变量.
	//也不能作为参数传给其它函数,否则可能会导致插件卸载失败
    var simpleService = pluginWrapper.New();
    simpleService.Run("Han Mei Mei");
    //卸载
    pluginWrapper.UnInstall();
}
```

注意事项

  1. 在主项目中引用的程序集,在插件目录中必须删除,否则会出现找不到程序集的错误.
  2. 插件项目和主项目必须同为.net core项目且版本一致.
  3. System.Drawing.Common声明兼容.net standard标准,
    实际上只能在windows下运行.插件若包含该程序集,
    应当把插件项目发布为win64或win32平台.
  4. 还有很多不规范的第三方nuget包,虽然写的是兼容所有平台.
    但实际上只能在某一平台运行,最终导致在linux或其它平台下运行失败,
    抛出Not support this platform异常.实际上这不是插件的问题.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 425 11/29/2020
1.0.1 370 11/11/2020
1.0.0 312 11/9/2020

解决卸载问题,修复加载失败问题.并提高代码可读性.