refactor: apply default vs transform to xproj

refactor(spa-services): clean code

refactor(node-services): clean code, extract classes nto separate files

refactor(angular-services): prime cache cleanup
This commit is contained in:
Andrei Tserakhau
2016-05-23 11:28:42 +03:00
parent 2c35945562
commit 95cba7f5dd
32 changed files with 621 additions and 448 deletions

View File

@@ -1,42 +1,34 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.NodeServices;
using Newtonsoft.Json.Linq;
namespace Microsoft.AspNetCore.SpaServices.Prerendering
{
public static class Prerenderer
{
private static Lazy<StringAsTempFile> nodeScript;
private static readonly Lazy<StringAsTempFile> NodeScript;
static Prerenderer() {
nodeScript = new Lazy<StringAsTempFile>(() => {
static Prerenderer()
{
NodeScript = new Lazy<StringAsTempFile>(() =>
{
var script = EmbeddedResourceReader.Read(typeof(Prerenderer), "/Content/Node/prerenderer.js");
return new StringAsTempFile(script); // Will be cleaned up on process exit
});
}
public static async Task<RenderToStringResult> RenderToString(string applicationBasePath, INodeServices nodeServices, JavaScriptModuleExport bootModule, string requestAbsoluteUrl, string requestPathAndQuery) {
return await nodeServices.InvokeExport<RenderToStringResult>(nodeScript.Value.FileName, "renderToString",
public static async Task<RenderToStringResult> RenderToString(
string applicationBasePath,
INodeServices nodeServices,
JavaScriptModuleExport bootModule,
string requestAbsoluteUrl,
string requestPathAndQuery)
=> await nodeServices.InvokeExport<RenderToStringResult>(
NodeScript.Value.FileName,
"renderToString",
applicationBasePath,
bootModule,
requestAbsoluteUrl,
requestPathAndQuery);
}
}
public class JavaScriptModuleExport {
public string moduleName { get; private set; }
public string exportName { get; set; }
public string webpackConfig { get; set; }
public JavaScriptModuleExport(string moduleName) {
this.moduleName = moduleName;
}
}
public class RenderToStringResult {
public string Html;
public JObject Globals;
}
}
}