Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ examples/AspNetCore6/PluginCoreAdmin/
examples/AspNetCore6/Plugins/
examples/AspNetCore6/Plugins_wwwroot/

examples/AspNetCore7/App_Data/
examples/AspNetCore7/PluginCoreAdmin/
examples/AspNetCore7/Plugins/
examples/AspNetCore7/Plugins_wwwroot/


# PluginCore
src/PluginCore/package-lock.json

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[README.md](README.md)
18 changes: 2 additions & 16 deletions PluginCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCore", "src\PluginCor
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{F7651716-CAC1-42B3-9D95-2C7C835F17CB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore3_1", "examples\AspNetCore3_1\AspNetCore3_1.csproj", "{A28AFD35-06C0-4CEE-BB40-45B080DF5A7F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore5", "examples\AspNetCore5\AspNetCore5.csproj", "{5B797C83-F308-4455-A599-E0CC771AE059}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCore.IPlugins", "src\PluginCore.IPlugins\PluginCore.IPlugins.csproj", "{9675260E-82D8-40CF-B681-898FE0DA839F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "plugins", "plugins", "{D8255E7B-33DD-40B1-95A7-2B4F45BFE0F4}"
Expand All @@ -29,7 +25,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestTimeJobPlugin", "plugin
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DemoModePlugin", "plugins\DemoModePlugin\DemoModePlugin.csproj", "{386ED921-054C-4BB3-A5FF-39011FDD574B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore6", "examples\AspNetCore6\AspNetCore6.csproj", "{601F78E5-D68D-4B79-BE56-A3F731E37511}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore7", "examples\AspNetCore7\AspNetCore7.csproj", "{601F78E5-D68D-4B79-BE56-A3F731E37511}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HexoPlugin", "plugins\HexoPlugin\HexoPlugin.csproj", "{93F2ABF9-64E2-4093-B23A-F22FF1981394}"
EndProject
Expand All @@ -42,7 +38,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCore.AspNetCore", "sr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PluginCore.IPlugins.AspNetCore", "src\PluginCore.IPlugins.AspNetCore\PluginCore.IPlugins.AspNetCore.csproj", "{003457E8-D13F-47C0-B07F-0CE5E6AD66F0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore6WithNatasha", "examples\AspNetCore6WithNatasha\AspNetCore6WithNatasha.csproj", "{73810C6C-4049-4382-8A96-D7B67B71CDDC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore7WithNatasha", "examples\AspNetCore7WithNatasha\AspNetCore7WithNatasha.csproj", "{73810C6C-4049-4382-8A96-D7B67B71CDDC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -54,14 +50,6 @@ Global
{8F29F5E4-F306-42E1-BA5D-E0ACAF0A7ED1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F29F5E4-F306-42E1-BA5D-E0ACAF0A7ED1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F29F5E4-F306-42E1-BA5D-E0ACAF0A7ED1}.Release|Any CPU.Build.0 = Release|Any CPU
{A28AFD35-06C0-4CEE-BB40-45B080DF5A7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A28AFD35-06C0-4CEE-BB40-45B080DF5A7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A28AFD35-06C0-4CEE-BB40-45B080DF5A7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A28AFD35-06C0-4CEE-BB40-45B080DF5A7F}.Release|Any CPU.Build.0 = Release|Any CPU
{5B797C83-F308-4455-A599-E0CC771AE059}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B797C83-F308-4455-A599-E0CC771AE059}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B797C83-F308-4455-A599-E0CC771AE059}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B797C83-F308-4455-A599-E0CC771AE059}.Release|Any CPU.Build.0 = Release|Any CPU
{9675260E-82D8-40CF-B681-898FE0DA839F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9675260E-82D8-40CF-B681-898FE0DA839F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9675260E-82D8-40CF-B681-898FE0DA839F}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -116,8 +104,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8F29F5E4-F306-42E1-BA5D-E0ACAF0A7ED1} = {F4038C30-CEF3-406D-AAC6-1158BE61617D}
{A28AFD35-06C0-4CEE-BB40-45B080DF5A7F} = {F7651716-CAC1-42B3-9D95-2C7C835F17CB}
{5B797C83-F308-4455-A599-E0CC771AE059} = {F7651716-CAC1-42B3-9D95-2C7C835F17CB}
{9675260E-82D8-40CF-B681-898FE0DA839F} = {F4038C30-CEF3-406D-AAC6-1158BE61617D}
{C000158C-1690-41E8-8D44-41AC01A8E81B} = {D8255E7B-33DD-40B1-95A7-2B4F45BFE0F4}
{42648CA6-5BC7-4C5C-8A23-1F384D18309F} = {F4038C30-CEF3-406D-AAC6-1158BE61617D}
Expand Down
48 changes: 0 additions & 48 deletions examples/AspNetCore6WithNatasha/Natasha/NatashaPluginContext.cs

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions examples/AspNetCore6WithNatasha/WeatherForecast.cs

This file was deleted.

1 change: 1 addition & 0 deletions examples/AspNetCore7/App_Data/PluginCore.Config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Admin":{"UserName":"admin","Password":"ABC12345"},"FrontendMode":"LocalEmbedded","RemoteFrontend":"https://cdn.jsdelivr.net/gh/yiyungent/[email protected]/dist-cdn","PluginWidgetDebug":false}
1 change: 1 addition & 0 deletions examples/AspNetCore7/App_Data/plugin.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"EnabledPlugins":["HelloWorldPlugin"]}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>11</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<!-- 方便开发debug,与发布到nuget -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using Microsoft.AspNetCore.Mvc;

namespace AspNetCore6.Controllers
namespace AspNetCore7.Controllers
{
[ApiController]
[Route("[controller]")]
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



// ���� PluginCore ��������ռ�
// ���� PluginCore ��������ռ�
using PluginCore.AspNetCore.Extensions;


Expand All @@ -20,7 +20,7 @@
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// 1. ��� PluginCore
// 1. ��� PluginCore
builder.Services.AddPluginCore();

var app = builder.Build();
Expand All @@ -32,9 +32,9 @@
app.UseSwaggerUI();
}

app.UseHttpsRedirection();
//app.UseHttpsRedirection();

// 2. ʹ�� PluginCore
// 2. ʹ�� PluginCore
app.UsePluginCore();

//app.UseAuthorization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



namespace AspNetCore6
namespace AspNetCore7
{
public class WeatherForecast
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>11</LangVersion>
<RootNamespace>AspNetCore6WithNatasha</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DotNetCore.Natasha.CSharp" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="DotNetCore.Natasha.CSharp" Version="5.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<!-- 方便开发debug,与发布到nuget -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using Microsoft.AspNetCore.Mvc;

namespace AspNetCore6WithNatasha.Controllers
namespace AspNetCore7WithNatasha.Controllers
{
[ApiController]
[Route("[controller]")]
Expand Down Expand Up @@ -39,4 +39,4 @@ public IEnumerable<WeatherForecast> Get()
.ToArray();
}
}
}
}
54 changes: 54 additions & 0 deletions examples/AspNetCore7WithNatasha/Natasha/NatashaPluginContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Reflection;
using PluginCore;
using PluginCore.Interfaces;
using PluginCore.IPlugins.Infrastructure;

