Added plugin events
This commit is contained in:
@@ -80,6 +80,8 @@ builder.Services.AddHopFrame(options => {
|
||||
options.AddCustomView("Counter", "/counter")
|
||||
.SetDescription("A custom view")
|
||||
.SetPolicy("counter.view");
|
||||
|
||||
options.AddPlugin<TestPlugin>();
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
26
testing/HopFrame.Testing/TestPlugin.cs
Normal file
26
testing/HopFrame.Testing/TestPlugin.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using HopFrame.Core.Config;
|
||||
using HopFrame.Testing.Models;
|
||||
using HopFrame.Web.Plugins;
|
||||
using HopFrame.Web.Plugins.Annotations;
|
||||
using HopFrame.Web.Plugins.Events;
|
||||
|
||||
namespace HopFrame.Testing;
|
||||
|
||||
public class TestPlugin : HopFramePlugin {
|
||||
|
||||
[PluginConfigurator]
|
||||
public static void OnConfiguring(HopFrameConfigurator configurator) {
|
||||
Console.WriteLine("Configurator invoked!");
|
||||
configurator.GetDbContext<DatabaseContext>()!
|
||||
.Table<User>()
|
||||
.Property(u => u.Email)
|
||||
.SetDisplayName("Modified by Plugin!");
|
||||
}
|
||||
|
||||
[EventHandler]
|
||||
public void OnDelete(DeleteEntryEvent e) {
|
||||
Console.WriteLine("Event called!");
|
||||
e.SetCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user