THYClr

Overview

The THYClr is a class that responsible for interaction with CLR. This class is used internally to initialize and manage .NET CLR. Please note that process can initialize CLR only once, so if you need to access to CLR pleases use global variable named HYClr which is located in the uHYCLRWrappers.pas. Also please note that this variable is initialized when first .NET plugin is loaded, so you need to perform a check before use it.

Use Case

Usualy you won't need to use this class direclty, however in some situation it may be useful, for example:

uses
  uHYCLRWrappers;

if HYClr <> nil then begin
  HYClr.DefaultAppDomain.LoadAssembly("My.Assembly");
end;

Location

  • Unit: Hydra.Managed.Wrappers.pas
  • Ancestry: THYClr

 

constructor Create

Creates an instance of the object with specified parameters.

constructor Create(const FileName: string)

Parameters:

  • FileName: File name of an assembly. This assembly will be used to detect CLR version.

Clr

Reference to an instance of Microsoft hosting interface.

property Clr: ICorRuntimeHost read write

CreateDomain

Creates an AppDomain with specified parameters.

function CreateDomain(const Name: UnicodeString; Setup: IAppDomainSetup): _AppDomain

Parameters:

  • Name: Name of the new AppDomain.
  • Setup: Refenrence to a parameters for the new AppDomain.

CreateDomainSetup

Creates a new instance of IAppDomainSetup

function CreateDomainSetup: IAppDomainSetup

DefaultAppDomain

Reference to a default AppDomain. Please note that this property can be nil.

property DefaultAppDomain: THYClrAppDomain read write

GC

Reference to an instance of garbage collector.

property GC: THYGC read write

GetDefaultDomain

function GetDefaultDomain: _AppDomain

InitializeDefaultAppDomain

Creates a default AppDomain or returns an existing one.

function InitializeDefaultAppDomain(const BasePath: UnicodeString): THYClrAppDomain

Parameters:

  • BasePath: Path to a base AppDomain directory. This is the directory where the assembly manager looking for assemblies.

UnloadDomain

Unloads a specified AppDomain.

procedure UnloadDomain(Domain: _AppDomain)

Parameters:

  • Domain: Domain that needs to be unloaded.

 

Clr

Reference to an instance of Microsoft hosting interface.

property Clr: ICorRuntimeHost read write

DefaultAppDomain

Reference to a default AppDomain. Please note that this property can be nil.

property DefaultAppDomain: THYClrAppDomain read write

GC

Reference to an instance of garbage collector.

property GC: THYGC read write

 

constructor Create

Creates an instance of the object with specified parameters.

constructor Create(const FileName: string)

Parameters:

  • FileName: File name of an assembly. This assembly will be used to detect CLR version.

CreateDomain

Creates an AppDomain with specified parameters.

function CreateDomain(const Name: UnicodeString; Setup: IAppDomainSetup): _AppDomain

Parameters:

  • Name: Name of the new AppDomain.
  • Setup: Refenrence to a parameters for the new AppDomain.

CreateDomainSetup

Creates a new instance of IAppDomainSetup

function CreateDomainSetup: IAppDomainSetup

GetDefaultDomain

function GetDefaultDomain: _AppDomain

InitializeDefaultAppDomain

Creates a default AppDomain or returns an existing one.

function InitializeDefaultAppDomain(const BasePath: UnicodeString): THYClrAppDomain

Parameters:

  • BasePath: Path to a base AppDomain directory. This is the directory where the assembly manager looking for assemblies.

UnloadDomain

Unloads a specified AppDomain.

procedure UnloadDomain(Domain: _AppDomain)

Parameters:

  • Domain: Domain that needs to be unloaded.