Class UnmanagedLibrary
Represents management and access to an unmanaged library. An unmanaged library can be loaded and unloaded dynamically. The library then searches for a list of exported functions to create managed delegates for, allowing callers to access the library. Each OS platform has its own implementation to determine how to load unmanaged libraries.
Inherited Members
Namespace: SharpAssimp.Unmanaged
Assembly: SharpAssimp.dll
Syntax
public abstract class UnmanagedLibrary
Constructors
| Edit this page View SourceUnmanagedLibrary(string, Type[])
Constructs a new UnmanagedLibrary.
Declaration
protected UnmanagedLibrary(string defaultName, Type[] unmanagedFunctionDelegateTypes)
Parameters
Type | Name | Description |
---|---|---|
string | defaultName | Default name (NOT path) of the unmanaged library. |
Type[] | unmanagedFunctionDelegateTypes | Delegate types to instantiate and load. |
Properties
| Edit this page View SourceDefaultLibraryName
Gets the default name of the unmanaged library DLL. This is dependent based on the platform extension and name prefix. Additional names can be set in the UnmanagedLibraryResolver (e.g. to load versioned DLLs)
Declaration
public string DefaultLibraryName { get; }
Property Value
Type | Description |
---|---|
string |
Is64Bit
Queries if the OS is 64-bit, if false then it is 32-bit.
Declaration
public static bool Is64Bit { get; }
Property Value
Type | Description |
---|---|
bool |
IsLibraryLoaded
Queries if the unmanaged library has been loaded or not.
Declaration
public bool IsLibraryLoaded { get; }
Property Value
Type | Description |
---|---|
bool |
LibraryPath
Gets the path to the unmanaged library DLL that is currently loaded.
Declaration
public string LibraryPath { get; }
Property Value
Type | Description |
---|---|
string |
Resolver
Gets the resolver used to find the unmanaged library DLL when loading.
Declaration
public UnmanagedLibraryResolver Resolver { get; }
Property Value
Type | Description |
---|---|
UnmanagedLibraryResolver |
ThrowOnLoadFailure
Gets or sets whether an AssimpException is thrown if the unmanaged DLL fails to load for whatever reason. By default this is true.
Declaration
public bool ThrowOnLoadFailure { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
| Edit this page View SourceFreeLibrary()
Frees the unmanaged library that is currently loaded.
Declaration
public bool FreeLibrary()
Returns
Type | Description |
---|---|
bool | True if the library was sucessfully freed. |
GetFunction<T>(string)
Gets a delegate based on the unmanaged function name.
Declaration
public T GetFunction<T>(string funcName) where T : class
Parameters
Type | Name | Description |
---|---|---|
string | funcName | Name of unmanaged function that is exported by the library. |
Returns
Type | Description |
---|---|
T | The delegate, or null if not found. |
Type Parameters
Name | Description |
---|---|
T | Type of delegate. |
GetPlatform()
Gets an enum representing the current OS that is application is executing on.
Declaration
public static Platform GetPlatform()
Returns
Type | Description |
---|---|
Platform | Platform enumeration. |
LoadIfNotLoaded()
If library is not explicitly loaded by user, call this when trying to call an unmanaged function to load the unmanaged library from the default path. This function is thread safe.
Declaration
protected void LoadIfNotLoaded()
LoadLibrary()
Loads the unmanaged library using the UnmanagedLibraryResolver.
Declaration
public bool LoadLibrary()
Returns
Type | Description |
---|---|
bool | True if the library was found and successfully loaded. |
LoadLibrary(string)
Loads the unmanaged library using the supplied path.
Declaration
public bool LoadLibrary(string libPath)
Parameters
Type | Name | Description |
---|---|---|
string | libPath | Path to the unmanaged DLL. |
Returns
Type | Description |
---|---|
bool | True if the library was found and successfully loaded. |
LoadLibrary(string, string)
Loads the unmanaged library using the supplied 32 and 64 bit paths, the one chosen is based on the OS bitness.
Declaration
public bool LoadLibrary(string lib32Path, string lib64Path)
Parameters
Type | Name | Description |
---|---|---|
string | lib32Path | Path to the 32-bit DLL |
string | lib64Path | Path to the 64-bit DLL |
Returns
Type | Description |
---|---|
bool | True if the library was found and successfully loaded. |
OnLibraryFreed()
Called when the library is freed.
Declaration
protected virtual void OnLibraryFreed()
OnLibraryLoaded()
Called when the library is loaded.
Declaration
protected virtual void OnLibraryLoaded()
Events
| Edit this page View SourceLibraryFreed
Occurs when the unmanaged library is freed.
Declaration
public event EventHandler? LibraryFreed
Event Type
Type | Description |
---|---|
EventHandler |
LibraryLoaded
Occurs when the unmanaged library is loaded.
Declaration
public event EventHandler? LibraryLoaded
Event Type
Type | Description |
---|---|
EventHandler |