Skip to content

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)
parameterdescription
T.NET type that the imported JS value will be marshalled to.
moduleName 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.
propertyName of a property on the module (or global), or null to import the module object. Required if module is null.
marshallerJS 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

exceptioncondition
ArgumentNullExceptionBoth and are null.

See Also


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)
parameterdescription
T.NET type that the imported JS value will be marshalled to.
moduleName 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.
propertyName of a property on the module (or global), or null to import the module object. Required if module is null.
marshallerJS 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

exceptioncondition
ArgumentNullExceptionBoth and are null.

See Also

Released under the MIT license