namespace AspNetCore7WithNatasha.Natasha;

public class NatashaPluginContext : IPluginContext
{

public NatashaReferenceDomain Domain
{
get; set;
}

public NatashaPluginContext(string pluginId)
{
this.Domain = DomainManagement.Create(pluginId);
// 插件的主dll, 不包括插件项目引用的dll
string pluginMainDllFilePath = Path.Combine(PluginPathProvider.PluginsRootPath(), pluginId, $"{pluginId}.dll");
this.Domain.LoadPluginWithAllDependency(path: pluginMainDllFilePath);
}

public string PluginId
{
get;
}

public IEnumerable<Assembly> Assemblies
{
get
{
return this.Domain.Assemblies;
}
}

public Assembly LoadFromAssemblyName(AssemblyName assemblyName)
{
var ass = this.Domain.LoadFromAssemblyName(assemblyName);

return ass;
}

public Assembly LoadFromStream(Stream assembly)
{
throw new NotImplementedException();
}

public void Unload()
{
this.Domain.Unload();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using PluginCore.Interfaces;

namespace AspNetCore7WithNatasha.Natasha;

public class NatashaPluginContextPack : IPluginContextPack
{
public IPluginContext Pack(string pluginId)
{
var context = new NatashaPluginContext(pluginId);

return context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



// ���� PluginCore ��������ռ�
// ���� PluginCore ��������ռ�
using PluginCore.AspNetCore.Extensions;
using PluginCore.Interfaces;

Expand All @@ -20,8 +20,8 @@
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// 1. ��� PluginCore
builder.Services.AddTransient<IPluginContextPack, AspNetCore6WithNatasha.Natasha.NatashaPluginContextPack>();
// 1. ��� PluginCore
builder.Services.AddTransient<IPluginContextPack, AspNetCore7WithNatasha.Natasha.NatashaPluginContextPack>();
builder.Services.AddPluginCore();

var app = builder.Build();
Expand All @@ -35,7 +35,7 @@

app.UseHttpsRedirection();

// 2. ʹ�� PluginCore
// 2. ʹ�� PluginCore
app.UsePluginCore();

//app.UseAuthorization();
Expand Down
Loading