diff --git a/samples/misc/LatencyTest/Program.cs b/samples/misc/LatencyTest/Program.cs index 8654e2c..855402b 100755 --- a/samples/misc/LatencyTest/Program.cs +++ b/samples/misc/LatencyTest/Program.cs @@ -8,11 +8,11 @@ namespace ConsoleApplication { // This project is a micro-benchmark for .NET->Node RPC via NodeServices. It doesn't reflect // real-world usage patterns (you're not likely to make hundreds of sequential calls like this), - // but is a starting point for comparing the overhead of different hosting models and transports. + // but is a starting point for comparing the overhead of different hosting models and transports. public class Program { public static void Main(string[] args) { - using (var nodeServices = CreateNodeServices(NodeHostingModel.Http)) { + using (var nodeServices = CreateNodeServices(Configuration.DefaultNodeHostingModel)) { MeasureLatency(nodeServices).Wait(); } } @@ -21,7 +21,7 @@ namespace ConsoleApplication // Ensure the connection is open, so we can measure per-request timings below var response = await nodeServices.Invoke("latencyTest", "C#"); Console.WriteLine(response); - + // Now perform a series of requests, capturing the time taken const int requestCount = 100; var watch = Stopwatch.StartNew(); diff --git a/src/Microsoft.AspNetCore.NodeServices/Configuration.cs b/src/Microsoft.AspNetCore.NodeServices/Configuration.cs index 1a0e4ed..9e983a0 100644 --- a/src/Microsoft.AspNetCore.NodeServices/Configuration.cs +++ b/src/Microsoft.AspNetCore.NodeServices/Configuration.cs @@ -6,11 +6,12 @@ namespace Microsoft.AspNetCore.NodeServices { public static class Configuration { - private static readonly string[] DefaultWatchFileExtensions = {".js", ".jsx", ".ts", ".tsx", ".json", ".html"}; + public const NodeHostingModel DefaultNodeHostingModel = NodeHostingModel.Http; + private static readonly string[] DefaultWatchFileExtensions = {".js", ".jsx", ".ts", ".tsx", ".json", ".html"}; private static readonly NodeServicesOptions DefaultOptions = new NodeServicesOptions { - HostingModel = NodeHostingModel.Http, + HostingModel = DefaultNodeHostingModel, WatchFileExtensions = DefaultWatchFileExtensions }; diff --git a/src/Microsoft.AspNetCore.NodeServices/NodeServicesOptions.cs b/src/Microsoft.AspNetCore.NodeServices/NodeServicesOptions.cs index 7452c5f..dccd85d 100644 --- a/src/Microsoft.AspNetCore.NodeServices/NodeServicesOptions.cs +++ b/src/Microsoft.AspNetCore.NodeServices/NodeServicesOptions.cs @@ -4,7 +4,7 @@ namespace Microsoft.AspNetCore.NodeServices { public NodeServicesOptions() { - HostingModel = NodeHostingModel.Http; + HostingModel = Configuration.DefaultNodeHostingModel; } public NodeHostingModel HostingModel { get; set; } diff --git a/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs b/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs index ea95821..6e36481 100644 --- a/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs +++ b/src/Microsoft.AspNetCore.SpaServices/Prerendering/PrerenderTagHelper.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.SpaServices.Prerendering { _nodeServices = _fallbackNodeServices = Configuration.CreateNodeServices(new NodeServicesOptions { - HostingModel = NodeHostingModel.Http, + HostingModel = Configuration.DefaultNodeHostingModel, ProjectPath = _applicationBasePath }); } diff --git a/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs b/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs index 7c59721..8c3dbd2 100644 --- a/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs +++ b/src/Microsoft.AspNetCore.SpaServices/Webpack/WebpackDevMiddleware.cs @@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Builder var hostEnv = (IHostingEnvironment)appBuilder.ApplicationServices.GetService(typeof(IHostingEnvironment)); var nodeServices = Configuration.CreateNodeServices(new NodeServicesOptions { - HostingModel = NodeHostingModel.Http, + HostingModel = Configuration.DefaultNodeHostingModel, ProjectPath = hostEnv.ContentRootPath, WatchFileExtensions = new string[] { } // Don't watch anything });