ComponentFunction Class
A function of the component model: a function exported by a component instance (ComponentFunction.Call), or a function of the host (ComponentFunction.FromCallback, ComponentFunction.FromAsyncCallback) given to the imports of a component.
public sealed class ComponentFunctionProperties
| Name | Description |
|---|---|
| Type | Gets the type of the function: the type of an exported function, or the type given to a function of the host (null when it takes the type of the import). |
Type
WasmComponent.csGets the type of the function: the type of an exported function, or the type given to a function of the host (null when it takes the type of the import).
public ComponentFunctionType? Type { get; }Property value
Methods
| Name | Description |
|---|---|
| Call(ComponentValue[]) | Calls an exported function: the arguments are converted to the memory of the component, and the result from it. The call runs the store until it returns, including the other asynchronous calls of the store and the operations of the host they wait for. |
| FromAsyncCallback(ComponentHostAsyncCallback, ComponentFunctionType?) | Creates an asynchronous function of the host: a component that calls it asynchronously continues while it runs. Without type, the function has the type of the import it is given to. |
| FromCallback(ComponentHostCallback, ComponentFunctionType?) | Creates a function of the host. Without type, the function has the type of the import it is given to: the callback receives it in ComponentCallContext.Type. |
Call(ComponentValue[])
WasmComponent.csCalls an exported function: the arguments are converted to the memory of the component, and the result from it. The call runs the store until it returns, including the other asynchronous calls of the store and the operations of the host they wait for.
public ComponentValue? Call(params ComponentValue[] arguments)Parameters
argumentsComponentValue[]- The arguments, one per parameter.
Returns
ComponentValue? The result, or null for a function without result.
Exceptions
InvalidOperationException- The function is a function of the host.
WasmTrapException- The component trapped.
FromAsyncCallback(ComponentHostAsyncCallback, ComponentFunctionType?)
WasmComponent.csCreates an asynchronous function of the host: a component that calls it asynchronously continues while it runs. Without type, the function has the type of the import it is given to.
public static ComponentFunction FromAsyncCallback(ComponentHostAsyncCallback callback, ComponentFunctionType? type = null)Parameters
callbackComponentHostAsyncCallback- The steps of the function.
typeComponentFunctionType?- The type of the function, which must be the type of the import, or null.
Returns
FromCallback(ComponentHostCallback, ComponentFunctionType?)
WasmComponent.csCreates a function of the host. Without type, the function has the type of the import it is given to: the callback receives it in ComponentCallContext.Type.
public static ComponentFunction FromCallback(ComponentHostCallback callback, ComponentFunctionType? type = null)Parameters
callbackComponentHostCallback- The steps of the function.
typeComponentFunctionType?- The type of the function, which must be the type of the import, or null.