Skip to content

Commit

Permalink
fixing mvc project
Browse files Browse the repository at this point in the history
  • Loading branch information
Jetski5822 committed Mar 8, 2017
1 parent 159b8f5 commit 92b071d
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public Startup(IServiceProvider applicationServices,

public override void ConfigureServices(IServiceCollection serviceCollection)
{
serviceCollection.AddRouting();
serviceCollection.AddMvcModules(_applicationServices);
}

Expand All @@ -40,7 +41,7 @@ public override void Configure(IApplicationBuilder builder, IRouteBuilder routes
routes.MapAreaRoute
(
name: "Home",
areaName: "HelloWorld",
areaName: "Orchard.Mvc.HelloWorld",
template: "",
defaults: new { controller = "Home", action = "Index" }
);
Expand Down
1 change: 1 addition & 0 deletions src/Orchard.Mvc.Web/OrchardCore.Mvc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<ProjectReference Include="../OrchardCore/Orchard.Hosting.Console/Orchard.Hosting.Console.csproj" />
<ProjectReference Include="../OrchardCore/Microsoft.AspNetCore.Modules/Microsoft.AspNetCore.Modules.csproj" />
<ProjectReference Include="../OrchardCore/Microsoft.AspNetCore.Mvc.Modules/Microsoft.AspNetCore.Mvc.Modules.csproj" />
<ProjectReference Include="Modules\Orchard.Mvc.HelloWorld\Orchard.Mvc.HelloWorld.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Linq" Version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public static IServiceCollection AddWebHost(
internalServices.AddExtensionManagerHost("App_Data", "dependencies");

internalServices.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

internalServices.AddScoped<IModularTenantRouteBuilder, ModularTenantRouteBuilder>();
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Routing;

namespace Microsoft.AspNetCore.Modules
{
public class ModularTenantRouteBuilder : IModularTenantRouteBuilder
{
private readonly IServiceProvider _serviceProvider;

// Register one top level TenantRoute per tenant. Each instance contains all the routes
// for this tenant.
public ModularTenantRouteBuilder(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}

public IRouteBuilder Build()
{
IApplicationBuilder appBuilder = new ApplicationBuilder(_serviceProvider);

var routeBuilder = new RouteBuilder(appBuilder)
{
};

return routeBuilder;
}

public void Configure(IRouteBuilder builder)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ internal static IMvcCoreBuilder AddModularRazorViewEngine(this IMvcCoreBuilder b

internal static void AddMvcModuleCoreServices(IServiceCollection services)
{
services.AddScoped<IModularTenantRouteBuilder, ModularTenantRouteBuilder>();
services.Replace(
ServiceDescriptor.Scoped<IModularTenantRouteBuilder, ModularTenantRouteBuilder>());

services.AddScoped<IViewLocationExpanderProvider, DefaultViewLocationExpanderProvider>();
services.AddScoped<IViewLocationExpanderProvider, ModularViewLocationExpanderProvider>();
Expand Down

0 comments on commit 92b071d

Please sign in to comment.