diff --git a/Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs b/Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs index 31e4602..d920a17 100644 --- a/Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs +++ b/Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs @@ -1,7 +1,7 @@ +using System; using System.Threading.Tasks; using Microsoft.AspNet.Razor.Runtime.TagHelpers; using Microsoft.AspNet.Http; -using Microsoft.AspNet.NodeServices; using Microsoft.AspNet.Http.Extensions; namespace Microsoft.AspNet.NodeServices.Angular @@ -10,6 +10,7 @@ namespace Microsoft.AspNet.NodeServices.Angular public class AngularRunAtServerTagHelper : TagHelper { static StringAsTempFile nodeScript; + static INodeServices fallbackNodeServices; // Used only if no INodeServices was registered with DI static AngularRunAtServerTagHelper() { // Consider populating this lazily @@ -17,8 +18,8 @@ namespace Microsoft.AspNet.NodeServices.Angular nodeScript = new StringAsTempFile(script); // Will be cleaned up on process exit } - const string PrerenderModuleAttributeName = "aspnet-ng2-prerender-module"; - const string PrerenderExportAttributeName = "aspnet-ng2-prerender-export"; + const string PrerenderModuleAttributeName = "asp-ng2-prerender-module"; + const string PrerenderExportAttributeName = "asp-ng2-prerender-export"; [HtmlAttributeName(PrerenderModuleAttributeName)] public string ModuleName { get; set; } @@ -29,10 +30,16 @@ namespace Microsoft.AspNet.NodeServices.Angular private IHttpContextAccessor contextAccessor; private INodeServices nodeServices; - public AngularRunAtServerTagHelper(INodeServices nodeServices, IHttpContextAccessor contextAccessor) + public AngularRunAtServerTagHelper(IServiceProvider nodeServices, IHttpContextAccessor contextAccessor) { this.contextAccessor = contextAccessor; - this.nodeServices = nodeServices; + this.nodeServices = (INodeServices)nodeServices.GetService(typeof (INodeServices)) ?? fallbackNodeServices; + + // Consider removing the following. Having it means you can get away with not putting app.AddNodeServices() + // in your startup file, but then again it might be confusing that you don't need to. + if (this.nodeServices == null) { + this.nodeServices = fallbackNodeServices = Configuration.CreateNodeServices(NodeHostingModel.Http); + } } public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) diff --git a/Microsoft.AspNet.NodeServices.Angular/project.json b/Microsoft.AspNet.NodeServices.Angular/project.json index fec49f8..241590e 100644 --- a/Microsoft.AspNet.NodeServices.Angular/project.json +++ b/Microsoft.AspNet.NodeServices.Angular/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-alpha2", + "version": "1.0.0-alpha3", "description": "Microsoft.AspNet.NodeServices.Angular Class Library", "authors": [ "Microsoft" @@ -25,7 +25,7 @@ } }, "dependencies": { - "Microsoft.AspNet.NodeServices": "1.0.0-alpha2", + "Microsoft.AspNet.NodeServices": "1.0.0-alpha3", "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8" }, "resource": [ diff --git a/Microsoft.AspNet.NodeServices.React/project.json b/Microsoft.AspNet.NodeServices.React/project.json index a099840..36356cf 100644 --- a/Microsoft.AspNet.NodeServices.React/project.json +++ b/Microsoft.AspNet.NodeServices.React/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-alpha2", + "version": "1.0.0-alpha3", "description": "Microsoft.AspNet.NodeServices.React Class Library", "authors": [ "Microsoft" @@ -25,7 +25,7 @@ } }, "dependencies": { - "Microsoft.AspNet.NodeServices": "1.0.0-alpha2" + "Microsoft.AspNet.NodeServices": "1.0.0-alpha3" }, "resource": [ "Content/**/*" diff --git a/Microsoft.AspNet.NodeServices/Configuration.cs b/Microsoft.AspNet.NodeServices/Configuration.cs index c0c336e..2323812 100644 --- a/Microsoft.AspNet.NodeServices/Configuration.cs +++ b/Microsoft.AspNet.NodeServices/Configuration.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.NodeServices { }); } - private static INodeServices CreateNodeServices(NodeHostingModel hostingModel) + public static INodeServices CreateNodeServices(NodeHostingModel hostingModel) { switch (hostingModel) { diff --git a/Microsoft.AspNet.NodeServices/project.json b/Microsoft.AspNet.NodeServices/project.json index c071791..81a7a23 100644 --- a/Microsoft.AspNet.NodeServices/project.json +++ b/Microsoft.AspNet.NodeServices/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-alpha2", + "version": "1.0.0-alpha3", "description": "Microsoft.AspNet.NodeServices", "authors": [ "Microsoft" ], "tags": [""], diff --git a/samples/angular/MusicStore/Startup.cs b/samples/angular/MusicStore/Startup.cs index 592302e..81a5279 100755 --- a/samples/angular/MusicStore/Startup.cs +++ b/samples/angular/MusicStore/Startup.cs @@ -8,7 +8,6 @@ using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Http; using Microsoft.AspNet.Identity.EntityFramework; -using Microsoft.AspNet.NodeServices; using Microsoft.Data.Entity; using Microsoft.Dnx.Runtime; using Microsoft.Framework.Configuration; @@ -79,9 +78,6 @@ namespace MusicStore Mapper.CreateMap(); Mapper.CreateMap(); Mapper.CreateMap(); - - // Enable Node Services - services.AddNodeServices(); } // Configure is called after ConfigureServices is called. diff --git a/samples/angular/MusicStore/Views/Home/Index.cshtml b/samples/angular/MusicStore/Views/Home/Index.cshtml index 9019251..acd6a30 100755 --- a/samples/angular/MusicStore/Views/Home/Index.cshtml +++ b/samples/angular/MusicStore/Views/Home/Index.cshtml @@ -3,7 +3,7 @@ } - + Loading... diff --git a/samples/angular/MusicStore/project.json b/samples/angular/MusicStore/project.json index 76659e2..4568226 100755 --- a/samples/angular/MusicStore/project.json +++ b/samples/angular/MusicStore/project.json @@ -19,7 +19,7 @@ "EntityFramework.SQLite": "7.0.0-beta8", "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8", "AutoMapper": "4.0.0-alpha1", - "Microsoft.AspNet.NodeServices.Angular": "1.0.0-alpha2" + "Microsoft.AspNet.NodeServices.Angular": "1.0.0-alpha3" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel" diff --git a/samples/misc/ES2015Transpilation/project.json b/samples/misc/ES2015Transpilation/project.json index 16aa144..d8be5db 100755 --- a/samples/misc/ES2015Transpilation/project.json +++ b/samples/misc/ES2015Transpilation/project.json @@ -16,7 +16,7 @@ "Microsoft.Framework.Logging": "1.0.0-beta8", "Microsoft.Framework.Logging.Console": "1.0.0-beta8", "Microsoft.Framework.Logging.Debug": "1.0.0-beta8", - "Microsoft.AspNet.NodeServices": "1.0.0-alpha2" + "Microsoft.AspNet.NodeServices": "1.0.0-alpha3" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel" diff --git a/samples/react/ReactGrid/project.json b/samples/react/ReactGrid/project.json index 5c33b46..5d6f8e0 100755 --- a/samples/react/ReactGrid/project.json +++ b/samples/react/ReactGrid/project.json @@ -16,7 +16,7 @@ "Microsoft.Framework.Logging": "1.0.0-beta8", "Microsoft.Framework.Logging.Console": "1.0.0-beta8", "Microsoft.Framework.Logging.Debug": "1.0.0-beta8", - "Microsoft.AspNet.NodeServices.React": "1.0.0-alpha2" + "Microsoft.AspNet.NodeServices.React": "1.0.0-alpha3" }, "commands": { "web": "Microsoft.AspNet.Server.Kestrel"