mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
54 lines
3.8 KiB
C#
54 lines
3.8 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Microsoft.AspNetCore.NodeServices
|
|
{
|
|
/// <summary>
|
|
/// Represents the ability to invoke code in a Node.js environment. Although the underlying Node.js instance
|
|
/// might change over time (e.g., the process might be restarted), the <see cref="INodeServices"/> instance
|
|
/// will remain constant.
|
|
/// </summary>
|
|
public interface INodeServices : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// Asynchronously invokes code in the Node.js instance.
|
|
/// </summary>
|
|
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
|
|
/// <param name="moduleName">The path to the Node.js module (i.e., JavaScript file) relative to your project root whose default CommonJS export is the function to be invoked.</param>
|
|
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
|
|
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
|
|
Task<T> InvokeAsync<T>(string moduleName, params object[] args);
|
|
|
|
/// <summary>
|
|
/// Asynchronously invokes code in the Node.js instance.
|
|
/// </summary>
|
|
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
|
|
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel the invocation.</param>
|
|
/// <param name="moduleName">The path to the Node.js module (i.e., JavaScript file) relative to your project root whose default CommonJS export is the function to be invoked.</param>
|
|
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
|
|
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
|
|
Task<T> InvokeAsync<T>(CancellationToken cancellationToken, string moduleName, params object[] args);
|
|
|
|
/// <summary>
|
|
/// Asynchronously invokes code in the Node.js instance.
|
|
/// </summary>
|
|
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
|
|
/// <param name="moduleName">The path to the Node.js module (i.e., JavaScript file) relative to your project root that contains the code to be invoked.</param>
|
|
/// <param name="exportedFunctionName">Specifies the CommonJS export to be invoked.</param>
|
|
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
|
|
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
|
|
Task<T> InvokeExportAsync<T>(string moduleName, string exportedFunctionName, params object[] args);
|
|
|
|
/// <summary>
|
|
/// Asynchronously invokes code in the Node.js instance.
|
|
/// </summary>
|
|
/// <typeparam name="T">The JSON-serializable data type that the Node.js code will asynchronously return.</typeparam>
|
|
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel the invocation.</param>
|
|
/// <param name="moduleName">The path to the Node.js module (i.e., JavaScript file) relative to your project root that contains the code to be invoked.</param>
|
|
/// <param name="exportedFunctionName">Specifies the CommonJS export to be invoked.</param>
|
|
/// <param name="args">Any sequence of JSON-serializable arguments to be passed to the Node.js function.</param>
|
|
/// <returns>A <see cref="Task{TResult}"/> representing the completion of the RPC call.</returns>
|
|
Task<T> InvokeExportAsync<T>(CancellationToken cancellationToken, string moduleName, string exportedFunctionName, params object[] args);
|
|
}
|
|
} |