forked from Taritsyn/JavaScriptEngineSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultNodeJsService.cs
More file actions
117 lines (93 loc) · 4.67 KB
/
DefaultNodeJsService.cs
File metadata and controls
117 lines (93 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Jering.Javascript.NodeJS;
namespace JavaScriptEngineSwitcher.Node
{
/// <summary>
/// Default Node JS service
/// </summary>
/// <remarks>
/// Wrapper around the <see cref="StaticNodeJSService"/> class.
/// </remarks>
public sealed class DefaultNodeJsService : INodeJSService
{
/// <summary>
/// Instance of default Node JS service
/// </summary>
private static readonly DefaultNodeJsService _instance = new DefaultNodeJsService();
/// <summary>
/// Gets a instance of default Node JS service
/// </summary>
public static INodeJSService Instance
{
get { return _instance; }
}
/// <summary>
/// Private constructor for implementation Singleton pattern
/// </summary>
private DefaultNodeJsService()
{ }
#region INodeJSService implementation
public Task<T> InvokeFromFileAsync<T>(string modulePath, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromFileAsync<T>(modulePath, exportName, args, cancellationToken);
}
public Task InvokeFromFileAsync(string modulePath, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromFileAsync(modulePath, exportName, args, cancellationToken);
}
public Task<T> InvokeFromStringAsync<T>(string moduleString, string cacheIdentifier = null, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromStringAsync<T>(moduleString, cacheIdentifier, exportName, args, cancellationToken);
}
public Task InvokeFromStringAsync(string moduleString, string cacheIdentifier = null, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromStringAsync(moduleString, cacheIdentifier, exportName, args, cancellationToken);
}
public Task<T> InvokeFromStringAsync<T>(Func<string> moduleFactory, string cacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromStringAsync<T>(moduleFactory, cacheIdentifier, exportName, args, cancellationToken);
}
public Task InvokeFromStringAsync(Func<string> moduleFactory, string cacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromStringAsync(moduleFactory, cacheIdentifier, exportName, args, cancellationToken);
}
public Task<T> InvokeFromStreamAsync<T>(Stream moduleStream, string cacheIdentifier = null, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromStreamAsync<T>(moduleStream, cacheIdentifier, exportName, args, cancellationToken);
}
public Task InvokeFromStreamAsync(Stream moduleStream, string cacheIdentifier = null, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromStreamAsync(moduleStream, cacheIdentifier, exportName, args, cancellationToken);
}
public Task<T> InvokeFromStreamAsync<T>(Func<Stream> moduleFactory, string cacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromStreamAsync<T>(moduleFactory, cacheIdentifier, exportName, args, cancellationToken);
}
public Task InvokeFromStreamAsync(Func<Stream> moduleFactory, string cacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.InvokeFromStreamAsync(moduleFactory, cacheIdentifier, exportName, args, cancellationToken);
}
public Task<(bool, T)> TryInvokeFromCacheAsync<T>(string moduleCacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.TryInvokeFromCacheAsync<T>(moduleCacheIdentifier, exportName, args, cancellationToken);
}
public Task<bool> TryInvokeFromCacheAsync(string moduleCacheIdentifier, string exportName = null, object[] args = null, CancellationToken cancellationToken = default)
{
return StaticNodeJSService.TryInvokeFromCacheAsync(moduleCacheIdentifier, exportName, args, cancellationToken);
}
public ValueTask MoveToNewProcessAsync()
{
throw new NotSupportedException();
}
#region IDisposable implementation
public void Dispose()
{
throw new NotSupportedException();
}
#endregion
#endregion
}
}