-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lukas Gerbenis
committed
Oct 1, 2015
1 parent
91ae313
commit 23e39b8
Showing
14 changed files
with
178 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 6 additions & 28 deletions
34
vNext/src/BetterModules.Core.Web/Extensions/BetterModulesApplicationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,18 @@ | ||
using System; | ||
using System.Linq; | ||
using BetterModules.Core.DataAccess.DataContext.Migrations; | ||
using BetterModules.Core.Modules.Registration; | ||
using BetterModules.Core.Web.Web.EmbeddedResources; | ||
using Microsoft.AspNet.Builder; | ||
using Microsoft.AspNet.Hosting; | ||
using Microsoft.AspNet.StaticFiles; | ||
using Microsoft.Framework.DependencyInjection; | ||
|
||
namespace BetterModules.Core.Web.Extensions | ||
{ | ||
public static class BetterModulesApplicationBuilderExtensions | ||
{ | ||
public static IApplicationBuilder UseBetterModules(this IApplicationBuilder app, IHostingEnvironment env) | ||
public static IApplicationBuilder UseBetterStaticFiles(this IApplicationBuilder app) | ||
{ | ||
RunDatabaseMigrations(app.ApplicationServices); | ||
if (env.IsDevelopment()) | ||
return app.UseStaticFiles(new StaticFileOptions | ||
{ | ||
app.Use(async (context, next) => | ||
{ | ||
if (context.Request.Query["restart"] == "1") | ||
{ | ||
//find a way to restart a server | ||
return; | ||
} | ||
await next.Invoke(); | ||
}); | ||
} | ||
return app; | ||
} | ||
|
||
private static void RunDatabaseMigrations(IServiceProvider provider) | ||
{ | ||
var migrationRunner = provider.GetService<IMigrationRunner>(); | ||
var modulesRegistration = provider.GetService<IModulesRegistration>(); | ||
|
||
var descriptors = modulesRegistration.GetModules().Select(x => x.ModuleDescriptor).ToList(); | ||
migrationRunner.MigrateStructure(descriptors); | ||
FileProvider = app.ApplicationServices.GetService<IEmbeddedResourceProvider>() | ||
}); | ||
} | ||
} | ||
} |
25 changes: 17 additions & 8 deletions
25
...tterModulesServiceCollectionExtensions.cs → ...rModulesWebServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.