JSRuntimeContextExtensions.Import<T> method (1 of 2)
Imports a module or module property from JavaScript and converts it to an interface.
C#
public static T Import<T>(this JSRuntimeContext runtimeContext, string? module, string? property,
bool esModule, JSMarshaller marshaller)
parameter | description |
---|---|
T | .NET type that the imported JS value will be marshalled to. |
module | Name of the module being imported, or null to import a global property. This is equivalent to the value provided to import or require() in JavaScript. Required if property is null. |
property | Name of a property on the module (or global), or null to import the module object. Required if module is null. |
marshaller | JS marshaller instance to use to convert the imported value to a .NET type. |
Return Value
The imported value, marshalled to the specified .NET type.
Exceptions
exception | condition |
---|---|
ArgumentNullException | Both and are null. |
See Also
- class JSMarshaller
- class JSRuntimeContextExtensions
- namespace Microsoft.JavaScript.NodeApi.DotNetHost
JSRuntimeContextExtensions.Import<T> method (2 of 2)
Imports a module or module property from JavaScript and converts it to an interface.
C#
public static T Import<T>(this NodejsEnvironment nodejs, string? module, string? property,
bool esModule, JSMarshaller marshaller)
parameter | description |
---|---|
T | .NET type that the imported JS value will be marshalled to. |
module | Name of the module being imported, or null to import a global property. This is equivalent to the value provided to import or require() in JavaScript. Required if property is null. |
property | Name of a property on the module (or global), or null to import the module object. Required if module is null. |
marshaller | JS marshaller instance to use to convert the imported value to a .NET type. |
Return Value
The imported value, marshalled to the specified .NET type.
Exceptions
exception | condition |
---|---|
ArgumentNullException | Both and are null. |
See Also
- class JSMarshaller
- class JSRuntimeContextExtensions
- namespace Microsoft.JavaScript.NodeApi.DotNetHost