public NodeInvocationService( INodeJSService nodeJsService, ReactConfiguration configuration, IEmbeddedResourcesService embeddedResourcesService, IOptions <NodeJSProcessOptions> nodeJsProcessOptions, IServiceScopeFactory serviceScopeFactory) { _nodeJsService = nodeJsService; _embeddedResourcesService = embeddedResourcesService; using (IServiceScope scope = serviceScopeFactory.CreateScope()) { IServiceProvider serviceProvider = scope.ServiceProvider; IHostingEnvironment hostingEnvironment = serviceProvider.GetService <IHostingEnvironment>(); var requireFiles = configuration.ScriptFilesWithoutTransform .Select(relativePath => { if (relativePath.StartsWith(nodeJsProcessOptions.Value.ProjectPath)) { return(relativePath); } relativePath = relativePath.TrimStart('~').TrimStart('/'); return(Path.GetFullPath(Path.Combine(hostingEnvironment?.WebRootPath ?? nodeJsProcessOptions.Value.ProjectPath, relativePath))); }); //TODO: do this in configure nodeJsProcessOptions.Value.EnvironmentVariables.Add("NODEREACT_REQUIREFILES", string.Join(',', requireFiles)); } }
private HttpNodeJSService CreateHttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeHostOptionsAccessor = null, IHttpContentFactory httpContentFactory = null, IEmbeddedResourcesService embeddedResourcesService = null, IFileWatcherFactory fileWatcherFactory = null, IMonitorService monitorService = null, ITaskService taskService = null, IHttpClientService httpClientService = null, IJsonService jsonService = null, INodeJSProcessFactory nodeProcessFactory = null, ILogger <HttpNodeJSService> logger = null) { if (logger == null) { Mock <ILogger <HttpNodeJSService> > mockLogger = _mockRepository.Create <ILogger <HttpNodeJSService> >(); logger = mockLogger.Object; } return(new HttpNodeJSService(outOfProcessNodeHostOptionsAccessor, httpContentFactory, embeddedResourcesService, fileWatcherFactory, monitorService, taskService, httpClientService, jsonService, nodeProcessFactory, logger)); }
public DummyNodeJSService(INodeJSProcessFactory nodeProcessFactory, ILogger <DummyNodeJSService> nodeServiceLogger, IOptions <OutOfProcessNodeJSServiceOptions> optionsAccessor, IEmbeddedResourcesService embeddedResourcesService) : base(nodeProcessFactory, nodeServiceLogger, optionsAccessor, embeddedResourcesService, typeof(HttpNodeJSService).GetTypeInfo().Assembly, "HttpServer.js") // TODO somehow get HttpServer into test assembly? { }
/// <summary> /// Creates a <see cref="HttpNodeJSService"/>. /// </summary> /// <param name="outOfProcessNodeJSServiceOptionsAccessor"></param> /// <param name="httpContentFactory"></param> /// <param name="embeddedResourcesService"></param> /// <param name="fileWatcherFactory"></param> /// <param name="monitorService"></param> /// <param name="taskService"></param> /// <param name="httpClientService"></param> /// <param name="jsonService"></param> /// <param name="nodeJSProcessFactory"></param> /// <param name="logger"></param> public HttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeJSServiceOptionsAccessor, IHttpContentFactory httpContentFactory, IEmbeddedResourcesService embeddedResourcesService, IFileWatcherFactory fileWatcherFactory, IMonitorService monitorService, ITaskService taskService, IHttpClientService httpClientService, IJsonService jsonService, INodeJSProcessFactory nodeJSProcessFactory, ILogger <HttpNodeJSService> logger) : base(nodeJSProcessFactory, logger, outOfProcessNodeJSServiceOptionsAccessor, embeddedResourcesService, fileWatcherFactory, monitorService, taskService, typeof(HttpNodeJSService).GetTypeInfo().Assembly, SERVER_SCRIPT_NAME) { _httpClientService = httpClientService; _jsonService = jsonService; _logger = logger; _httpContentFactory = httpContentFactory; }
public ExposedHttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeHostOptionsAccessor, IHttpContentFactory httpContentFactory, IEmbeddedResourcesService embeddedResourcesService, IHttpClientService httpClientService, IJsonService jsonService, INodeJSProcessFactory nodeProcessFactory, ILoggerFactory loggerFactory) : base(outOfProcessNodeHostOptionsAccessor, httpContentFactory, embeddedResourcesService, httpClientService, jsonService, nodeProcessFactory, loggerFactory) { }
/// <summary> /// Creates an<see cref="OutOfProcessNodeJSService"/> instance. /// </summary> /// <param name="nodeProcessFactory"></param> /// <param name="logger"></param> /// <param name="optionsAccessor"></param> /// <param name="embeddedResourcesService"></param> /// <param name="serverScriptAssembly"></param> /// <param name="serverScriptName"></param> protected OutOfProcessNodeJSService(INodeJSProcessFactory nodeProcessFactory, ILogger logger, IOptions <OutOfProcessNodeJSServiceOptions> optionsAccessor, IEmbeddedResourcesService embeddedResourcesService, Assembly serverScriptAssembly, string serverScriptName) { _nodeProcessFactory = nodeProcessFactory; Logger = logger; _options = optionsAccessor?.Value ?? new OutOfProcessNodeJSServiceOptions(); _embeddedResourcesService = embeddedResourcesService; _serverScriptName = serverScriptName; _serverScriptAssembly = serverScriptAssembly; }
private ExposedHttpNodeJSService CreateHttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeHostOptionsAccessor = null, IHttpContentFactory httpContentFactory = null, IEmbeddedResourcesService embeddedResourcesService = null, IHttpClientService httpClientService = null, IJsonService jsonService = null, INodeJSProcessFactory nodeProcessFactory = null, ILoggerFactory loggerFactory = null) { return(new ExposedHttpNodeJSService(outOfProcessNodeHostOptionsAccessor, httpContentFactory, embeddedResourcesService, httpClientService, jsonService, nodeProcessFactory, loggerFactory)); }
/// <summary> /// Creates an <see cref="OutOfProcessNodeJSService"/> instance. /// </summary> /// <param name="nodeProcessFactory"></param> /// <param name="logger"></param> /// <param name="optionsAccessor"></param> /// <param name="embeddedResourcesService"></param> /// <param name="fileWatcherFactory"></param> /// <param name="monitorService"></param> /// <param name="taskService"></param> /// <param name="serverScriptAssembly"></param> /// <param name="serverScriptName"></param> protected OutOfProcessNodeJSService(INodeJSProcessFactory nodeProcessFactory, ILogger logger, IOptions <OutOfProcessNodeJSServiceOptions> optionsAccessor, IEmbeddedResourcesService embeddedResourcesService, IFileWatcherFactory fileWatcherFactory, IMonitorService monitorService, ITaskService taskService, Assembly serverScriptAssembly, string serverScriptName) : this(nodeProcessFactory, logger, optionsAccessor, embeddedResourcesService, serverScriptAssembly, serverScriptName) { _fileWatcherFactory = fileWatcherFactory; _monitorService = monitorService; _taskService = taskService; (_trackInvokeTasks, _trackedInvokeTasks, _invokeTaskCreationCountdown) = InitializeFileWatching(); }
/// <summary> /// Creates an<see cref="OutOfProcessNodeJSService"/> instance. /// </summary> /// <param name="nodeProcessFactory"></param> /// <param name="logger"></param> /// <param name="optionsAccessor"></param> /// <param name="embeddedResourcesService"></param> /// <param name="serverScriptAssembly"></param> /// <param name="serverScriptName"></param> protected OutOfProcessNodeJSService(INodeJSProcessFactory nodeProcessFactory, ILogger logger, IOptions <OutOfProcessNodeJSServiceOptions> optionsAccessor, IEmbeddedResourcesService embeddedResourcesService, Assembly serverScriptAssembly, string serverScriptName) { _nodeProcessFactory = nodeProcessFactory; _options = optionsAccessor?.Value ?? new OutOfProcessNodeJSServiceOptions(); _embeddedResourcesService = embeddedResourcesService; _serverScriptName = serverScriptName; _serverScriptAssembly = serverScriptAssembly; Logger = logger; _debugLoggingEnabled = Logger.IsEnabled(LogLevel.Debug); _warningLoggingEnabled = Logger.IsEnabled(LogLevel.Warning); }
/// <summary> /// Creates a <see cref="HttpNodeJSService"/> instance. /// </summary> /// <param name="outOfProcessNodeJSServiceOptionsAccessor"></param> /// <param name="httpContentFactory"></param> /// <param name="embeddedResourcesService"></param> /// <param name="httpClientService"></param> /// <param name="jsonService"></param> /// <param name="nodeJSProcessFactory"></param> /// <param name="loggerFactory"></param> public HttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeJSServiceOptionsAccessor, IHttpContentFactory httpContentFactory, IEmbeddedResourcesService embeddedResourcesService, IHttpClientService httpClientService, IJsonService jsonService, INodeJSProcessFactory nodeJSProcessFactory, ILoggerFactory loggerFactory) : base(nodeJSProcessFactory, loggerFactory.CreateLogger(typeof(HttpNodeJSService)), outOfProcessNodeJSServiceOptionsAccessor, embeddedResourcesService, typeof(HttpNodeJSService).GetTypeInfo().Assembly, SERVER_SCRIPT_NAME) { _httpClientService = httpClientService; _jsonService = jsonService; _httpContentFactory = httpContentFactory; }
private ExposedHttpNodeJSService CreateHttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeHostOptionsAccessor = null, IHttpContentFactory httpContentFactory = null, IEmbeddedResourcesService embeddedResourcesService = null, IFileWatcherFactory fileWatcherFactory = null, IMonitorService monitorService = null, ITaskService taskService = null, IHttpClientService httpClientService = null, IJsonService jsonService = null, INodeJSProcessFactory nodeProcessFactory = null, ILogger <HttpNodeJSService> logger = null, StringBuilder loggerStringBuilder = null) { if (logger == null) { // Log output if (loggerStringBuilder != null) { var services = new ServiceCollection(); services.AddLogging(lb => { lb. AddProvider(new StringBuilderProvider(loggerStringBuilder)). AddFilter <StringBuilderProvider>((LogLevel LogLevel) => LogLevel >= LogLevel.Trace); }); logger = services.BuildServiceProvider().GetRequiredService <ILogger <HttpNodeJSService> >(); } else { Mock <ILogger <HttpNodeJSService> > mockLogger = _mockRepository.Create <ILogger <HttpNodeJSService> >(); logger = mockLogger.Object; } } return(new ExposedHttpNodeJSService(outOfProcessNodeHostOptionsAccessor, httpContentFactory, embeddedResourcesService, fileWatcherFactory, monitorService, taskService, httpClientService, jsonService, nodeProcessFactory, logger)); }
/// <summary> /// Creates an <see cref="HttpNodeJSService"/>. /// </summary> /// <param name="outOfProcessNodeJSServiceOptionsAccessor">The <see cref="OutOfProcessNodeJSServiceOptions"/> accessor.</param> /// <param name="httpNodeJSServiceOptionsAccessor">The <see cref="HttpNodeJSServiceOptions"/> accessor.</param> /// <param name="httpContentFactory">The factory for creating <see cref="HttpContent"/>s.</param> /// <param name="embeddedResourcesService">The service for retrieving NodeJS Http server scripts.</param> /// <param name="fileWatcherFactory">The service for creating <see cref="IFileWatcher"/>s</param> /// <param name="monitorService">The service for lock-based thread synchronization.</param> /// <param name="taskService">The service for utilizing tasks.</param> /// <param name="httpClientService">The service for utilizing <see cref="HttpClient"/>.</param> /// <param name="jsonService">The service for JSON serialization and deserialization.</param> /// <param name="nodeJSProcessFactory">The factory for creating <see cref="NodeJSProcess"/>s.</param> /// <param name="logger">The logger for the instance.</param> public HttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeJSServiceOptionsAccessor, IOptions <HttpNodeJSServiceOptions> httpNodeJSServiceOptionsAccessor, IHttpContentFactory httpContentFactory, IEmbeddedResourcesService embeddedResourcesService, IFileWatcherFactory fileWatcherFactory, IMonitorService monitorService, ITaskService taskService, IHttpClientService httpClientService, IJsonService jsonService, INodeJSProcessFactory nodeJSProcessFactory, ILogger <HttpNodeJSService> logger) : base(nodeJSProcessFactory, logger, outOfProcessNodeJSServiceOptionsAccessor, embeddedResourcesService, fileWatcherFactory, monitorService, taskService, typeof(HttpNodeJSService).GetTypeInfo().Assembly, #if NETCOREAPP3_1 || NET5_0_OR_GREATER httpNodeJSServiceOptionsAccessor.Value.Version == HttpVersion.Version20 ? HTTP20_SERVER_SCRIPT_NAME : HTTP11_SERVER_SCRIPT_NAME)
public ExposedHttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeJSServiceOptionsAccessor, IHttpContentFactory httpContentFactory, IEmbeddedResourcesService embeddedResourcesService, IFileWatcherFactory fileWatcherFactory, IMonitorService monitorService, ITaskService taskService, IHttpClientService httpClientService, IJsonService jsonService, INodeJSProcessFactory nodeJSProcessFactory, ILogger <HttpNodeJSService> logger) : base(outOfProcessNodeJSServiceOptionsAccessor, httpContentFactory, embeddedResourcesService, fileWatcherFactory, monitorService, taskService, httpClientService, jsonService, nodeJSProcessFactory, logger) { }
// DO NOT DELETE - keep for backward compatibility. /// <summary> /// <para>Creates an <see cref="OutOfProcessNodeJSService"/> instance.</para> /// <para>If this constructor is used, file watching is disabled.</para> /// </summary> /// <param name="nodeProcessFactory"></param> /// <param name="logger"></param> /// <param name="optionsAccessor"></param> /// <param name="embeddedResourcesService"></param> /// <param name="serverScriptAssembly"></param> /// <param name="serverScriptName"></param> protected OutOfProcessNodeJSService(INodeJSProcessFactory nodeProcessFactory, ILogger logger, IOptions <OutOfProcessNodeJSServiceOptions> optionsAccessor, IEmbeddedResourcesService embeddedResourcesService, Assembly serverScriptAssembly, string serverScriptName) { _nodeProcessFactory = nodeProcessFactory; _options = optionsAccessor?.Value ?? new OutOfProcessNodeJSServiceOptions(); _embeddedResourcesService = embeddedResourcesService; _serverScriptName = serverScriptName; _serverScriptAssembly = serverScriptAssembly; Logger = logger; _debugLoggingEnabled = Logger.IsEnabled(LogLevel.Debug); _warningLoggingEnabled = Logger.IsEnabled(LogLevel.Warning); _infoLoggingEnabled = Logger.IsEnabled(LogLevel.Information); _numRetries = _options.NumRetries; _numProcessRetries = _options.NumProcessRetries; _numConnectionRetries = _options.NumConnectionRetries; _timeoutMS = _options.TimeoutMS; }
private ExposedHttpNodeJSService CreateHttpNodeJSService(IOptions <OutOfProcessNodeJSServiceOptions> outOfProcessNodeHostOptionsAccessor = null, IHttpContentFactory httpContentFactory = null, IEmbeddedResourcesService embeddedResourcesService = null, IHttpClientService httpClientService = null, IJsonService jsonService = null, INodeJSProcessFactory nodeProcessFactory = null, ILoggerFactory loggerFactory = null) { if (loggerFactory == null) { Mock <ILogger> mockLogger = _mockRepository.Create <ILogger>(); Mock <ILoggerFactory> mockLoggerFactory = _mockRepository.Create <ILoggerFactory>(); mockLoggerFactory.Setup(l => l.CreateLogger(typeof(HttpNodeJSService).FullName)).Returns(mockLogger.Object); loggerFactory = mockLoggerFactory.Object; } return(new ExposedHttpNodeJSService(outOfProcessNodeHostOptionsAccessor, httpContentFactory, embeddedResourcesService, httpClientService, jsonService, nodeProcessFactory, loggerFactory)); }
private Mock <PrismService> CreateMockPrismService(INodeJSService nodeJSService = null, IEmbeddedResourcesService embeddedResourcesService = null) { return(_mockRepository.Create <PrismService>(nodeJSService ?? _mockRepository.Create <INodeJSService>().Object, embeddedResourcesService ?? _mockRepository.Create <IEmbeddedResourcesService>().Object)); }
/// <summary> /// Creates a <see cref="HighlightJSService"/> instance. /// </summary> /// <param name="nodeJSService">The service used to invoke HighlightJS in NodeJS.</param> /// <param name="embeddedResourcesService">The service used to retrieve embedded resources.</param> public HighlightJSService(INodeJSService nodeJSService, IEmbeddedResourcesService embeddedResourcesService) { _nodeJSService = nodeJSService ?? throw new ArgumentNullException(nameof(nodeJSService)); _embeddedResourcesService = embeddedResourcesService ?? throw new ArgumentNullException(nameof(embeddedResourcesService)); }