mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 09:37:45 +00:00
Make app.AddNodeServices optional in Angular case. Fix tag helper attribute name. Bump versions.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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/**/*"
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Microsoft.AspNet.NodeServices {
|
||||
});
|
||||
}
|
||||
|
||||
private static INodeServices CreateNodeServices(NodeHostingModel hostingModel)
|
||||
public static INodeServices CreateNodeServices(NodeHostingModel hostingModel)
|
||||
{
|
||||
switch (hostingModel)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.0.0-alpha2",
|
||||
"version": "1.0.0-alpha3",
|
||||
"description": "Microsoft.AspNet.NodeServices",
|
||||
"authors": [ "Microsoft" ],
|
||||
"tags": [""],
|
||||
|
||||
@@ -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<ArtistResultDto, Artist>();
|
||||
Mapper.CreateMap<Genre, GenreResultDto>();
|
||||
Mapper.CreateMap<GenreResultDto, Genre>();
|
||||
|
||||
// Enable Node Services
|
||||
services.AddNodeServices();
|
||||
}
|
||||
|
||||
// Configure is called after ConfigureServices is called.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
}
|
||||
|
||||
<cache vary-by="@Context.Request.Path">
|
||||
<app aspnet-ng2-prerender-module="wwwroot/ng-app/components/app/app">
|
||||
<app asp-ng2-prerender-module="wwwroot/ng-app/components/app/app">
|
||||
Loading...
|
||||
</app>
|
||||
</cache>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user