use-extensionpoints-lib
Use the #ExtensionPoints library
When developing with a DLL, the definition of extension points can be described very simply by using the NextDesign.ExtensionPoints library.
- You can create extension points for Next Design extensions in code.
- Can be separated by command and event class.
- There is a base class for extensions and it can be implemented simply.
Installation method
Get the following DLL with the NuGet package. Select your project's Dependencies from the Visual Studio Solution Explorer and run Manage NuGet Packages from the context menu.
Make sure the package source is nuget.org
, type NextDesign
on the Reference tab and search for it. The package for NextDesign.Desktop.ExtensionPoints
will be displayed, so install it.
You can also install it by going to the project directory on the command line and running the following command:
C:\Projects\MyExtension> NuGet Install NextDesign.Desktop.ExtensionPoints
Definition of extension points
Manifest definition
- It will be very simple as follows.
{
"name": "SampleExtension",
"main": "SampleExtension.dll",
"lifecycle": "application"
}
Implementation of extensions
You can create a manifest in code.
using NextDesign.Desktop.ExtensionPoints;
namespace SampleExtension
{
///<summary>
///Extension entry point
///</summary>
public class SampleExtensionEntryPoint: ExtensionBase
{
#region Activate/Deactivate
///<summary>
///This is the process at the time of activation.
///</summary>
protected override void OnActivate ()
{
//Ribbon
ExtensionPoints.Ribbon.AddTab ("SampleExPoint"). AddGroup ("Test1"). AddLargeButton <HelloCommand> ("Hello");
//event
ExtensionPoints.Events.Application.RegisterOnAfterStart <ApplicationAfterStart> ();
}
///<summary>
///This is the process at the time of deactivation.
///</summary>
protected override void OnDeactivate ()
{
}
#endregion
}
}
Command processing is also a separate class, which improves maintainability.
using NextDesign.Desktop;
using NextDesign.Desktop.ExtensionPoints;
namespace SampleExtension.Commands
{
///<summary>
///Implementation of Hello command.
///</summary>
public class HelloCommand: CommandHandlerBase
{
///<summary>
///Command execution
///</summary>
///<param name = "c"> </param>
///<param name = "p"> </param>
protected override void OnExecute (ICommandContext c, ICommandParams p)
{
if (CurrentProject! = null)
{
Output.WriteLine (ExtensionName, $ "ProjectName: {CurrentProject.Name}");
} else else
{
Output.WriteLine (ExtensionName, $ "Project is not opened");
}
//activate
App.Window.IsInformationPaneVisible = true;
App.Window.CurrentOutputCategory = ExtensionName;
App.Window.ActiveInfoWindow = "Output";
}
}
}
Events are also unique classes, and parameters are also typed, so implementation is simple.
using NextDesign.Desktop;
using NextDesign.Desktop.ExtensionPoints;
namespace SampleExtension.Events
{
///<summary>
///Application execution event
///</summary>
internal class ApplicationAfterStart: ApplicationAfterStartEventHandlerBase
{
///<summary>
///Event handler processing.
///</summary>
///<param name = "c"> </param>
///<param name = "p"> </param>
protected override void OnHandle (IEventContext c, AfterStartEventParams p)
{
//Implement event handling.
Output.WriteLine (ExtensionName, $ "Events: ApplicationAfterStart Event. Version: {App.Version}");
}
}
}
reference
See ExtensionPoints for details.