diff --git a/vNext/src/BetterModules.Core.Web/Configuration/DefaultWebConfigurationSection.cs b/vNext/src/BetterModules.Core.Web/Configuration/DefaultWebConfigurationSection.cs
index 9e81283..424bae6 100644
--- a/vNext/src/BetterModules.Core.Web/Configuration/DefaultWebConfigurationSection.cs
+++ b/vNext/src/BetterModules.Core.Web/Configuration/DefaultWebConfigurationSection.cs
@@ -2,7 +2,7 @@
namespace BetterModules.Core.Web.Configuration
{
- public class DefaultWebConfigurationSection : DefaultConfigurationSection, IWebConfiguration
+ public class DefaultWebConfigurationSection : DefaultConfigurationSection
{
public string WebSiteUrl { get; set; }
}
diff --git a/vNext/src/BetterModules.Core.Web/Configuration/IWebConfiguration.cs b/vNext/src/BetterModules.Core.Web/Configuration/IWebConfiguration.cs
deleted file mode 100644
index 65f3929..0000000
--- a/vNext/src/BetterModules.Core.Web/Configuration/IWebConfiguration.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using BetterModules.Core.Configuration;
-
-namespace BetterModules.Core.Web.Configuration
-{
- public interface IWebConfiguration : IConfiguration
- {
- ///
- /// Gets or sets the web site URL.
- ///
- ///
- /// The web site URL.
- ///
- string WebSiteUrl { get; set; }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Dependencies/PerWebRequestContainerProvider.cs b/vNext/src/BetterModules.Core.Web/Dependencies/PerWebRequestContainerProvider.cs
deleted file mode 100644
index eccf7c7..0000000
--- a/vNext/src/BetterModules.Core.Web/Dependencies/PerWebRequestContainerProvider.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-//using System;
-//using BetterModules.Core.Web.Web;
-
-//namespace BetterModules.Core.Web.Dependencies
-//{
-// ///
-// /// Service locator to support per web request life time manager.
-// ///
-// public class PerWebRequestContainerProvider
-// {
-// ///
-// /// Marker key.
-// ///
-// private static readonly object PerWebRequestContainerKey = new object();
-
-// ///
-// /// The HTTP context accessor.
-// ///
-// private readonly IHttpContextAccessor httpContextAccessor;
-
-// ///
-// /// Initializes a new instance of the class.
-// ///
-// /// The HTTP context accessor.
-// public PerWebRequestContainerProvider(IHttpContextAccessor httpContextAccessor)
-// {
-// this.httpContextAccessor = httpContextAccessor;
-// }
-
-// ///
-// /// Gets the child container.
-// ///
-// ///
-// /// The child container.
-// ///
-// public ILifetimeScope CurrentScope
-// {
-// get
-// {
-// var httpContext = httpContextAccessor.GetCurrent();
-
-// ILifetimeScope requestContainer = httpContext.Items[PerWebRequestContainerKey] as ILifetimeScope;
-
-// if (requestContainer == null)
-// {
-// httpContext.Items[PerWebRequestContainerKey] = requestContainer = ContextScopeProvider.CreateChildContainer();
-// }
-
-// return requestContainer;
-// }
-// }
-
-// ///
-// /// Gets the lifetime scope.
-// ///
-// /// The context.
-// /// The child container.
-// public static ILifetimeScope GetLifetimeScope(HttpContextBase context)
-// {
-// return context.Items[PerWebRequestContainerKey] as ILifetimeScope;
-// }
-
-// ///
-// /// Disposes the managed resources.
-// ///
-// protected void DisposeManagedResources()
-// {
-// var httpContext = httpContextAccessor.GetCurrent();
-// if (httpContext != null)
-// {
-// var requestContainer = httpContext.Items[PerWebRequestContainerKey] as ILifetimeScope;
-
-// if (requestContainer != null)
-// {
-// requestContainer.Dispose();
-// }
-// }
-// }
-
-// ///
-// /// Disposes the current scope.
-// ///
-// /// The sender.
-// /// The instance containing the event data.
-// internal static void DisposeCurrentScope(object sender, EventArgs args)
-// {
-// var httpApplication = sender as HttpApplication;
-// if (httpApplication != null)
-// {
-// if (httpApplication.Context != null)
-// {
-// var requestContainer = httpApplication.Context.Items[PerWebRequestContainerKey] as ILifetimeScope;
-// if (requestContainer != null)
-// {
-// requestContainer.Dispose();
-// }
-// }
-// }
-// }
-// }
-//}
\ No newline at end of file
diff --git a/vNext/src/BetterModules.Core.Web/Dependencies/PerWebRequestLifetimeModule.cs b/vNext/src/BetterModules.Core.Web/Dependencies/PerWebRequestLifetimeModule.cs
deleted file mode 100644
index 64bb644..0000000
--- a/vNext/src/BetterModules.Core.Web/Dependencies/PerWebRequestLifetimeModule.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-//using System.Web;
-//using Microsoft.Web.Infrastructure.DynamicModuleHelper;
-
-//namespace BetterModules.Core.Web.Dependencies
-//{
-// ///
-// /// Per web request lifetime http module.
-// ///
-// public class PerWebRequestLifetimeModule : IHttpModule
-// {
-// ///
-// /// Indicates if module is starting.
-// ///
-// private static bool isStarting;
-
-// ///
-// /// Dynamic the module registration.
-// ///
-// public static void DynamicModuleRegistration()
-// {
-// if (!isStarting)
-// {
-// isStarting = true;
-// DynamicModuleUtility.RegisterModule(typeof(PerWebRequestLifetimeModule));
-// }
-// }
-
-// ///
-// /// Disposes of the resources (other than memory) used by the module that implements .
-// ///
-// public void Dispose()
-// {
-// }
-
-// ///
-// /// Initializes a module and prepares it to handle requests.
-// ///
-// /// An that provides access to the methods, properties, and events common to all application objects within an ASP.NET application
-// public void Init(HttpApplication context)
-// {
-// context.EndRequest += (sender, e) =>
-// {
-// PerWebRequestContainerProvider.DisposeCurrentScope(sender, e);
-// };
-// }
-// }
-//}
\ No newline at end of file
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationEntryPoint.cs b/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationEntryPoint.cs
deleted file mode 100644
index 387a597..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationEntryPoint.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using BetterModules.Core.Exceptions;
-using BetterModules.Core.Web.Environment.Application;
-
-[assembly: WebApplicationPreStartAttribute(typeof(WebApplicationEntryPoint), "PreApplicationStart", Order = 100)]
-
-namespace BetterModules.Core.Web.Environment.Application
-{
- ///
- /// Entry point to run web application preload logic.
- ///
- public class WebApplicationEntryPoint
- {
- private static bool isStarted;
-
- ///
- /// Method to run logic before application start (as PreApplicationStartMethod). Do not run this method from your code.
- ///
- public static void PreApplicationStart()
- {
- if (isStarted)
- {
- return;
- }
-
- ILog logger;
-
- try
- {
- logger = LogManager.GetCurrentClassLogger();
- logger.Info("Starting Web Application...");
- }
- catch (Exception ex)
- {
- throw new CoreException("Logging is not working. A reason may be that Common.Logging section is not configured in web.config.", ex);
- }
-
- try
- {
- logger.Info("Creating Web Application context dependencies container...");
- ContextScopeProvider.RegisterTypes(WebApplicationContext.InitializeContainer());
- }
- catch (Exception ex)
- {
- string message = "Failed to create Web Application context dependencies container.";
- logger.Fatal(message, ex);
-
- throw new CoreException(message, ex);
- }
-
- PreStartWebApplication();
-
- isStarted = true;
- }
-
- public static void PreStartWebApplication()
- {
- if (isStarted)
- {
- return;
- }
-
- var logger = LogManager.GetCurrentClassLogger();
-
- try
- {
- logger.Info("Registering per web request lifetime manager module...");
- PerWebRequestLifetimeModule.DynamicModuleRegistration();
- }
- catch (Exception ex)
- {
- string message = "Failed to register per web request lifetime manager module.";
- logger.Fatal(message, ex);
-
- throw new CoreException(message, ex);
- }
-
- try
- {
- logger.Info("Load assemblies...");
- WebApplicationContext.LoadAssemblies();
- }
- catch (Exception ex)
- {
- string message = "Failed to load assemblies.";
- logger.Fatal(message, ex);
-
- throw new CoreException(message, ex);
- }
-
- try
- {
- logger.Info("Migrating database...");
- ApplicationContext.RunDatabaseMigrations();
- }
- catch (Exception ex)
- {
- string message = "Failed to run database migrations.";
- logger.Fatal(message, ex);
-
- throw new CoreException(message, ex);
- }
-
- isStarted = true;
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationHostAttribute.cs b/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationHostAttribute.cs
deleted file mode 100644
index 937afbb..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationHostAttribute.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-
-namespace BetterModules.Core.Web.Environment.Application
-{
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
- public class WebApplicationHostAttribute : BaseAttribute
- {
- public WebApplicationHostAttribute(Type type) : base(type)
- {
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationPreStartAttribute.cs b/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationPreStartAttribute.cs
deleted file mode 100644
index 4ec9198..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationPreStartAttribute.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-
-namespace BetterModules.Core.Web.Environment.Application
-{
- ///
- /// Application assembly pre-start attribute
- /// Based on: https://github.com/davidebbo/WebActivator
- ///
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
- public sealed class WebApplicationPreStartAttribute : BaseActivationMethodAttribute
- {
- public WebApplicationPreStartAttribute(Type type, string methodName)
- : base(type, methodName)
- {
- }
-
- // Set this to true to have the method run in designer mode (in addition to running at runtime)
- public bool RunInDesigner { get; set; }
-
- public override bool ShouldRunInDesignerMode()
- {
- return RunInDesigner;
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationPreStartManager.cs b/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationPreStartManager.cs
deleted file mode 100644
index 06a1844..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Application/WebApplicationPreStartManager.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Security;
-using BetterModules.Core.Web.Environment.Application;
-using BetterModules.Core.Web.Extensions;
-
-[assembly: PreApplicationStartMethod(typeof(WebApplicationPreStartManager), "PreApplicationStart")]
-
-namespace BetterModules.Core.Web.Environment.Application
-{
- ///
- /// Based on: https://github.com/davidebbo/WebActivator
- ///
- public class WebApplicationPreStartManager
- {
- private static bool _hasInited;
- private static List _assemblies;
-
- // For unit test purpose
- public static void Reset()
- {
- _hasInited = false;
- _assemblies = null;
- }
-
- public static void PreApplicationStart()
- {
- if (!_hasInited)
- {
- // Run pre-start methods
- RunPreStartMethods();
-
- // Register post-start methods to run after App_Start
- foreach (var type in GetWebApplicationHostTypes())
- {
- Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(type);
- }
-
- _hasInited = true;
- }
- }
-
- private static IEnumerable Assemblies
- {
- get
- {
- if (_assemblies == null)
- {
- // Cache the list of relevant assemblies, since we need it for both Pre and Post
- _assemblies = new List();
- foreach (var assemblyFile in GetAssemblyFiles())
- {
- try
- {
- // Ignore assemblies we can't load. They could be native, etc...
- _assemblies.Add(Assembly.LoadFrom(assemblyFile));
- }
- catch (Win32Exception) { }
- catch (ArgumentException) { }
- catch (FileNotFoundException) { }
- catch (PathTooLongException) { }
- catch (BadImageFormatException) { }
- catch (SecurityException) { }
- }
- }
-
- return _assemblies;
- }
- }
-
- private static IEnumerable GetAssemblyFiles()
- {
- // When running under ASP.NET, find assemblies in the bin folder.
- // Outside of ASP.NET, use whatever folder WebActivator itself is in
- string directory = HostingEnvironment.IsHosted
- ? HttpRuntime.BinDirectory
- : Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
- return Directory.GetFiles(directory, "*.dll");
- }
-
- // Return all the App_Code assemblies
- private static IEnumerable AppCodeAssemblies
- {
- get
- {
- // Return an empty list if we;re not hosted or there aren't any
- if (!HostingEnvironment.IsHosted || !_hasInited || BuildManager.CodeAssemblies == null)
- {
- return Enumerable.Empty();
- }
-
- return BuildManager.CodeAssemblies.OfType();
- }
- }
-
- // Call the relevant activation method from all assemblies
- private static void RunPreStartMethods(bool designerMode = false)
- {
- RunActivationMethods(designerMode);
- }
-
- private static void RunActivationMethods(bool designerMode = false) where T : BaseActivationMethodAttribute
- {
- var attribs = Assemblies.Concat(AppCodeAssemblies)
- .SelectMany(assembly => assembly.GetAttributes())
- .OrderBy(att => att.Order);
-
- foreach (var activationAttrib in attribs)
- {
- if (!designerMode || activationAttrib.ShouldRunInDesignerMode())
- {
- activationAttrib.InvokeMethod();
- }
- }
- }
-
- static IEnumerable GetWebApplicationHostTypes()
- {
- return Assemblies.Concat(AppCodeAssemblies)
- .SelectMany(assembly => assembly.GetAttributes())
- .OrderBy(att => att.Order)
- .Select(att => att.Type);
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Assemblies/DefaultWebAssemblyManager.cs b/vNext/src/BetterModules.Core.Web/Environment/Assemblies/DefaultWebAssemblyManager.cs
index efd19a6..7a089fd 100644
--- a/vNext/src/BetterModules.Core.Web/Environment/Assemblies/DefaultWebAssemblyManager.cs
+++ b/vNext/src/BetterModules.Core.Web/Environment/Assemblies/DefaultWebAssemblyManager.cs
@@ -2,7 +2,6 @@
using BetterModules.Core.Environment.Assemblies;
using BetterModules.Core.Environment.FileSystem;
using BetterModules.Core.Modules.Registration;
-using BetterModules.Core.Web.Web.EmbeddedResources;
using Microsoft.Dnx.Runtime;
using Microsoft.Framework.Logging;
using IAssemblyLoader = BetterModules.Core.Environment.Assemblies.IAssemblyLoader;
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Host/DefaultWebApplicationAutoHost.cs b/vNext/src/BetterModules.Core.Web/Environment/Host/DefaultWebApplicationAutoHost.cs
deleted file mode 100644
index a95297f..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Host/DefaultWebApplicationAutoHost.cs
+++ /dev/null
@@ -1,249 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Threading;
-using BetterModules.Core.Exceptions;
-using BetterModules.Core.Web.Exceptions.Host;
-using Microsoft.Framework.Logging;
-
-namespace BetterModules.Core.Web.Environment.Host
-{
- public abstract class DefaultWebApplicationAutoHost : IWebApplicationAutoHost
- {
- private readonly ILogger logger;
-
- private static object _lock = new object();
-
- private string _hostName = "Web application host";
-
- public string HostName
- {
- get { return _hostName; }
- set { _hostName = value; }
- }
-
- protected int InitializedCount
- {
- get
- {
- var type = GetType();
- if (InitializedTypes.ContainsKey(type))
- {
- return InitializedTypes[type];
- }
- InitializedTypes.Add(type, 0);
- return 0;
- }
- set
- {
- var type = GetType();
- if (!InitializedTypes.ContainsKey(type))
- {
- InitializedTypes.Add(type, value);
- }
- else
- {
- InitializedTypes[GetType()] = value;
- }
- }
- }
-
- private static readonly Dictionary InitializedTypes = new Dictionary();
-
- private HttpApplication _application;
-
- protected DefaultWebApplicationAutoHost(ILoggerFactory loggerFactory)
- {
- this.logger = loggerFactory.CreateLogger(typeof(DefaultWebApplicationAutoHost).FullName);
- }
-
- protected HttpApplication Application
- {
- get
- {
- return _application;
- }
- set { _application = value; }
- }
-
- public object Lock
- {
- get { return _lock; }
- }
-
- public virtual void Init(HttpApplication context)
- {
- _application = context;
-
- lock (Lock)
- {
- AttachApplicationEvents(_application);
-
- if(InitializedCount++ == 0)
- {
- OnApplicationStart(_application);
- }
- }
- }
-
- public virtual void Dispose()
- {
- lock (_lock)
- {
- if (--InitializedCount == 0)
- {
- OnApplicationEnd(_application);
- }
- }
- }
-
- protected void AttachApplicationEvents(HttpApplication application)
- {
- application.AuthenticateRequest += Application_AuthenticateRequest;
- application.BeginRequest += Application_BeginRequest;
- application.EndRequest += Application_EndRequest;
- application.Error += Application_Error;
- }
-
- public virtual void OnEndRequest(HttpApplication application)
- {
- }
-
- public virtual void OnAuthenticateRequest(HttpApplication application)
- {
- }
-
- public virtual void OnApplicationStart(HttpApplication application, bool validateViewEngines = true)
- {
- try
- {
- logger.LogInformation("{0} starting...", HostName);
- if (validateViewEngines && !ViewEngines.Engines.Any(engine => engine is CompositePrecompiledMvcEngine))
- {
- throw new CoreException("ViewEngines.Engines collection doesn't contain precompiled composite MVC view engine. Application modules use precompiled MVC views for rendering. Please check if Engines list is not cleared manualy in global.asax.cx");
- }
-
- logger.LogInformation("{0} started.", HostName);
- }
- catch (Exception ex)
- {
- logger.LogCritical("Failed to start host application.", ex);
- }
- }
-
- public virtual void OnApplicationEnd(HttpApplication application)
- {
- logger.LogInformation("{0} stopped.", HostName);
- }
-
- public virtual void OnApplicationError(HttpApplication application)
- {
- }
-
- public virtual void OnBeginRequest(HttpApplication application)
- {
-#if DEBUG
- // A quick way to restart an application host.
- // This is not going to affect production as it is compiled only in the debug mode.
- if (application.Request["restart"] == "1")
- {
- RestartAndReloadHost(application);
- }
-#endif
- }
-
- public virtual void RestartApplicationHost()
- {
- try
- {
- HttpRuntime.UnloadAppDomain();
- }
- catch
- {
- try
- {
- bool success = TryTouchBinRestartMarker() || TryTouchWebConfig();
-
- if (!success)
- {
- throw new RestartApplicationException("Failed to terminate host application.");
- }
- }
- catch (Exception ex)
- {
- throw new RestartApplicationException("Failed to terminate host application.", ex);
- }
- }
- }
-
- private void Application_AuthenticateRequest(object sender, EventArgs e)
- {
- OnAuthenticateRequest((HttpApplication)sender);
- }
-
- private void Application_BeginRequest(object sender, EventArgs e)
- {
- OnBeginRequest((HttpApplication)sender);
- }
-
- private void Application_EndRequest(object sender, EventArgs e)
- {
- OnEndRequest((HttpApplication)sender);
- }
-
- private void Application_Error(object sender, EventArgs e)
- {
- OnApplicationError((HttpApplication)sender);
- }
-
- private bool TryTouchBinRestartMarker()
- {
- try
- {
- var binMarker = HostingEnvironment.MapPath("~/bin/restart");
- Directory.CreateDirectory(binMarker);
-
- using (var stream = File.CreateText(Path.Combine(binMarker, "marker.txt")))
- {
- stream.WriteLine("Restarted on '{0}'", DateTime.UtcNow);
- stream.Flush();
- }
-
- return true;
- }
- catch (Exception ex)
- {
- logger.LogWarning("Failed to touch web host application \bin folder.", ex);
- return false;
- }
- }
-
- private void RestartAndReloadHost(HttpApplication application)
- {
- RestartApplicationHost();
-
- Thread.Sleep(500);
-
- UriBuilder uri = new UriBuilder(application.Request.Url);
- uri.Query = string.Empty;
-
- application.Response.ClearContent();
- application.Response.Write(string.Format("", uri));
- application.Response.End();
- }
-
- private bool TryTouchWebConfig()
- {
- try
- {
- File.SetLastWriteTimeUtc(HostingEnvironment.MapPath("~/web.config"), DateTime.UtcNow);
- return true;
- }
- catch (Exception ex)
- {
- logger.LogWarning("Failed to touch web host application web.config file.", ex);
- return false;
- }
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Host/DefaultWebApplicationHost.cs b/vNext/src/BetterModules.Core.Web/Environment/Host/DefaultWebApplicationHost.cs
deleted file mode 100644
index a04c029..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Host/DefaultWebApplicationHost.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.Web;
-using BetterModules.Core.DataAccess.DataContext.Migrations;
-using BetterModules.Core.Exceptions;
-using BetterModules.Core.Web.Modules.Registration;
-
-namespace BetterModules.Core.Web.Environment.Host
-{
- ///
- /// Default web host implementation.
- ///
- [Obsolete("DefaultWebApplicationHost is deprecated. Consider utilizing DefaultWebApplicationAutoHost")]
- public class DefaultWebApplicationHost : IWebApplicationHost
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The modules registration.
- /// The migration runner.
- public DefaultWebApplicationHost(IWebModulesRegistration modulesRegistration, IMigrationRunner migrationRunner)
- {
- }
-
- ///
- /// Called when the host application starts.
- ///
- /// The host application.
- /// if set to true valdiate view engines.
- /// ViewEngines.Engines collection doesn't contain any precompiled MVC view engines. Each module uses precompiled MVC engines for rendering views. Please check if Engines list is not cleared manualy in global.asax.cx
- public virtual void OnApplicationStart(HttpApplication application, bool validateViewEngines = true)
- {
- }
-
- ///
- /// Called when the host application stops.
- ///
- /// The host application.
- public virtual void OnApplicationEnd(HttpApplication application)
- {
- }
-
- ///
- /// Called when the host application throws unhandled error.
- ///
- /// The host application.
- public virtual void OnApplicationError(HttpApplication application)
- {
- }
-
- ///
- /// Called when the host application ends a web request.
- ///
- /// The host application.
- public virtual void OnEndRequest(HttpApplication application)
- {
- }
-
- ///
- /// Called when the host application begins a web request.
- ///
- /// The host application.
- public virtual void OnBeginRequest(HttpApplication application)
- {
- }
-
- ///
- /// Called when the host application authenticates a web request.
- ///
- ///
- ///
- public virtual void OnAuthenticateRequest(HttpApplication application)
- {
- }
-
- ///
- /// Restarts and reloads application.
- ///
- /// The application.
- public virtual void RestartAndReloadHost(HttpApplication application)
- {
- }
-
- ///
- /// Terminates current application. The application restarts on the next time a request is received for it.
- ///
- public virtual void RestartApplicationHost()
- {
- }
- }
-}
\ No newline at end of file
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Host/IWebApplicationAutoHost.cs b/vNext/src/BetterModules.Core.Web/Environment/Host/IWebApplicationAutoHost.cs
deleted file mode 100644
index 8c8f50d..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Host/IWebApplicationAutoHost.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using System.Web;
-
-namespace BetterModules.Core.Web.Environment.Host
-{
- public interface IWebApplicationAutoHost : IHttpModule, IWebApplicationHost
- {
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Host/IWebApplicationHost.cs b/vNext/src/BetterModules.Core.Web/Environment/Host/IWebApplicationHost.cs
deleted file mode 100644
index 4bb5476..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Host/IWebApplicationHost.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System.Web;
-
-namespace BetterModules.Core.Web.Environment.Host
-{
- ///
- /// Defines the contract for web application host.
- ///
- public interface IWebApplicationHost
- {
- ///
- /// Called when the host application starts.
- ///
- /// The host application.
- /// if set to true valdiate view engines.
- void OnApplicationStart(HttpApplication application, bool validateViewEngines = true);
-
- ///
- /// Called when the host application stops.
- ///
- /// The host application.
- void OnApplicationEnd(HttpApplication application);
-
- ///
- /// Called when the host application throws unhandled error.
- ///
- /// The host application.
- void OnApplicationError(HttpApplication application);
-
- ///
- /// Called when the host application begins a web request.
- ///
- /// The host application.
- void OnBeginRequest(HttpApplication application);
-
- ///
- /// Called when the host application ends a web request.
- ///
- /// The host application.
- void OnEndRequest(HttpApplication application);
-
- ///
- /// Called when the host application authenticates a web request.
- ///
- void OnAuthenticateRequest(HttpApplication application);
-
- ///
- /// Method to restarts the host application domain.
- ///
- void RestartApplicationHost();
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Environment/Host/UtilityHost.cs b/vNext/src/BetterModules.Core.Web/Environment/Host/UtilityHost.cs
deleted file mode 100644
index a26bd00..0000000
--- a/vNext/src/BetterModules.Core.Web/Environment/Host/UtilityHost.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using BetterModules.Core.Web.Environment.Application;
-using BetterModules.Core.Web.Environment.Host;
-using BetterModules.Core.Web.Modules.Registration;
-using BetterModules.Events;
-
-[assembly : WebApplicationHost(typeof(UtilityHost), Order = Int32.MaxValue)]
-namespace BetterModules.Core.Web.Environment.Host
-{
- public sealed class UtilityHost : DefaultWebApplicationAutoHost
- {
- public override void Init(HttpApplication context)
- {
- Application = context;
- lock (Lock)
- {
- if (InitializedCount++ == 0)
- {
- WebCoreEvents.Instance.OnHostStart(context);
-
- using (var container = ContextScopeProvider.CreateChildContainer())
- {
- var modulesRegistration = container.Resolve();
- modulesRegistration.RegisterKnownModuleRoutes(RouteTable.Routes);
- }
- }
- }
- }
-
- public override void Dispose()
- {
- lock (Lock)
- {
- if (--InitializedCount == 0)
- {
- WebCoreEvents.Instance.OnHostStop(Application);
- }
- }
- }
-
- public override void OnApplicationError(HttpApplication application)
- {
- var error = application.Server.GetLastError();
- Logger.Fatal("Unhandled exception occurred in web host application.", error);
-
- // Notify.
- WebCoreEvents.Instance.OnHostError(application);
- }
-
- public override void OnAuthenticateRequest(HttpApplication application)
- {
- WebCoreEvents.Instance.OnHostAuthenticateRequest(application);
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Events/WebCoreEvents.cs b/vNext/src/BetterModules.Core.Web/Events/WebCoreEvents.cs
deleted file mode 100644
index 3b71d6a..0000000
--- a/vNext/src/BetterModules.Core.Web/Events/WebCoreEvents.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System.Web;
-
-// ReSharper disable CheckNamespace
-namespace BetterModules.Events
-// ReSharper restore CheckNamespace
-{
- public class WebCoreEvents : EventsBase
- {
- ///
- /// Occurs when a host starts.
- ///
-
- public event DefaultEventHandler> HostStart;
-
- public event DefaultEventHandler> HostStop;
-
- public event DefaultEventHandler> HostError;
-
- public event DefaultEventHandler> HostAuthenticateRequest;
-
- ///
- /// Called when a host starts.
- ///
- /// The host.
- public void OnHostStart(HttpApplication host)
- {
- if (HostStart != null)
- {
- HostStart(new SingleItemEventArgs(host));
- }
- }
-
- ///
- /// Called when a host stops.
- ///
- /// The host.
- public void OnHostStop(HttpApplication host)
- {
- if (HostStop != null)
- {
- HostStop(new SingleItemEventArgs(host));
- }
- }
-
- ///
- /// Called when a host throws error.
- ///
- /// The host.
- public void OnHostError(HttpApplication host)
- {
- if (HostError != null)
- {
- HostError(new SingleItemEventArgs(host));
- }
- }
-
- ///
- /// Called when a host authenticates request.
- ///
- /// The host.
- public void OnHostAuthenticateRequest(HttpApplication host)
- {
- if (HostAuthenticateRequest != null)
- {
- HostAuthenticateRequest(new SingleItemEventArgs(host));
- }
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Extensions/BetterModulesApplicationBuilderExtensions.cs b/vNext/src/BetterModules.Core.Web/Extensions/BetterModulesApplicationBuilderExtensions.cs
index 46bdc42..05d4dc3 100644
--- a/vNext/src/BetterModules.Core.Web/Extensions/BetterModulesApplicationBuilderExtensions.cs
+++ b/vNext/src/BetterModules.Core.Web/Extensions/BetterModulesApplicationBuilderExtensions.cs
@@ -3,26 +3,28 @@
using BetterModules.Core.DataAccess.DataContext.Migrations;
using BetterModules.Core.Modules.Registration;
using Microsoft.AspNet.Builder;
+using Microsoft.AspNet.Hosting;
using Microsoft.Framework.DependencyInjection;
namespace BetterModules.Core.Web.Extensions
{
public static class BetterModulesApplicationBuilderExtensions
{
- public static IApplicationBuilder UseBetterModules(this IApplicationBuilder app)
+ public static IApplicationBuilder UseBetterModules(this IApplicationBuilder app, IHostingEnvironment env)
{
RunDatabaseMigrations(app.ApplicationServices);
-#if DEBUG
- app.Use(async (context, next) =>
+ if (env.IsDevelopment())
{
- if (context.Request.Query["restart"] == "1")
+ app.Use(async (context, next) =>
{
- //find a way to restart a server
- return;
- }
- await next.Invoke();
- });
-#endif
+ if (context.Request.Query["restart"] == "1")
+ {
+ //find a way to restart a server
+ return;
+ }
+ await next.Invoke();
+ });
+ }
return app;
}
diff --git a/vNext/src/BetterModules.Core.Web/Extensions/BetterModulesServiceCollectionExtensions.cs b/vNext/src/BetterModules.Core.Web/Extensions/BetterModulesServiceCollectionExtensions.cs
index 41021b9..6fd7542 100644
--- a/vNext/src/BetterModules.Core.Web/Extensions/BetterModulesServiceCollectionExtensions.cs
+++ b/vNext/src/BetterModules.Core.Web/Extensions/BetterModulesServiceCollectionExtensions.cs
@@ -3,6 +3,7 @@
using BetterModules.Core.Environment.Assemblies;
using BetterModules.Core.Exceptions;
using BetterModules.Core.Extensions;
+using BetterModules.Core.Infrastructure.Commands;
using BetterModules.Core.Modules.Registration;
using BetterModules.Core.Security;
using BetterModules.Core.Web.Configuration;
@@ -10,11 +11,9 @@
using BetterModules.Core.Web.Modules;
using BetterModules.Core.Web.Modules.Registration;
using BetterModules.Core.Web.Mvc;
-using BetterModules.Core.Web.Mvc.Commands;
using BetterModules.Core.Web.Mvc.Extensions;
using BetterModules.Core.Web.Security;
using BetterModules.Core.Web.Web;
-using BetterModules.Core.Web.Web.EmbeddedResources;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.Framework.Configuration;
@@ -43,10 +42,8 @@ private static void ConfigureDefaultWebServices(this IServiceCollection services
services.AddSingleton();
- services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
- services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
}
@@ -54,59 +51,38 @@ private static void ConfigureDefaultWebServices(this IServiceCollection services
private static void LoadWebConfiguration(this IServiceCollection services, IConfiguration configuration)
{
services.Configure(configuration);
- var provider = services.BuildServiceProvider();
- var config = provider.GetService>().Options;
- if (config?.Database != null)
- {
- config.Database.ConnectionString = configuration[config.Database.ConnectionStringName];
- }
- services.AddInstance(config);
- services.AddInstance(config);
}
private static void LoadWebAssemblies(this IServiceCollection services)
{
services.LoadAssemblies();
- //TODO: find out how to register EmbeddedResourcesVirtualPathProvider
- //if (HostingEnvironment.IsHosted)
- //{
- // HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedResourcesVirtualPathProvider(container.Resolve()));
- //}
- //else
- //{
- // if (!IsTestMode)
- // {
- // throw new CoreException("Failed to register EmbeddedResourcesVirtualPathProvider as a virtual path provider.");
- // }
- //}
-
//TODO: find out how to add precompiled views for assemblies
// Register precompiled views for all the assemblies
- //var precompiledAssemblies = new List();
+ var precompiledAssemblies = new List();
- //var provider = services.BuildServiceProvider();
- //var moduleRegistration = provider.GetService();
- //moduleRegistration.GetModules().Select(m => m.ModuleDescriptor).Distinct().ToList().ForEach(
- // descriptor =>
- // {
- // var webDescriptor = descriptor as WebModuleDescriptor;
- // if (webDescriptor != null)
- // {
- // var precompiledAssembly = new PrecompiledViewAssembly(descriptor.GetType().Assembly,
- // $"~/Areas/{webDescriptor.AreaName}/")
- // {
- // UsePhysicalViewsIfNewer = false
- // };
- // precompiledAssemblies.Add(precompiledAssembly);
- // }
- // });
+ var provider = services.BuildServiceProvider();
+ var moduleRegistration = provider.GetService();
+ moduleRegistration.GetModules().Select(m => m.ModuleDescriptor).Distinct().ToList().ForEach(
+ descriptor =>
+ {
+ var webDescriptor = descriptor as WebModuleDescriptor;
+ if (webDescriptor != null)
+ {
+ var precompiledAssembly = new PrecompiledViewAssembly(descriptor.GetType().Assembly,
+ $"~/Areas/{webDescriptor.AreaName}/")
+ {
+ UsePhysicalViewsIfNewer = false
+ };
+ precompiledAssemblies.Add(precompiledAssembly);
+ }
+ });
- //var engine = new CompositePrecompiledMvcEngine(precompiledAssemblies.ToArray());
- //services.Configure(options =>
- //{
- // options.ViewEngines.Add(engine);
- //});
+ var engine = new CompositePrecompiledMvcEngine(precompiledAssemblies.ToArray());
+ services.Configure(options =>
+ {
+ options.ViewEngines.Add(engine);
+ });
}
}
}
\ No newline at end of file
diff --git a/vNext/src/BetterModules.Core.Web/Modules/Registration/DefaultWebModulesRegistration.cs b/vNext/src/BetterModules.Core.Web/Modules/Registration/DefaultWebModulesRegistration.cs
index 573800f..578e529 100644
--- a/vNext/src/BetterModules.Core.Web/Modules/Registration/DefaultWebModulesRegistration.cs
+++ b/vNext/src/BetterModules.Core.Web/Modules/Registration/DefaultWebModulesRegistration.cs
@@ -56,22 +56,6 @@ public bool IsModuleRegisteredByAreaName(string areaName)
return knownModules.ContainsKey(areaName.ToLowerInvariant());
}
- ///
- /// Register all modules routes
- ///
- ///
- public void RegisterKnownModuleRoutes(RouteCollection routes)
- {
- foreach (var context in knownModules)
- {
- var webModuleContext = context.Value as WebModuleRegistrationContext;
- if (webModuleContext != null)
- {
- routes.Add(webModuleContext.Routes);
- }
- }
- }
-
///
/// Registers the types.
///
diff --git a/vNext/src/BetterModules.Core.Web/Modules/Registration/IWebModulesRegistration.cs b/vNext/src/BetterModules.Core.Web/Modules/Registration/IWebModulesRegistration.cs
index 1d84d1f..8dd62c3 100644
--- a/vNext/src/BetterModules.Core.Web/Modules/Registration/IWebModulesRegistration.cs
+++ b/vNext/src/BetterModules.Core.Web/Modules/Registration/IWebModulesRegistration.cs
@@ -23,11 +23,5 @@ public interface IWebModulesRegistration : IModulesRegistration
/// true if module by area name is registered; otherwise, false.
///
bool IsModuleRegisteredByAreaName(string areaName);
-
- ///
- ///
- ///
- ///
- void RegisterKnownModuleRoutes(RouteCollection routes);
}
}
diff --git a/vNext/src/BetterModules.Core.Web/Modules/WebModuleDescriptor.cs b/vNext/src/BetterModules.Core.Web/Modules/WebModuleDescriptor.cs
index f17adac..0c941c9 100644
--- a/vNext/src/BetterModules.Core.Web/Modules/WebModuleDescriptor.cs
+++ b/vNext/src/BetterModules.Core.Web/Modules/WebModuleDescriptor.cs
@@ -3,10 +3,10 @@
using System.Linq;
using System.Reflection;
using BetterModules.Core.Extensions;
+using BetterModules.Core.Infrastructure.Commands;
using BetterModules.Core.Modules;
using BetterModules.Core.Modules.Registration;
using BetterModules.Core.Web.Modules.Registration;
-using BetterModules.Core.Web.Mvc.Commands;
using BetterModules.Core.Web.Mvc.Extensions;
using Microsoft.AspNet.Mvc;
using Microsoft.Framework.DependencyInjection;
@@ -116,8 +116,7 @@ public virtual void RegisterModuleCommands(WebModuleRegistrationContext registra
{
Assembly assembly = GetType().Assembly;
- Type[] commandTypes = new[]
- {
+ Type[] commandTypes = {
typeof(ICommand),
typeof(ICommandIn<>),
typeof(ICommandOut<>),
diff --git a/vNext/src/BetterModules.Core.Web/Mvc/CoreControllerBase.cs b/vNext/src/BetterModules.Core.Web/Mvc/CoreControllerBase.cs
index 267f83f..2c1c377 100644
--- a/vNext/src/BetterModules.Core.Web/Mvc/CoreControllerBase.cs
+++ b/vNext/src/BetterModules.Core.Web/Mvc/CoreControllerBase.cs
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
-using System.Web.Mvc;
using BetterModules.Core.Infrastructure;
using BetterModules.Core.Infrastructure.Commands;
using BetterModules.Core.Web.Models;
using BetterModules.Core.Web.Mvc.Extensions;
+using Microsoft.AspNet.Mvc;
namespace BetterModules.Core.Web.Mvc
{
@@ -163,7 +163,7 @@ public virtual string RenderView(string viewName, object model, bool enableFormC
/// Called before the action method is invoked.
///
/// Information about the current request and action.
- protected override void OnActionExecuting(ActionExecutingContext filterContext)
+ public override void OnActionExecuting(ActionExecutingContext filterContext)
{
UpdateModelStateErrors();
diff --git a/vNext/src/BetterModules.Core.Web/Mvc/Routes/DefaultRouteTable.cs b/vNext/src/BetterModules.Core.Web/Mvc/Routes/DefaultRouteTable.cs
deleted file mode 100644
index 936d5ee..0000000
--- a/vNext/src/BetterModules.Core.Web/Mvc/Routes/DefaultRouteTable.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Microsoft.AspNet.Routing;
-
-namespace BetterModules.Core.Web.Mvc.Routes
-{
- ///
- /// Default implementation of interface.
- ///
- public class DefaultRouteTable : IRouteTable
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The routes.
- public DefaultRouteTable(RouteCollection routes)
- {
- Routes = routes;
- }
-
- ///
- public RouteCollection Routes { get; private set; }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Mvc/Routes/IRouteTable.cs b/vNext/src/BetterModules.Core.Web/Mvc/Routes/IRouteTable.cs
deleted file mode 100644
index 191039c..0000000
--- a/vNext/src/BetterModules.Core.Web/Mvc/Routes/IRouteTable.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Microsoft.AspNet.Routing;
-
-namespace BetterModules.Core.Web.Mvc.Routes
-{
- ///
- /// Defines the contract that a class must contain routes collection.
- ///
- public interface IRouteTable
- {
- ///
- /// Gets the route collection.
- ///
- ///
- /// The route collection.
- ///
- RouteCollection Routes { get; }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Mvc/Routes/RouteExtensions.cs b/vNext/src/BetterModules.Core.Web/Mvc/Routes/RouteExtensions.cs
deleted file mode 100644
index c31a6f6..0000000
--- a/vNext/src/BetterModules.Core.Web/Mvc/Routes/RouteExtensions.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using Microsoft.AspNet.Routing;
-
-namespace BetterModules.Core.Web.Mvc.Routes
-{
- ///
- /// Route extensions container.
- ///
- public static class RouteExtensions
- {
- ///
- /// Gets the name of the area.
- ///
- /// The route data.
- /// Area name.
- public static string GetAreaName(this RouteData routeData)
- {
- return routeData.Values["area"] as string;
- }
- }
-}
-
diff --git a/vNext/src/BetterModules.Core.Web/Services/Caching/HttpRuntimeCacheService.cs b/vNext/src/BetterModules.Core.Web/Services/Caching/HttpRuntimeCacheService.cs
deleted file mode 100644
index d9f9c1b..0000000
--- a/vNext/src/BetterModules.Core.Web/Services/Caching/HttpRuntimeCacheService.cs
+++ /dev/null
@@ -1,148 +0,0 @@
-using System;
-using FluentNHibernate.Conventions.Helpers;
-using Microsoft.Framework.Caching.Memory;
-using Microsoft.Framework.Logging;
-
-namespace BetterModules.Core.Web.Services.Caching
-{
- ///
- /// Provides a cache service implementation based on the HttpRuntime cache.
- ///
- public class HttpRuntimeCacheService : ICacheService
- {
- ///
- /// Current class logger.
- ///
- private readonly ILogger logger;
-
- public HttpRuntimeCacheService(ILoggerFactory loggerFactory)
- {
- this.logger = loggerFactory.CreateLogger(typeof(HttpRuntimeCacheService).FullName);
- }
-
- ///
- /// Sets object in cache with a specified key for specific time.
- ///
- /// Expected object type.
- /// The cache key.
- /// The cache object to set.
- /// The cache item expiration.
- public void Set(string key, T obj, TimeSpan expiration)
- {
- Set(key, obj, expiration, null);
- }
-
- ///
- /// Gets object from cache by specified key.
- ///
- /// Expected object type.
- /// The cache key.
- /// Object from cache or default value of type T.
- public T Get(string key)
- {
- object obj;
-
- try
- {
- obj = HttpRuntime.Cache[key.ToUpperInvariant()];
- }
- catch (Exception ex)
- {
- logger.LogWarning("Failed to retrieve cache item {0}.", ex, key);
- obj = null;
- }
-
- if (obj == null)
- {
- return default(T);
- }
-
- T converted;
- try
- {
- converted = (T)obj;
- }
- catch (Exception ex)
- {
- logger.LogWarning("Failed to convert cache item {0} of type {1} to type {2}.", ex, key, obj.GetType().FullName, typeof(T).FullName);
- converted = default(T);
- }
-
- return converted;
- }
-
- ///
- /// Gets object from cache by a specified key with defined function to retrieve object.
- ///
- /// Expected type.
- /// The cache key.
- /// The expiration.
- /// A function to create cache object.
- /// Object from cache or getCacheObject function value.
- public T Get(string key, TimeSpan expiration, Func getCacheObject)
- {
- return Get(key, expiration, getCacheObject, null);
- }
-
- ///
- /// Removes object from cache by a specified key.
- ///
- /// The cache key.
- public void Remove(string key)
- {
- if (HttpRuntime.Cache[key.ToUpperInvariant()] != null)
- {
- HttpRuntime.Cache.Remove(key.ToUpperInvariant());
- }
- }
-
- ///
- /// Sets the specified key.
- ///
- /// Expected object type.
- /// The key.
- /// The obj.
- /// The expiration.
- /// The cache item removed callback.
- internal void Set(string key, T obj, TimeSpan expiration, CacheItemRemovedCallback cacheItemRemovedCallback)
- {
- if (obj == null)
- {
- Remove(key);
- }
- else
- {
- HttpRuntime.Cache.Add(
- key.ToUpperInvariant(),
- obj,
- null,
- DateTime.UtcNow.Add(expiration),
- Cache.NoSlidingExpiration,
- CacheItemPriority.NotRemovable,
- cacheItemRemovedCallback);
- }
- }
-
- ///
- /// Gets an item from cache by specified key.
- ///
- /// Expected object type.
- /// The cache key.
- /// The cache item expiration.
- /// Function to create cache item.
- /// The cache item removed callback.
- /// Object from cache or getCacheObject function value.
- internal T Get(string key, TimeSpan expiration, Func getCacheObject, CacheItemRemovedCallback cacheItemRemovedCallback)
- {
- T obj = Get(key);
-
- if (obj == null)
- {
- obj = getCacheObject();
- Set(key, obj, expiration, cacheItemRemovedCallback);
- }
-
- return obj;
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Services/Caching/ICacheService.cs b/vNext/src/BetterModules.Core.Web/Services/Caching/ICacheService.cs
deleted file mode 100644
index 28a5851..0000000
--- a/vNext/src/BetterModules.Core.Web/Services/Caching/ICacheService.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using System;
-
-namespace BetterModules.Core.Web.Services.Caching
-{
- ///
- /// Defines the contract to manage cache items.
- ///
- public interface ICacheService
- {
- ///
- /// Sets object in cache with a specified key for specific time.
- ///
- /// Expected object type.
- /// The cache key.
- /// The cache object to set.
- /// The cache item expiration.
- void Set(string key, T obj, TimeSpan expiration);
-
- ///
- /// Gets object from cache by specified key.
- ///
- /// Expected object type.
- /// The cache key.
- /// Object from cache or default value of type T.
- T Get(string key);
-
- ///
- /// Gets object from cache by a specified key with defined function to retrieve object.
- ///
- /// Expected type.
- /// The cache key.
- /// The expiration.
- /// A function to create cache object.
- /// Object from cache or getCacheObject function value.
- T Get(string key, TimeSpan expiration, Func getCacheObject);
-
- ///
- /// Removes object from cache by a specified key.
- ///
- /// The cache key.
- void Remove(string key);
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Web/DefaultHttpContextAccessor.cs b/vNext/src/BetterModules.Core.Web/Web/DefaultHttpContextAccessor.cs
index 56be016..bd5326a 100644
--- a/vNext/src/BetterModules.Core.Web/Web/DefaultHttpContextAccessor.cs
+++ b/vNext/src/BetterModules.Core.Web/Web/DefaultHttpContextAccessor.cs
@@ -2,39 +2,44 @@
using System.IO;
using System.Reflection;
using BetterModules.Core.Web.Configuration;
+using Microsoft.AspNet.Hosting;
using Microsoft.AspNet.Http;
-using Microsoft.AspNet.Http.Extensions;
+using Microsoft.AspNet.Http.Internal;
using Microsoft.AspNet.Mvc;
+using Microsoft.AspNet.Mvc.Core;
using Microsoft.AspNet.Mvc.Rendering.Expressions;
+using Microsoft.Framework.OptionsModel;
+using Microsoft.Framework.WebEncoders;
namespace BetterModules.Core.Web.Web
{
///
/// Default implementation of http context accessor. Provides HttpContext.Current context wrapper.
///
- public class DefaultHttpContextAccessor : IHttpContextAccessor
+ public class DefaultHttpContextAccessor : HttpContextAccessor, IHttpContextAccessor
{
///
/// The web configuration
///
- private readonly IWebConfiguration configuration;
+ private readonly DefaultWebConfigurationSection configuration;
+
+ ///
+ /// The hosting environment
+ ///
+ private readonly IHostingEnvironment hostingEnvironment;
///
/// Initializes a new instance of the class.
///
/// The application configuration.
- public DefaultHttpContextAccessor(IWebConfiguration configuration)
+ public DefaultHttpContextAccessor(IOptions configuration, IHostingEnvironment hostingEnvironment)
{
- this.configuration = configuration;
+ this.hostingEnvironment = hostingEnvironment;
+ this.configuration = configuration.Options;
}
// TBD: create a DefaultControllerContextAccessor service to get current controller views and etc.
- public HttpContext GetCurrent()
- {
- throw new NotImplementedException();
- }
-
///
/// Returns the physical file path that corresponds to the specified virtual path on the Web server.
///
@@ -44,13 +49,7 @@ public HttpContext GetCurrent()
///
public string MapPath(string path)
{
- var current = GetCurrent();
- if (current != null)
- {
- return current.Server.MapPath(path);
- }
-
- return Path.Combine(GetExecutingAssemblyPath(), path);
+ return hostingEnvironment.MapPath(path);
}
///
@@ -60,7 +59,7 @@ public string MapPath(string path)
/// The absolute path that corresponds to path.
public string MapPublicPath(string path)
{
- return string.Concat(GetServerUrl(GetCurrent().Request).TrimEnd('/'), VirtualPathUtility.ToAbsolute(path));
+ return string.Concat(GetServerUrl(HttpContext.Request).TrimEnd('/'), VirtualPathUtility.ToAbsolute(path));
}
///
@@ -74,22 +73,23 @@ public string MapPublicPath(string path)
public string ResolveActionUrl(System.Linq.Expressions.Expression> expression, bool fullUrl = false)
where TController : Controller
{
- var routeValuesFromExpression = ExpressionHelper.GetRouteValuesFromExpression(expression);
- var action = routeValuesFromExpression["Action"].ToString();
- var controller = routeValuesFromExpression["Controller"].ToString();
- var current = GetCurrent();
- if (current != null)
- {
- string url = new UrlHelper(null, null).Action(action, controller, routeValuesFromExpression);
- if (fullUrl)
- {
- url = string.Concat(GetServerUrl(current.Request).TrimEnd('/'), url);
- }
+ //TODO: Find another way to resolve action url
+ //var routeValuesFromExpression = ExpressionHelper.GetRouteValuesFromExpression(expression);
+
+ //var action = routeValuesFromExpression["Action"].ToString();
+ //var controller = routeValuesFromExpression["Controller"].ToString();
+ //if (HttpContext != null)
+ //{
- url = HttpUtility.UrlDecode(url);
-
- return url;
- }
+ // string url = new UrlHelper(null, null).Action(action, controller, routeValuesFromExpression);
+ // if (fullUrl)
+ // {
+ // url = string.Concat(GetServerUrl(HttpContext.Request).TrimEnd('/'), url);
+ // }
+
+ // url = HttpUtility.UrlDecode(url);
+ // return url;
+ //}
return null;
}
diff --git a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/DefaultEmbeddedResourcesProvider.cs b/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/DefaultEmbeddedResourcesProvider.cs
deleted file mode 100644
index f5319e8..0000000
--- a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/DefaultEmbeddedResourcesProvider.cs
+++ /dev/null
@@ -1,236 +0,0 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text.RegularExpressions;
-using BetterModules.Core.Environment.Assemblies;
-using BetterModules.Core.Web.Modules.Registration;
-using Microsoft.Framework.Logging;
-
-namespace BetterModules.Core.Web.Web.EmbeddedResources
-{
- ///
- /// Default implementation of embedded resources provider.
- ///
- public class DefaultEmbeddedResourcesProvider : IEmbeddedResourcesProvider
- {
- ///
- /// Current class logger.
- ///
- private readonly ILogger logger;
-
- ///
- /// Contains resource name - assembly name pairs dictionary.
- ///
- private readonly ConcurrentDictionary resourceNameEmbeddedResource;
-
- ///
- /// Contains virtual path - embedded resource name pairs dictionary.
- ///
- private readonly ConcurrentDictionary virtualPathResourceName;
-
- ///
- /// Assembly loader contract.
- ///
- private readonly IAssemblyLoader assemblyLoader;
-
- ///
- /// Modules registry contract.
- ///
- private readonly IWebModulesRegistration modulesRegistry;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The modules registry.
- /// The assembly loader contract.
- /// The logger factory
- public DefaultEmbeddedResourcesProvider(IWebModulesRegistration modulesRegistry,
- IAssemblyLoader assemblyLoader,
- ILoggerFactory loggerFactory)
- {
- resourceNameEmbeddedResource = new ConcurrentDictionary();
- virtualPathResourceName = new ConcurrentDictionary();
- this.modulesRegistry = modulesRegistry;
- this.assemblyLoader = assemblyLoader;
- logger = loggerFactory.CreateLogger(typeof (DefaultEmbeddedResourcesProvider).FullName);
- }
-
- ///
- /// Scans and adds an embedded resources from assembly.
- ///
- /// The assembly to scan.
- public void AddEmbeddedResourcesFrom(Assembly assembly)
- {
- if (logger.IsEnabled(LogLevel.Verbose))
- {
- logger.LogVerbose("Adds embedded resources from assembly {0}.", assembly.FullName);
- }
-
- var resourceNames = assembly.GetManifestResourceNames();
- var assemblyName = assembly.GetName();
-
- foreach (var resourceName in resourceNames)
- {
- resourceNameEmbeddedResource.TryAdd(
- resourceName.ToLowerInvariant(),
- new EmbeddedResourceDescriptor
- {
- AssemblyName = assemblyName,
- ResourceName = resourceName
- });
- }
- }
-
- ///
- /// Checks if virtual path exists as embedded resource.
- ///
- /// The virtual path.
- ///
- /// true if virtual path is embedded resource path; otherwise, false.
- ///
- public bool IsEmbeddedResourceVirtualPath(string virtualPath)
- {
- string resourceName;
- if (TryConvertVirtualPathToEmbeddedResourceName(virtualPath, out resourceName))
- {
- return true;
- }
-
- return false;
- }
-
- ///
- /// Gets the embedded resource virtual file.
- ///
- /// The virtual path.
- /// Embedded resource virtual file.
- public EmbeddedResourcesVirtualFile GetEmbeddedResourceVirtualFile(string virtualPath)
- {
- string resourceName;
-
- if (TryConvertVirtualPathToEmbeddedResourceName(virtualPath, out resourceName))
- {
- var embeddedResourceDescriptor = resourceNameEmbeddedResource[resourceName];
- var assembly = assemblyLoader.Load(embeddedResourceDescriptor.AssemblyName);
-
- return new EmbeddedResourcesVirtualFile(assembly, embeddedResourceDescriptor.ResourceName, virtualPath);
- }
-
- return null;
- }
-
- ///
- /// Gets the embedded resource JavaScript virtual files.
- ///
- /// The assembly.
- /// List of embedded resource virtual files.
- public IEnumerable GetEmbeddedResourceJsVirtualFiles(Assembly assembly)
- {
- var javaScriptResources = resourceNameEmbeddedResource
- .Where(f => f.Key.EndsWith(".js", StringComparison.OrdinalIgnoreCase))
- .Where(f => f.Value.AssemblyName.FullName == assembly.FullName);
-
- foreach (var resource in javaScriptResources)
- {
- yield return new EmbeddedResourcesVirtualFile(assembly, resource.Key, "/file/");
- }
- }
-
- ///
- /// Converts the name of the virtual path to embedded resource.
- ///
- /// The virtual path.
- /// Name of the resource.
- /// Returns true if virtual path was successfully parsed to resource name; false otherwise.
- private bool TryConvertVirtualPathToEmbeddedResourceName(string virtualPath, out string embeddedResourceName)
- {
- bool success = false;
- embeddedResourceName = null;
-
- try
- {
- string virtualPathLowered = virtualPath.ToLowerInvariant();
-
- if (virtualPathResourceName.ContainsKey(virtualPathLowered))
- {
- embeddedResourceName = virtualPathResourceName[virtualPathLowered];
- success = true;
- }
-
- if (!success)
- {
- string rawResourceName;
- var areaName = ParseAreaNameFromVirtualPath(virtualPathLowered, out rawResourceName);
- if (!string.IsNullOrEmpty(areaName))
- {
- var module = modulesRegistry.FindModuleByAreaName(areaName);
- if (module != null)
- {
- string predicatedResourceName = (module.AssemblyName.Name + rawResourceName).ToLowerInvariant();
- if (resourceNameEmbeddedResource.ContainsKey(predicatedResourceName))
- {
- virtualPathResourceName.TryAdd(virtualPathLowered, predicatedResourceName);
- embeddedResourceName = predicatedResourceName;
- success = true;
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- logger.LogWarning("Failed to convert virtual path '{0}' to embedded resource name.", ex, virtualPath);
- }
-
- return success;
- }
-
- ///
- /// Parses the name of area from virtual path.
- ///
- /// The virtual path.
- /// Name of the embedded resource without assembly name.
- ///
- /// Name of area; null if area name not exists in virtual path.
- ///
- private string ParseAreaNameFromVirtualPath(string virtualPath, out string rawResourceName)
- {
- int startIndex = virtualPath.IndexOf("/Areas/", StringComparison.OrdinalIgnoreCase);
- if (startIndex > -1)
- {
- startIndex += 7;
- int endIndex = virtualPath.IndexOf('/', startIndex);
- if (endIndex > -1)
- {
- rawResourceName = string.Empty;
-
- string[] parts = virtualPath.Substring(endIndex).Split('/');
- for (int i = 0; i < parts.Length - 1; i++)
- {
- string part = parts[i].Replace("-", "_");
- part = Regex.Replace(part, @"^([0-9])", "_$1");
-
- if (i > 0)
- {
- rawResourceName = string.Concat(rawResourceName, ".");
- }
-
- rawResourceName = string.Concat(rawResourceName, part);
- }
- rawResourceName = string.Concat(rawResourceName, ".", parts[parts.Length - 1]);
-
- string areaName = virtualPath.Substring(startIndex, endIndex - startIndex);
- if (modulesRegistry.IsModuleRegisteredByAreaName(areaName))
- {
- return areaName;
- }
- }
- }
-
- rawResourceName = null;
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourceDescriptor.cs b/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourceDescriptor.cs
deleted file mode 100644
index 508776a..0000000
--- a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourceDescriptor.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System.Reflection;
-
-namespace BetterModules.Core.Web.Web.EmbeddedResources
-{
- ///
- /// Describes embedded assembly resource.
- ///
- public class EmbeddedResourceDescriptor
- {
- ///
- /// Gets or sets the name of the resource.
- ///
- ///
- /// The name of the resource.
- ///
- public string ResourceName { get; set; }
-
- ///
- /// Gets or sets the name of the assembly.
- ///
- ///
- /// The name of the assembly.
- ///
- public AssemblyName AssemblyName { get; set; }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourcesVirtualFile.cs b/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourcesVirtualFile.cs
deleted file mode 100644
index 46ba401..0000000
--- a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourcesVirtualFile.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-using System.IO;
-using System.Reflection;
-
-namespace BetterModules.Core.Web.Web.EmbeddedResources
-{
- ///
- /// Embedded resources virtual file.
- ///
- public class EmbeddedResourcesVirtualFile : VirtualFile
- {
- ///
- /// Embedded resources provider contract.
- ///
- private readonly Assembly assembly;
-
- ///
- /// Name of the embedded resource.
- ///
- private readonly string resourceName;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The assembly.
- /// Name of the embedded resource.
- /// The virtual path.
- public EmbeddedResourcesVirtualFile(Assembly assembly, string resourceName, string virtualPath)
- : base(virtualPath)
- {
- this.assembly = assembly;
- this.resourceName = resourceName;
- }
-
- ///
- /// When overridden in a derived class, returns a read-only stream to the virtual resource.
- ///
- ///
- /// A read-only stream to the virtual file.
- ///
- public override Stream Open()
- {
- return assembly.GetManifestResourceStream(resourceName);
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourcesVirtualPathProvider.cs b/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourcesVirtualPathProvider.cs
deleted file mode 100644
index dd99b6e..0000000
--- a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/EmbeddedResourcesVirtualPathProvider.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-using System;
-using System.Collections;
-using System.Linq;
-
-namespace BetterModules.Core.Web.Web.EmbeddedResources
-{
- ///
- /// Embedded resources virtual path provider.
- ///
- public class EmbeddedResourcesVirtualPathProvider : VirtualPathProvider
- {
- ///
- /// Embedded resources provider contract.
- ///
- private readonly IEmbeddedResourcesProvider embeddedResourcesProvider;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The embedded resources provider.
- public EmbeddedResourcesVirtualPathProvider(IEmbeddedResourcesProvider embeddedResourcesProvider)
- {
- this.embeddedResourcesProvider = embeddedResourcesProvider;
- }
-
- ///
- /// Creates a cache dependency based on the specified virtual paths.
- ///
- /// The path to the primary virtual resource.
- /// An array of paths to other resources required by the primary virtual resource.
- /// The UTC time at which the virtual resources were read.
- ///
- /// A object for the specified virtual resources.
- ///
- public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart)
- {
- if (embeddedResourcesProvider.IsEmbeddedResourceVirtualPath(virtualPath))
- {
- return null;
- }
-
- string[] strArray = (from s in virtualPathDependencies.OfType()
- where !embeddedResourcesProvider.IsEmbeddedResourceVirtualPath(s)
- select s).ToArray();
-
- return base.GetCacheDependency(virtualPath, strArray, utcStart);
- }
-
- ///
- /// Returns a cache key to use for the specified virtual path.
- ///
- /// The path to the virtual resource.
- ///
- /// A cache key for the specified virtual resource.
- ///
- public override string GetCacheKey(string virtualPath)
- {
- return null;
- }
-
- ///
- /// Gets a value that indicates whether a file exists in the virtual file system.
- ///
- /// The path to the virtual file.
- ///
- /// true if the file exists in the virtual file system; otherwise, false.
- ///
- public override bool FileExists(string virtualPath)
- {
- bool isEmbeddedResourceVirtualPath = embeddedResourcesProvider.IsEmbeddedResourceVirtualPath(virtualPath);
-
- if (isEmbeddedResourceVirtualPath)
- {
- return true;
- }
-
- return base.FileExists(virtualPath);
- }
-
- ///
- /// Gets a virtual file from the virtual file system.
- ///
- /// The path to the virtual file.
- ///
- /// A descendent of the class that represents a file in the virtual file system.
- ///
- public override VirtualFile GetFile(string virtualPath)
- {
- VirtualFile embeddedResourcesVirtualFile = embeddedResourcesProvider.GetEmbeddedResourceVirtualFile(virtualPath);
-
- if (embeddedResourcesVirtualFile != null)
- {
- return embeddedResourcesVirtualFile;
- }
-
- return base.GetFile(virtualPath);
- }
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/IEmbeddedResourcesProvider.cs b/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/IEmbeddedResourcesProvider.cs
deleted file mode 100644
index 279781f..0000000
--- a/vNext/src/BetterModules.Core.Web/Web/EmbeddedResources/IEmbeddedResourcesProvider.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System.Collections.Generic;
-using System.Reflection;
-
-namespace BetterModules.Core.Web.Web.EmbeddedResources
-{
- ///
- /// Defines the contract to manage embedded resources.
- ///
- public interface IEmbeddedResourcesProvider
- {
- ///
- /// Scans and adds an embedded resources from assembly.
- ///
- /// The assembly to scan.
- void AddEmbeddedResourcesFrom(Assembly assembly);
-
- ///
- /// Checks if virtual path exists as embedded resource.
- ///
- /// The virtual path.
- ///
- /// true if virtual path is embedded resource path; otherwise, false.
- ///
- bool IsEmbeddedResourceVirtualPath(string virtualPath);
-
- ///
- /// Gets the embedded resource virtual file.
- ///
- /// The virtual path.
- /// Embedded resource virtual file.
- EmbeddedResourcesVirtualFile GetEmbeddedResourceVirtualFile(string virtualPath);
-
- ///
- /// Gets the embedded resource JavaScript virtual files.
- ///
- /// The assembly.
- /// List of embedded resource virtual files.
- IEnumerable GetEmbeddedResourceJsVirtualFiles(Assembly assembly);
- }
-}
diff --git a/vNext/src/BetterModules.Core.Web/Web/IHttpContextAccessor.cs b/vNext/src/BetterModules.Core.Web/Web/IHttpContextAccessor.cs
index 26ec3b7..66d6e09 100644
--- a/vNext/src/BetterModules.Core.Web/Web/IHttpContextAccessor.cs
+++ b/vNext/src/BetterModules.Core.Web/Web/IHttpContextAccessor.cs
@@ -8,14 +8,8 @@ namespace BetterModules.Core.Web.Web
///
/// Defines the contract to access current http context.
///
- public interface IHttpContextAccessor
+ public interface IHttpContextAccessor: Microsoft.AspNet.Http.IHttpContextAccessor
{
- ///
- /// Gets the current http context.
- ///
- /// Current http context instance.
- HttpContext GetCurrent();
-
///
/// Returns the physical file path that corresponds to the specified virtual path on the Web server.
///
diff --git a/vNext/src/BetterModules.Core.Web/project.json b/vNext/src/BetterModules.Core.Web/project.json
index 2c0a964..e3bba73 100644
--- a/vNext/src/BetterModules.Core.Web/project.json
+++ b/vNext/src/BetterModules.Core.Web/project.json
@@ -8,9 +8,8 @@
"dependencies": {
"BetterModules.Core": "1.0.0-*",
- "Microsoft.AspNet.Mvc": "1.0.0-beta7",
- "Microsoft.AspNet.Http": "1.0.0-beta7",
- "Microsoft.Framework.DependencyInjection": "1.0.0-beta7"
+ "Microsoft.AspNet.Http": "1.0.0-beta7",
+ "Microsoft.AspNet.Mvc": "6.0.0-beta7"
},
"frameworks": {
diff --git a/vNext/src/BetterModules.Core/Configuration/DatabaseConfigurationElement.cs b/vNext/src/BetterModules.Core/Configuration/DatabaseConfigurationElement.cs
index 1c994f5..93a4916 100644
--- a/vNext/src/BetterModules.Core/Configuration/DatabaseConfigurationElement.cs
+++ b/vNext/src/BetterModules.Core/Configuration/DatabaseConfigurationElement.cs
@@ -1,6 +1,6 @@
namespace BetterModules.Core.Configuration
{
- public class DatabaseConfigurationElement: IDatabaseConfiguration
+ public class DatabaseConfigurationElement
{
public string SchemaName { get; set; }
diff --git a/vNext/src/BetterModules.Core/Configuration/DefaultConfigurationSection.cs b/vNext/src/BetterModules.Core/Configuration/DefaultConfigurationSection.cs
index 0042fe1..75aa2be 100644
--- a/vNext/src/BetterModules.Core/Configuration/DefaultConfigurationSection.cs
+++ b/vNext/src/BetterModules.Core/Configuration/DefaultConfigurationSection.cs
@@ -1,9 +1,7 @@
namespace BetterModules.Core.Configuration
{
- public class DefaultConfigurationSection: IConfiguration
+ public class DefaultConfigurationSection
{
public DatabaseConfigurationElement Database { get; set; }
-
- IDatabaseConfiguration IConfiguration.Database => Database;
}
}
\ No newline at end of file
diff --git a/vNext/src/BetterModules.Core/Configuration/IConfiguration.cs b/vNext/src/BetterModules.Core/Configuration/IConfiguration.cs
deleted file mode 100644
index 026c38b..0000000
--- a/vNext/src/BetterModules.Core/Configuration/IConfiguration.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace BetterModules.Core.Configuration
-{
- public interface IConfiguration
- {
- ///
- /// Gets the configuration of database.
- ///
- IDatabaseConfiguration Database { get; }
- }
-}
\ No newline at end of file
diff --git a/vNext/src/BetterModules.Core/Configuration/IDatabaseConfiguration.cs b/vNext/src/BetterModules.Core/Configuration/IDatabaseConfiguration.cs
deleted file mode 100644
index 63317de..0000000
--- a/vNext/src/BetterModules.Core/Configuration/IDatabaseConfiguration.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace BetterModules.Core.Configuration
-{
- public interface IDatabaseConfiguration
- {
- string ConnectionString { get; set; }
-
- string ConnectionStringName { get; set; }
-
- string ConnectionProvider { get; set; }
-
- string SchemaName { get; set; }
-
- DatabaseType DatabaseType { get; set; }
- }
-}
\ No newline at end of file
diff --git a/vNext/src/BetterModules.Core/DataAccess/DataContext/DefaultSessionFactoryProvider.cs b/vNext/src/BetterModules.Core/DataAccess/DataContext/DefaultSessionFactoryProvider.cs
index c14139d..f08546a 100644
--- a/vNext/src/BetterModules.Core/DataAccess/DataContext/DefaultSessionFactoryProvider.cs
+++ b/vNext/src/BetterModules.Core/DataAccess/DataContext/DefaultSessionFactoryProvider.cs
@@ -10,6 +10,7 @@
using FluentNHibernate.Cfg.Db;
using FluentNHibernate.Conventions.Helpers;
using Microsoft.Framework.Logging;
+using Microsoft.Framework.OptionsModel;
using NHibernate;
using NHibernate.Event;
using ILoggerFactory = Microsoft.Framework.Logging.ILoggerFactory;
@@ -21,7 +22,7 @@ public class DefaultSessionFactoryProvider : ISessionFactoryProvider
private static readonly object lockObject = new object();
private readonly IMappingResolver mappingResolver;
private volatile ISessionFactory sessionFactory;
- private readonly IConfiguration configuration;
+ private readonly DefaultConfigurationSection configuration;
private readonly IPrincipalProvider principalProvider;
///
@@ -30,12 +31,12 @@ public class DefaultSessionFactoryProvider : ISessionFactoryProvider
private readonly ILogger logger;
public DefaultSessionFactoryProvider(IMappingResolver mappingResolver,
- IConfiguration configuration,
+ IOptions configuration,
IPrincipalProvider principalProvider,
ILoggerFactory loggerFactory)
{
this.mappingResolver = mappingResolver;
- this.configuration = configuration;
+ this.configuration = configuration.Options;
this.principalProvider = principalProvider;
logger = loggerFactory.CreateLogger(typeof (DefaultSessionFactoryProvider).FullName);
}
diff --git a/vNext/src/BetterModules.Core/DataAccess/DataContext/Migrations/DefaultMigrationRunner.cs b/vNext/src/BetterModules.Core/DataAccess/DataContext/Migrations/DefaultMigrationRunner.cs
index 4fed6df..90ede04 100644
--- a/vNext/src/BetterModules.Core/DataAccess/DataContext/Migrations/DefaultMigrationRunner.cs
+++ b/vNext/src/BetterModules.Core/DataAccess/DataContext/Migrations/DefaultMigrationRunner.cs
@@ -46,7 +46,7 @@ public class DefaultMigrationRunner : IMigrationRunner
///
/// The configuration.
///
- private readonly IConfiguration configuration;
+ private readonly DefaultConfigurationSection configuration;
///
/// The version checker
@@ -59,13 +59,13 @@ public class DefaultMigrationRunner : IMigrationRunner
/// The assembly loader.
/// The configuration accessor.
/// The version checker.
- public DefaultMigrationRunner(IAssemblyLoader assemblyLoader,
- IConfiguration configuration,
+ public DefaultMigrationRunner(IAssemblyLoader assemblyLoader,
+ IOptions configuration,
IVersionChecker versionChecker,
ILoggerFactory loggerFactory)
{
this.assemblyLoader = assemblyLoader;
- this.configuration = configuration;
+ this.configuration = configuration.Options;
this.versionChecker = versionChecker;
logger = loggerFactory.CreateLogger(typeof (DefaultMigrationRunner).FullName);
}
diff --git a/vNext/src/BetterModules.Core/Extensions/BetterModulesServiceCollectionExtensions.cs b/vNext/src/BetterModules.Core/Extensions/BetterModulesServiceCollectionExtensions.cs
index aee6c03..12af8cf 100644
--- a/vNext/src/BetterModules.Core/Extensions/BetterModulesServiceCollectionExtensions.cs
+++ b/vNext/src/BetterModules.Core/Extensions/BetterModulesServiceCollectionExtensions.cs
@@ -10,7 +10,6 @@
using BetterModules.Core.Security;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Logging;
-using Microsoft.Framework.OptionsModel;
using IConfiguration = Microsoft.Framework.Configuration.IConfiguration;
namespace BetterModules.Core.Extensions
@@ -58,13 +57,6 @@ public static void ConfigureDefaultServices(this IServiceCollection services)
public static void LoadConfiguration(this IServiceCollection services, IConfiguration configuration)
{
services.Configure(configuration);
- var provider = services.BuildServiceProvider();
- var config = provider.GetService>().Options;
- if (config?.Database != null)
- {
- config.Database.ConnectionString = configuration[config.Database.ConnectionStringName];
- }
- services.AddInstance(config);
}
public static void LoadAssemblies(this IServiceCollection services)
diff --git a/vNext/src/BetterModules.Mvc6.Sandbox/Startup.cs b/vNext/src/BetterModules.Mvc6.Sandbox/Startup.cs
index a09b8b5..9030cfa 100644
--- a/vNext/src/BetterModules.Mvc6.Sandbox/Startup.cs
+++ b/vNext/src/BetterModules.Mvc6.Sandbox/Startup.cs
@@ -78,7 +78,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
template: "{controller=Home}/{action=Index}/{id?}");
});
- app.UseBetterModulesCore();
+ //app.UseBetterModules();
}
}
}