Table of Contents

CadPluginLoader

from OpenCAD2D.Plugins import CadPluginLoader

class CadPluginLoader(System.Object) ยท CadPluginLoader in the .NET reference

Loads the assemblies of a plugin for CadPluginManager, and unloads them, as the runtime allows: on .NET 8 each plugin into a collectible load context of its own, which unloading frees; on .NET Framework into the one AppDomain, from which nothing is ever unloaded. The presenter's controls give the loader of the runtime they run on (OpenCAD2D.Wpf.Plugins.CadPluginAssemblyLoader); this library, built for netstandard2.0, has no load contexts to give one of its own.

Properties and fields

CanCompile

.NET

@property
def CanCompile(self) -> bool

Gets whether CadPluginLoader.Compile builds plugins given as C# source: true in the app on .NET 8, false here and on .NET Framework.

CanUnload

.NET

@property
def CanUnload(self) -> bool

Gets whether CadPluginLoader.Unload frees a plugin's code, so that a new build of it can be loaded while the presenter runs.

Methods

Compile

.NET

def Compile(self, name: str, projectPath: str) -> CadPluginBuild

Compiles a plugin given as a folder with a .csproj into an assembly and its PDB, or takes them from the cache where the project and its sources are unchanged since they were last compiled. This loader cannot (CadPluginLoader.CanCompile is false).

Load

.NET

def Load(
    self,
    name: str,
    files: System.Collections.Generic.IReadOnlyList[str],
    probeFolder: str,
) -> System.Collections.Generic.IReadOnlyList[System.Reflection.Assembly]

Loads a plugin's assemblies from the copies of its files the manager made (its shadow copy). An assembly the presenter has itself, as OpenCAD2D, is not loaded a second time: the plugin is given the presenter's.

Unload

.NET

def Unload(self, assemblies: System.Collections.Generic.IReadOnlyList[System.Reflection.Assembly]) -> None

Unloads the assemblies CadPluginLoader.Load gave, where CadPluginLoader.CanUnload says it can; does nothing where it cannot.