Skip to content

Commit 7e1955c

Browse files
Make app.AddNodeServices optional in Angular case. Fix tag helper attribute name. Bump versions.
1 parent 37eb4ef commit 7e1955c

File tree

10 files changed

+22
-19
lines changed

10 files changed

+22
-19
lines changed

Microsoft.AspNet.NodeServices.Angular/AngularPrerenderTagHelper.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
using System;
12
using System.Threading.Tasks;
23
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
34
using Microsoft.AspNet.Http;
4-
using Microsoft.AspNet.NodeServices;
55
using Microsoft.AspNet.Http.Extensions;
66

77
namespace Microsoft.AspNet.NodeServices.Angular
@@ -10,15 +10,16 @@ namespace Microsoft.AspNet.NodeServices.Angular
1010
public class AngularRunAtServerTagHelper : TagHelper
1111
{
1212
static StringAsTempFile nodeScript;
13+
static INodeServices fallbackNodeServices; // Used only if no INodeServices was registered with DI
1314

1415
static AngularRunAtServerTagHelper() {
1516
// Consider populating this lazily
1617
var script = EmbeddedResourceReader.Read(typeof (AngularRunAtServerTagHelper), "/Content/Node/angular-rendering.js");
1718
nodeScript = new StringAsTempFile(script); // Will be cleaned up on process exit
1819
}
1920

20-
const string PrerenderModuleAttributeName = "aspnet-ng2-prerender-module";
21-
const string PrerenderExportAttributeName = "aspnet-ng2-prerender-export";
21+
const string PrerenderModuleAttributeName = "asp-ng2-prerender-module";
22+
const string PrerenderExportAttributeName = "asp-ng2-prerender-export";
2223

2324
[HtmlAttributeName(PrerenderModuleAttributeName)]
2425
public string ModuleName { get; set; }
@@ -29,10 +30,16 @@ static AngularRunAtServerTagHelper() {
2930
private IHttpContextAccessor contextAccessor;
3031
private INodeServices nodeServices;
3132

32-
public AngularRunAtServerTagHelper(INodeServices nodeServices, IHttpContextAccessor contextAccessor)
33+
public AngularRunAtServerTagHelper(IServiceProvider nodeServices, IHttpContextAccessor contextAccessor)
3334
{
3435
this.contextAccessor = contextAccessor;
35-
this.nodeServices = nodeServices;
36+
this.nodeServices = (INodeServices)nodeServices.GetService(typeof (INodeServices)) ?? fallbackNodeServices;
37+
38+
// Consider removing the following. Having it means you can get away with not putting app.AddNodeServices()
39+
// in your startup file, but then again it might be confusing that you don't need to.
40+
if (this.nodeServices == null) {
41+
this.nodeServices = fallbackNodeServices = Configuration.CreateNodeServices(NodeHostingModel.Http);
42+
}
3643
}
3744

3845
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)

Microsoft.AspNet.NodeServices.Angular/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.0-alpha2",
2+
"version": "1.0.0-alpha3",
33
"description": "Microsoft.AspNet.NodeServices.Angular Class Library",
44
"authors": [
55
"Microsoft"
@@ -25,7 +25,7 @@
2525
}
2626
},
2727
"dependencies": {
28-
"Microsoft.AspNet.NodeServices": "1.0.0-alpha2",
28+
"Microsoft.AspNet.NodeServices": "1.0.0-alpha3",
2929
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta8"
3030
},
3131
"resource": [

Microsoft.AspNet.NodeServices.React/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.0-alpha2",
2+
"version": "1.0.0-alpha3",
33
"description": "Microsoft.AspNet.NodeServices.React Class Library",
44
"authors": [
55
"Microsoft"
@@ -25,7 +25,7 @@
2525
}
2626
},
2727
"dependencies": {
28-
"Microsoft.AspNet.NodeServices": "1.0.0-alpha2"
28+
"Microsoft.AspNet.NodeServices": "1.0.0-alpha3"
2929
},
3030
"resource": [
3131
"Content/**/*"

Microsoft.AspNet.NodeServices/Configuration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static void AddNodeServices(this IServiceCollection serviceCollection, No
88
});
99
}
1010

11-
private static INodeServices CreateNodeServices(NodeHostingModel hostingModel)
11+
public static INodeServices CreateNodeServices(NodeHostingModel hostingModel)
1212
{
1313
switch (hostingModel)
1414
{

Microsoft.AspNet.NodeServices/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.0-alpha2",
2+
"version": "1.0.0-alpha3",
33
"description": "Microsoft.AspNet.NodeServices",
44
"authors": [ "Microsoft" ],
55
"tags": [""],

samples/angular/MusicStore/Startup.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Microsoft.AspNet.Hosting;
99
using Microsoft.AspNet.Http;
1010
using Microsoft.AspNet.Identity.EntityFramework;
11-
using Microsoft.AspNet.NodeServices;
1211
using Microsoft.Data.Entity;
1312
using Microsoft.Dnx.Runtime;
1413
using Microsoft.Framework.Configuration;
@@ -79,9 +78,6 @@ public void ConfigureServices(IServiceCollection services)
7978
Mapper.CreateMap<ArtistResultDto, Artist>();
8079
Mapper.CreateMap<Genre, GenreResultDto>();
8180
Mapper.CreateMap<GenreResultDto, Genre>();
82-
83-
// Enable Node Services
84-
services.AddNodeServices();
8581
}
8682

8783
// Configure is called after ConfigureServices is called.

samples/angular/MusicStore/Views/Home/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
}
44

55
<cache vary-by="@Context.Request.Path">
6-
<app aspnet-ng2-prerender-module="wwwroot/ng-app/components/app/app">
6+
<app asp-ng2-prerender-module="wwwroot/ng-app/components/app/app">
77
Loading...
88
</app>
99
</cache>

samples/angular/MusicStore/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"EntityFramework.SQLite": "7.0.0-beta8",
2020
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
2121
"AutoMapper": "4.0.0-alpha1",
22-
"Microsoft.AspNet.NodeServices.Angular": "1.0.0-alpha2"
22+
"Microsoft.AspNet.NodeServices.Angular": "1.0.0-alpha3"
2323
},
2424
"commands": {
2525
"web": "Microsoft.AspNet.Server.Kestrel"

samples/misc/ES2015Transpilation/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"Microsoft.Framework.Logging": "1.0.0-beta8",
1717
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
1818
"Microsoft.Framework.Logging.Debug": "1.0.0-beta8",
19-
"Microsoft.AspNet.NodeServices": "1.0.0-alpha2"
19+
"Microsoft.AspNet.NodeServices": "1.0.0-alpha3"
2020
},
2121
"commands": {
2222
"web": "Microsoft.AspNet.Server.Kestrel"

samples/react/ReactGrid/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"Microsoft.Framework.Logging": "1.0.0-beta8",
1717
"Microsoft.Framework.Logging.Console": "1.0.0-beta8",
1818
"Microsoft.Framework.Logging.Debug": "1.0.0-beta8",
19-
"Microsoft.AspNet.NodeServices.React": "1.0.0-alpha2"
19+
"Microsoft.AspNet.NodeServices.React": "1.0.0-alpha3"
2020
},
2121
"commands": {
2222
"web": "Microsoft.AspNet.Server.Kestrel"

0 commit comments

Comments
 (0)