Class CadPlugin
A command plugin made from its assemblies: the methods marked CadCommandAttribute as commands, the properties marked CadSettingAttribute as settings, found by reflection, and added to the command lines of the open drawings with AddTo(CadCommandRegistry).
public sealed class CadPlugin
- Inheritance
-
CadPlugin
- Inherited Members
Remarks
Every run of one of its commands is one undo step, whatever it edits through the document, and a run that throws has every change of it taken back, the error written on the command line with the plugin's name and logged as a Warn by the command line. A plugin edits only through the public members of CadCommandContext and CadDocument, so the owners' gate (EditGate) refuses what it refuses for any command. CadPluginManager loads and unloads plugins from files; a plugin's own tests can make one from its assembly with FromAssemblies(string, IEnumerable<Assembly>, string) and run its commands in a CadCommandSession.
Properties
- ApiVersion
Gets the version of the plugin API this build of the presenter has: 1.5. Version 1.1 added what ICadPluginApplication and CadPluginHost give the window; 1.2 added the slide-outs and dialog launchers of CadRibbonPanel and the macro buttons of CadRibbonButton; 1.3 added the CadEditor of Editor and Editor; 1.4 added the CadDocuments of Documents and Documents; 1.5 added Check(Action<CadEditor>). A plugin that uses the first states
[assembly: CadPluginApi("1.1")], one that uses the second"1.2", one that uses the third"1.3", one that uses the fourth"1.4", one that uses the fifth"1.5".
- Commands
Gets the commands, in ordinal order of their names.
- Host
Gets what the plugin's application classes added to the window in Initialize(CadPluginHost); never null, and empty for a plugin that has none.
- IsEnabled
Gets whether its commands still run; false once it is unloaded, after which a run of one that was going on fails.
- Name
Gets the plugin's name: the name of its manifest, or of its assembly.
- Problems
Gets what was left out while the plugin was read, a line each: a method marked as a command that cannot be one, a name taken twice.
- RequiredApiVersion
Gets the least version of the plugin API its assemblies state they need; 1.0 where none states one.
- Settings
Gets the settings, by the full name of the class that declares each, then in the order the class declares them.
- Version
Gets the plugin's version: its manifest's, or its first assembly's informational or assembly version.
Methods
- AddTo(CadCommandRegistry)
Adds the commands to a registry, and their aliases to its shortcuts. A command whose name is already a command or an alias of the registry is left out, and so is an alias already taken; each is said in the lines returned.
- FromAssemblies(string, IEnumerable<Assembly>, string)
Makes a plugin from its assemblies, already loaded. A plugin that states a newer version of the plugin API than ApiVersion, or that has neither a command nor a class that implements ICadPluginApplication, is refused; a method marked as a command that cannot be one is left out and said in Problems. Each application class is made and initialised, in ordinal order of its full name; Folder is the folder of the first assembly.
- RemoveFrom(CadCommandRegistry)
Takes the commands and aliases AddTo(CadCommandRegistry) added out of a registry again; a command since replaced there is left.