Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/RouteJs.AspNet/AttributeRouteFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Infrastructure;
using Microsoft.AspNetCore.Mvc.Internal;
//using Microsoft.AspNetCore.Mvc.Internal;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Template;
Expand Down
8 changes: 8 additions & 0 deletions src/RouteJs.AspNet/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.


[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0063:Utiliser une instruction 'using' simple")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0037:Utiliser un nom de membre déduit", Scope = "member", Target = "~M:RouteJs.RouteJs.GetJsonData~System.String")]
27 changes: 27 additions & 0 deletions src/RouteJs.AspNet/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:62667/",
"sslPort": 44316
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"RouteJs.AspNet": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
26 changes: 26 additions & 0 deletions src/RouteJs.AspNet/RouteJs.AspNet.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<None Remove="compiler\resources\router.min.js" />
<None Remove="router.js" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="compiler\resources\router.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="compiler\resources\router.min.js">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

</Project>
11 changes: 6 additions & 5 deletions src/RouteJs.AspNet/RouteJsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
using Microsoft.AspNetCore.Mvc;

namespace RouteJs
{
/// <summary>
/// ASP.NET MVC controller for RouteJs. Renders JavaScript to handle routing of ASP.NET URLs.
/// </summary>
public class RouteJsController : Controller
{
/// <summary>
/// ASP.NET MVC controller for RouteJs. Renders JavaScript to handle routing of ASP.NET URLs.
/// </summary>
[ApiExplorerSettings(IgnoreApi = true)]
public class RouteJsController : Controller
{
/// <summary>
/// How long to cache the JavaScript output for. Only used when a unique hash is present in the URL.
Expand Down
7 changes: 4 additions & 3 deletions src/RouteJs.AspNet/RouteJsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Html;

using Microsoft.Extensions.Hosting;

namespace RouteJs
{
/// <summary>
Expand Down Expand Up @@ -37,7 +38,7 @@ public class RouteJsHelper : IRouteJsHelper
/// <summary>
/// Hosting environment
/// </summary>
private readonly IHostingEnvironment _env;
private readonly IWebHostEnvironment _env;

private readonly IActionContextAccessor _actionContextAccessor;

Expand All @@ -51,7 +52,7 @@ public class RouteJsHelper : IRouteJsHelper
public RouteJsHelper(
IUrlHelperFactory urlHelperFactory,
IServiceProvider serviceProvider,
IHostingEnvironment env,
IWebHostEnvironment env,
IActionContextAccessor actionContextAccessor)
{
_urlHelperFactory = urlHelperFactory;
Expand Down
21 changes: 12 additions & 9 deletions src/RouteJs.AspNet/TemplateRouteFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ public TemplateRouteFetcher(IConstraintsProcessor constraintsProcessor, IRouteTe
/// <returns>Processed route information</returns>
public IEnumerable<RouteInfo> GetRoutes(RouteData routeData)
{
var routeCollection = routeData.Routers.OfType<RouteCollection>().First();
for (var i = 0; i < routeCollection.Count; i++)
{
var route = routeCollection[i];
if (route is Route)
{
yield return ProcessTemplateRoute((Route)route);
}
}
var routeCollection = routeData.Routers.OfType<RouteCollection>().FirstOrDefault();
if (routeCollection != null)
{
for (var i = 0; i < routeCollection.Count; i++)
{
var route = routeCollection[i];
if (route is Route)
{
yield return ProcessTemplateRoute((Route)route);
}
}
}
}

/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions src/RouteJs.AspNet/bundleconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"outputFileName": "compiler/resources/router.min.js",
"inputFiles": [
"compiler/resources/router.js"
]
}
]
Loading