mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Refactoring a csproj file compiler/build provider
* Removed unused "ServiceLocator" class * Added "OrchardHostContainerRegistry" class to enable Shim/HostContainer registration for DI * Refactored the BuildProvider for .csproj file to use the new OrchardHostContainerRegistry class and enable proper DI for implementations. --HG-- branch : dev
This commit is contained in:
@@ -270,46 +270,4 @@ namespace Orchard.Users.Controllers {
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IMembershipServiceShim {
|
|
||||||
int MinPasswordLength { get; }
|
|
||||||
|
|
||||||
bool ValidateUser(string userName, string password);
|
|
||||||
MembershipCreateStatus CreateUser(string userName, string password, string email);
|
|
||||||
bool ChangePassword(string userName, string oldPassword, string newPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AccountMembershipService : IMembershipServiceShim {
|
|
||||||
private readonly MembershipProvider _provider;
|
|
||||||
|
|
||||||
public AccountMembershipService()
|
|
||||||
: this(null) { }
|
|
||||||
|
|
||||||
public AccountMembershipService(MembershipProvider provider) {
|
|
||||||
_provider = provider ?? Membership.Provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IMembershipService Members
|
|
||||||
|
|
||||||
public int MinPasswordLength {
|
|
||||||
get { return _provider.MinRequiredPasswordLength; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ValidateUser(string userName, string password) {
|
|
||||||
return _provider.ValidateUser(userName, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MembershipCreateStatus CreateUser(string userName, string password, string email) {
|
|
||||||
MembershipCreateStatus status;
|
|
||||||
_provider.CreateUser(userName, password, email, null, null, true, null, out status);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ChangePassword(string userName, string oldPassword, string newPassword) {
|
|
||||||
var currentUser = _provider.GetUser(userName, true /* userIsOnline */);
|
|
||||||
return currentUser.ChangePassword(oldPassword, newPassword);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -28,13 +28,14 @@
|
|||||||
-->
|
-->
|
||||||
<compilation debug="true" targetFramework="4.0">
|
<compilation debug="true" targetFramework="4.0">
|
||||||
<buildProviders>
|
<buildProviders>
|
||||||
<add extension=".csproj" type="Orchard.Environment.Extensions.Compilers.CSharpExtensionBuildProvider"/>
|
<add extension=".csproj" type="Orchard.Environment.Extensions.Compilers.CSharpExtensionBuildProviderShim"/>
|
||||||
</buildProviders>
|
</buildProviders>
|
||||||
<assemblies>
|
<assemblies>
|
||||||
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||||
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||||
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
|
||||||
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
|
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
|
||||||
|
</assemblies>
|
||||||
</compilation>
|
</compilation>
|
||||||
<!--
|
<!--
|
||||||
The <authentication> section enables configuration
|
The <authentication> section enables configuration
|
||||||
|
|||||||
15
src/Orchard/Environment/DefaultHostContainer.cs
Normal file
15
src/Orchard/Environment/DefaultHostContainer.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Autofac;
|
||||||
|
|
||||||
|
namespace Orchard.Environment {
|
||||||
|
public class DefaultOrchardHostContainer : IOrchardHostContainer {
|
||||||
|
private readonly IContainer _container;
|
||||||
|
|
||||||
|
public DefaultOrchardHostContainer(IContainer container) {
|
||||||
|
_container = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>() {
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,14 +17,13 @@ using Orchard.Utility.Extensions;
|
|||||||
namespace Orchard.Environment {
|
namespace Orchard.Environment {
|
||||||
public class DefaultOrchardHost : IOrchardHost, IShellSettingsManagerEventHandler, IShellDescriptorManagerEventHandler {
|
public class DefaultOrchardHost : IOrchardHost, IShellSettingsManagerEventHandler, IShellDescriptorManagerEventHandler {
|
||||||
private readonly ControllerBuilder _controllerBuilder;
|
private readonly ControllerBuilder _controllerBuilder;
|
||||||
|
|
||||||
private readonly IShellSettingsManager _shellSettingsManager;
|
private readonly IShellSettingsManager _shellSettingsManager;
|
||||||
private readonly IShellContextFactory _shellContextFactory;
|
private readonly IShellContextFactory _shellContextFactory;
|
||||||
private readonly IRunningShellTable _runningShellTable;
|
private readonly IRunningShellTable _runningShellTable;
|
||||||
private readonly IProcessingEngine _processingEngine;
|
private readonly IProcessingEngine _processingEngine;
|
||||||
private readonly IExtensionManager _extensionManager;
|
|
||||||
private readonly IExtensionLoaderCoordinator _extensionLoaderCoordinator;
|
private readonly IExtensionLoaderCoordinator _extensionLoaderCoordinator;
|
||||||
private readonly ICacheManager _cacheManager;
|
private readonly ICacheManager _cacheManager;
|
||||||
|
private readonly object _syncLock = new object();
|
||||||
|
|
||||||
private IEnumerable<ShellContext> _current;
|
private IEnumerable<ShellContext> _current;
|
||||||
|
|
||||||
@@ -33,18 +32,18 @@ namespace Orchard.Environment {
|
|||||||
IShellContextFactory shellContextFactory,
|
IShellContextFactory shellContextFactory,
|
||||||
IRunningShellTable runningShellTable,
|
IRunningShellTable runningShellTable,
|
||||||
IProcessingEngine processingEngine,
|
IProcessingEngine processingEngine,
|
||||||
IExtensionManager extensionManager,
|
|
||||||
IExtensionLoaderCoordinator extensionLoaderCoordinator,
|
IExtensionLoaderCoordinator extensionLoaderCoordinator,
|
||||||
ICacheManager cacheManager,
|
ICacheManager cacheManager,
|
||||||
ControllerBuilder controllerBuilder) {
|
ControllerBuilder controllerBuilder) {
|
||||||
|
|
||||||
_shellSettingsManager = shellSettingsManager;
|
_shellSettingsManager = shellSettingsManager;
|
||||||
_shellContextFactory = shellContextFactory;
|
_shellContextFactory = shellContextFactory;
|
||||||
_runningShellTable = runningShellTable;
|
_runningShellTable = runningShellTable;
|
||||||
_processingEngine = processingEngine;
|
_processingEngine = processingEngine;
|
||||||
_extensionManager = extensionManager;
|
|
||||||
_extensionLoaderCoordinator = extensionLoaderCoordinator;
|
_extensionLoaderCoordinator = extensionLoaderCoordinator;
|
||||||
_cacheManager = cacheManager;
|
_cacheManager = cacheManager;
|
||||||
_controllerBuilder = controllerBuilder;
|
_controllerBuilder = controllerBuilder;
|
||||||
|
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@ namespace Orchard.Environment {
|
|||||||
|
|
||||||
IEnumerable<ShellContext> BuildCurrent() {
|
IEnumerable<ShellContext> BuildCurrent() {
|
||||||
if (_current == null) {
|
if (_current == null) {
|
||||||
lock (this) {
|
lock (_syncLock) {
|
||||||
if (_current == null) {
|
if (_current == null) {
|
||||||
SetupExtensions();
|
SetupExtensions();
|
||||||
MonitorExtensions();
|
MonitorExtensions();
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
using System.Web.Compilation;
|
|
||||||
using Orchard.FileSystems.VirtualPath;
|
|
||||||
|
|
||||||
namespace Orchard.Environment.Extensions.Compilers {
|
|
||||||
public class CSharpExtensionBuildProvider : BuildProvider {
|
|
||||||
private readonly CompilerType _codeCompilerType;
|
|
||||||
|
|
||||||
public CSharpExtensionBuildProvider() {
|
|
||||||
_codeCompilerType = GetDefaultCompilerTypeForLanguage("C#");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override CompilerType CodeCompilerType { get { return _codeCompilerType; } }
|
|
||||||
|
|
||||||
public override void GenerateCode(AssemblyBuilder assemblyBuilder) {
|
|
||||||
//Debug.WriteLine(string.Format("BuildProvider for file \"{0}\"", this.VirtualPath));
|
|
||||||
|
|
||||||
//TODO: It probably would be better to access the OrchardHost container
|
|
||||||
// to resolve these dependencies.
|
|
||||||
var virtualPathProvider = new DefaultVirtualPathProvider();
|
|
||||||
var compiler = new CSharpProjectMediumTrustCompiler(virtualPathProvider);
|
|
||||||
|
|
||||||
var aspNetAssemblyBuilder = new AspNetAssemblyBuilder(assemblyBuilder, this);
|
|
||||||
compiler.CompileProject(this.VirtualPath, aspNetAssemblyBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System.Web.Compilation;
|
||||||
|
|
||||||
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
|
public class CSharpExtensionBuildProviderShim : BuildProvider, IShim {
|
||||||
|
private readonly CompilerType _codeCompilerType;
|
||||||
|
|
||||||
|
public CSharpExtensionBuildProviderShim() {
|
||||||
|
OrchardHostContainerRegistry.RegisterShim(this);
|
||||||
|
|
||||||
|
_codeCompilerType = GetDefaultCompilerTypeForLanguage("C#");
|
||||||
|
}
|
||||||
|
|
||||||
|
public IOrchardHostContainer HostContainer { get; set; }
|
||||||
|
|
||||||
|
public override CompilerType CodeCompilerType {
|
||||||
|
get {
|
||||||
|
return _codeCompilerType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GenerateCode(AssemblyBuilder assemblyBuilder) {
|
||||||
|
var context = new CompileExtensionContext {
|
||||||
|
VirtualPath = this.VirtualPath,
|
||||||
|
AssemblyBuilder = new AspNetAssemblyBuilder(assemblyBuilder, this)
|
||||||
|
};
|
||||||
|
HostContainer.Resolve<IExtensionCompiler>().Compile(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,8 +8,9 @@ using System.Web.Compilation;
|
|||||||
namespace Orchard.Environment.Extensions.Compilers {
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compile a C# extension into an assembly given a directory location
|
/// Compile a C# extension into an assembly given a directory location
|
||||||
|
/// Note: Currently not used...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CSharpExtensionCompiler {
|
public class CSharpExtensionDirectoryCompiler {
|
||||||
public CompilerResults CompileProject(string location) {
|
public CompilerResults CompileProject(string location) {
|
||||||
var codeProvider = CodeDomProvider.CreateProvider("cs");
|
var codeProvider = CodeDomProvider.CreateProvider("cs");
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ using Orchard.FileSystems.VirtualPath;
|
|||||||
namespace Orchard.Environment.Extensions.Compilers {
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compile a C# extension into an assembly given a directory location
|
/// Compile a C# extension into an assembly given a directory location
|
||||||
|
/// Note: currently not used...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CSharpProjectFullTrustCompiler {
|
public class CSharpProjectFullTrustCompiler {
|
||||||
private readonly IVirtualPathProvider _virtualPathProvider;
|
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||||
@@ -26,7 +27,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
|||||||
var directory = _virtualPathProvider.GetDirectoryName(virtualPath);
|
var directory = _virtualPathProvider.GetDirectoryName(virtualPath);
|
||||||
|
|
||||||
using (var stream = _virtualPathProvider.OpenFile(virtualPath)) {
|
using (var stream = _virtualPathProvider.OpenFile(virtualPath)) {
|
||||||
var descriptor = new CSharpProjectParser().Parse(stream);
|
var descriptor = new DefaultProjectFileParser().Parse(stream);
|
||||||
|
|
||||||
var references = GetReferencedAssembliesLocation();
|
var references = GetReferencedAssembliesLocation();
|
||||||
var options = new CompilerParameters(references.ToArray());
|
var options = new CompilerParameters(references.ToArray());
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
|
public class CompileExtensionContext {
|
||||||
|
public string VirtualPath { get; set; }
|
||||||
|
public IAssemblyBuilder AssemblyBuilder { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,28 +2,33 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.FileSystems.VirtualPath;
|
using Orchard.FileSystems.VirtualPath;
|
||||||
|
using Orchard.Logging;
|
||||||
|
|
||||||
namespace Orchard.Environment.Extensions.Compilers {
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compile a C# extension into an assembly given a directory location
|
/// Compile a C# extension into an assembly given a directory location
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CSharpProjectMediumTrustCompiler {
|
public class DefaultExtensionCompiler : IExtensionCompiler {
|
||||||
private readonly IVirtualPathProvider _virtualPathProvider;
|
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||||
|
private readonly IProjectFileParser _projectFileParser;
|
||||||
|
|
||||||
public CSharpProjectMediumTrustCompiler(IVirtualPathProvider virtualPathProvider) {
|
public DefaultExtensionCompiler(IVirtualPathProvider virtualPathProvider, IProjectFileParser projectFileParser) {
|
||||||
_virtualPathProvider = virtualPathProvider;
|
_virtualPathProvider = virtualPathProvider;
|
||||||
|
_projectFileParser = projectFileParser;
|
||||||
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
/// <summary>
|
|
||||||
/// Compile a csproj file given its virtual path, a build provider and an assembly builder.
|
|
||||||
/// This method works in medium trust.
|
|
||||||
/// </summary>
|
|
||||||
public void CompileProject(string virtualPath, IAssemblyBuilder assemblyBuilder) {
|
|
||||||
using (var stream = _virtualPathProvider.OpenFile(virtualPath)) {
|
|
||||||
var descriptor = new CSharpProjectParser().Parse(stream);
|
|
||||||
|
|
||||||
var directory = _virtualPathProvider.GetDirectoryName(virtualPath);
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
|
public void Compile(CompileExtensionContext context) {
|
||||||
|
Logger.Information("Generate code for file \"{0}\"", context.VirtualPath);
|
||||||
|
|
||||||
|
using (var stream = _virtualPathProvider.OpenFile(context.VirtualPath)) {
|
||||||
|
var descriptor = _projectFileParser.Parse(stream);
|
||||||
|
|
||||||
|
var directory = _virtualPathProvider.GetDirectoryName(context.VirtualPath);
|
||||||
foreach (var filename in descriptor.SourceFilenames.Select(f => _virtualPathProvider.Combine(directory, f))) {
|
foreach (var filename in descriptor.SourceFilenames.Select(f => _virtualPathProvider.Combine(directory, f))) {
|
||||||
assemblyBuilder.AddCodeCompileUnit(CreateCompileUnit(filename));
|
context.AssemblyBuilder.AddCodeCompileUnit(CreateCompileUnit(filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,24 +5,11 @@ using System.Xml;
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace Orchard.Environment.Extensions.Compilers {
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
public class CSharpProjectDescriptor {
|
public class DefaultProjectFileParser : IProjectFileParser {
|
||||||
public string AssemblyName { get; set; }
|
|
||||||
public IEnumerable<string> SourceFilenames { get; set; }
|
|
||||||
public IEnumerable<ReferenceDescriptor> References { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ReferenceDescriptor {
|
public ProjectFileDescriptor Parse(Stream stream) {
|
||||||
public string AssemblyName { get; set; }
|
|
||||||
|
|
||||||
public override string ToString() {
|
|
||||||
return "{" + (AssemblyName ?? "") + "}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CSharpProjectParser {
|
|
||||||
public CSharpProjectDescriptor Parse(Stream stream) {
|
|
||||||
var document = XDocument.Load(XmlReader.Create(stream));
|
var document = XDocument.Load(XmlReader.Create(stream));
|
||||||
return new CSharpProjectDescriptor {
|
return new ProjectFileDescriptor {
|
||||||
AssemblyName = GetAssemblyName(document),
|
AssemblyName = GetAssemblyName(document),
|
||||||
SourceFilenames = GetSourceFilenames(document).ToArray(),
|
SourceFilenames = GetSourceFilenames(document).ToArray(),
|
||||||
References = GetReferences(document).ToArray()
|
References = GetReferences(document).ToArray()
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
|
public interface IExtensionCompiler {
|
||||||
|
void Compile(CompileExtensionContext context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
|
public interface IProjectFileParser {
|
||||||
|
ProjectFileDescriptor Parse(Stream stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
|
public class ProjectFileDescriptor {
|
||||||
|
public string AssemblyName { get; set; }
|
||||||
|
public IEnumerable<string> SourceFilenames { get; set; }
|
||||||
|
public IEnumerable<ReferenceDescriptor> References { get; set; }
|
||||||
|
}
|
||||||
|
public class ReferenceDescriptor {
|
||||||
|
public string AssemblyName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Orchard.Caching;
|
using Orchard.Caching;
|
||||||
using Orchard.Environment.Extensions.Loaders;
|
using Orchard.Environment.Extensions.Loaders;
|
||||||
@@ -21,10 +20,12 @@ namespace Orchard.Environment.Extensions {
|
|||||||
IExtensionManager extensionManager,
|
IExtensionManager extensionManager,
|
||||||
IEnumerable<IExtensionLoader> loaders,
|
IEnumerable<IExtensionLoader> loaders,
|
||||||
IHostEnvironment hostEnvironment) {
|
IHostEnvironment hostEnvironment) {
|
||||||
|
|
||||||
_dependenciesFolder = dependenciesFolder;
|
_dependenciesFolder = dependenciesFolder;
|
||||||
_extensionManager = extensionManager;
|
_extensionManager = extensionManager;
|
||||||
_loaders = loaders.OrderBy(l => l.Order);
|
_loaders = loaders.OrderBy(l => l.Order);
|
||||||
_hostEnvironment = hostEnvironment;
|
_hostEnvironment = hostEnvironment;
|
||||||
|
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
@@ -37,19 +38,16 @@ namespace Orchard.Environment.Extensions {
|
|||||||
|
|
||||||
var extensions = _extensionManager.AvailableExtensions().Where(d => d.ExtensionType == "Module").ToList();
|
var extensions = _extensionManager.AvailableExtensions().Where(d => d.ExtensionType == "Module").ToList();
|
||||||
var existingDependencies = _dependenciesFolder.LoadDescriptors().ToList();
|
var existingDependencies = _dependenciesFolder.LoadDescriptors().ToList();
|
||||||
|
|
||||||
var sameExtensions = extensions.Where(e => existingDependencies.Any(e2 => e2.Name == e.Name)).ToList();
|
|
||||||
var deletedDependencies = existingDependencies.Where(e => !extensions.Any(e2 => e2.Name == e.Name)).ToList();
|
var deletedDependencies = existingDependencies.Where(e => !extensions.Any(e2 => e2.Name == e.Name)).ToList();
|
||||||
var newExtensions = extensions.Except(sameExtensions).ToList();
|
|
||||||
|
|
||||||
var ctx = new ExtensionLoadingContext();
|
var loadingContext = new ExtensionLoadingContext();
|
||||||
|
|
||||||
// Notify all loaders about extensions removed from the web site
|
// Notify all loaders about extensions removed from the web site
|
||||||
foreach (var dependency in deletedDependencies) {
|
foreach (var dependency in deletedDependencies) {
|
||||||
Logger.Information("Extension {0} has been removed from site", dependency.Name);
|
Logger.Information("Extension {0} has been removed from site", dependency.Name);
|
||||||
foreach (var loader in _loaders) {
|
foreach (var loader in _loaders) {
|
||||||
if (dependency.LoaderName == loader.Name) {
|
if (dependency.LoaderName == loader.Name) {
|
||||||
loader.ExtensionRemoved(ctx, dependency);
|
loader.ExtensionRemoved(loadingContext, dependency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,11 +56,11 @@ namespace Orchard.Environment.Extensions {
|
|||||||
// load that extension.
|
// load that extension.
|
||||||
var newDependencies = new List<DependencyDescriptor>();
|
var newDependencies = new List<DependencyDescriptor>();
|
||||||
foreach (var extension in extensions) {
|
foreach (var extension in extensions) {
|
||||||
ProcessExtension(ctx, extension, existingDependencies, newDependencies);
|
ProcessExtension(loadingContext, extension, existingDependencies, newDependencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute all the work need by "ctx"
|
// Execute all the work need by "ctx"
|
||||||
ProcessContextCommands(ctx);
|
ProcessContextCommands(loadingContext);
|
||||||
|
|
||||||
// And finally save the new entries in the dependencies folder
|
// And finally save the new entries in the dependencies folder
|
||||||
_dependenciesFolder.StoreDescriptors(newDependencies);
|
_dependenciesFolder.StoreDescriptors(newDependencies);
|
||||||
|
|||||||
5
src/Orchard/Environment/IOrchardHostContainer.cs
Normal file
5
src/Orchard/Environment/IOrchardHostContainer.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Orchard.Environment {
|
||||||
|
public interface IOrchardHostContainer {
|
||||||
|
T Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/Orchard/Environment/IShim.cs
Normal file
9
src/Orchard/Environment/IShim.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Orchard.Environment {
|
||||||
|
/// <summary>
|
||||||
|
/// Interface implemented by shims for ASP.NET singleton services that
|
||||||
|
/// need access to the HostContainer instance.
|
||||||
|
/// </summary>
|
||||||
|
public interface IShim {
|
||||||
|
IOrchardHostContainer HostContainer { get; set;}
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/Orchard/Environment/OrchardHostContainerRegistry.cs
Normal file
37
src/Orchard/Environment/OrchardHostContainerRegistry.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Orchard.Environment {
|
||||||
|
/// <summary>
|
||||||
|
/// Provides ability to connect Shims and the OrchardHostContainer
|
||||||
|
/// </summary>
|
||||||
|
public static class OrchardHostContainerRegistry {
|
||||||
|
private static readonly IList<IShim> _shims = new List<IShim>();
|
||||||
|
private static IOrchardHostContainer _hostContainer;
|
||||||
|
|
||||||
|
public static void RegisterShim(IShim shim) {
|
||||||
|
_shims.Add(shim);
|
||||||
|
shim.HostContainer = _hostContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RegisterHostContainer(IOrchardHostContainer container) {
|
||||||
|
if (object.ReferenceEquals(_hostContainer, container))
|
||||||
|
return;
|
||||||
|
|
||||||
|
UnregisterContainerShims();
|
||||||
|
_hostContainer = container;
|
||||||
|
RegisterContainerInShims();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UnregisterContainerShims() {
|
||||||
|
foreach (var shim in _shims) {
|
||||||
|
shim.HostContainer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RegisterContainerInShims() {
|
||||||
|
foreach (var shim in _shims) {
|
||||||
|
shim.HostContainer = _hostContainer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ using Orchard.Caching;
|
|||||||
using Orchard.Environment.AutofacUtil;
|
using Orchard.Environment.AutofacUtil;
|
||||||
using Orchard.Environment.Configuration;
|
using Orchard.Environment.Configuration;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
|
using Orchard.Environment.Extensions.Compilers;
|
||||||
using Orchard.Environment.Extensions.Folders;
|
using Orchard.Environment.Extensions.Folders;
|
||||||
using Orchard.Environment.Extensions.Loaders;
|
using Orchard.Environment.Extensions.Loaders;
|
||||||
using Orchard.Environment.ShellBuilders;
|
using Orchard.Environment.ShellBuilders;
|
||||||
@@ -37,6 +38,8 @@ namespace Orchard.Environment {
|
|||||||
builder.RegisterType<DefaultBuildManager>().As<IBuildManager>().SingleInstance();
|
builder.RegisterType<DefaultBuildManager>().As<IBuildManager>().SingleInstance();
|
||||||
builder.RegisterType<WebFormsExtensionsVirtualPathProvider>().As<ICustomVirtualPathProvider>().SingleInstance();
|
builder.RegisterType<WebFormsExtensionsVirtualPathProvider>().As<ICustomVirtualPathProvider>().SingleInstance();
|
||||||
builder.RegisterType<AppDataFolderRoot>().As<IAppDataFolderRoot>().SingleInstance();
|
builder.RegisterType<AppDataFolderRoot>().As<IAppDataFolderRoot>().SingleInstance();
|
||||||
|
builder.RegisterType<DefaultExtensionCompiler>().As<IExtensionCompiler>().SingleInstance();
|
||||||
|
builder.RegisterType<DefaultProjectFileParser>().As<IProjectFileParser>().SingleInstance();
|
||||||
|
|
||||||
RegisterVolatileProvider<WebSiteFolder, IWebSiteFolder>(builder);
|
RegisterVolatileProvider<WebSiteFolder, IWebSiteFolder>(builder);
|
||||||
RegisterVolatileProvider<AppDataFolder, IAppDataFolder>(builder);
|
RegisterVolatileProvider<AppDataFolder, IAppDataFolder>(builder);
|
||||||
@@ -134,6 +137,7 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OrchardHostContainerRegistry.RegisterHostContainer(new DefaultOrchardHostContainer(container));
|
||||||
return container.Resolve<IOrchardHost>();
|
return container.Resolve<IOrchardHost>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Orchard.Environment {
|
|
||||||
public static class ServiceLocator {
|
|
||||||
private static Func<Type, object> _locator;
|
|
||||||
|
|
||||||
public static void SetLocator(Func<Type, object> locator) {
|
|
||||||
_locator = locator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T Resolve<T>() {
|
|
||||||
return (T)_locator(typeof(T));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -353,6 +353,14 @@
|
|||||||
<Compile Include="Data\ISessionLocator.cs" />
|
<Compile Include="Data\ISessionLocator.cs" />
|
||||||
<Compile Include="Data\DataModule.cs" />
|
<Compile Include="Data\DataModule.cs" />
|
||||||
<Compile Include="Data\Orderable.cs" />
|
<Compile Include="Data\Orderable.cs" />
|
||||||
|
<Compile Include="Environment\DefaultHostContainer.cs" />
|
||||||
|
<Compile Include="Environment\Extensions\Compilers\CompileExtensionContext.cs" />
|
||||||
|
<Compile Include="Environment\Extensions\Compilers\CSharpExtensionBuildProviderShim.cs" />
|
||||||
|
<Compile Include="Environment\Extensions\Compilers\ProjectFileDescriptor.cs" />
|
||||||
|
<Compile Include="Environment\Extensions\Compilers\IProjectFileParser.cs" />
|
||||||
|
<Compile Include="Environment\IOrchardHostContainer.cs" />
|
||||||
|
<Compile Include="Environment\IShim.cs" />
|
||||||
|
<Compile Include="Environment\OrchardHostContainerRegistry.cs" />
|
||||||
<Compile Include="Environment\DefaultOrchardShell.cs" />
|
<Compile Include="Environment\DefaultOrchardShell.cs" />
|
||||||
<Compile Include="Environment\Extensions\ExtensionLoaderCoordinator.cs" />
|
<Compile Include="Environment\Extensions\ExtensionLoaderCoordinator.cs" />
|
||||||
<Compile Include="Environment\Extensions\ExtensionLoadingContext.cs" />
|
<Compile Include="Environment\Extensions\ExtensionLoadingContext.cs" />
|
||||||
@@ -371,11 +379,11 @@
|
|||||||
<Compile Include="FileSystems\VirtualPath\IVirtualPathMonitor.cs" />
|
<Compile Include="FileSystems\VirtualPath\IVirtualPathMonitor.cs" />
|
||||||
<Compile Include="FileSystems\Dependencies\IDependenciesFolder.cs" />
|
<Compile Include="FileSystems\Dependencies\IDependenciesFolder.cs" />
|
||||||
<Compile Include="Environment\Extensions\Loaders\ProbingExtensionLoader.cs" />
|
<Compile Include="Environment\Extensions\Loaders\ProbingExtensionLoader.cs" />
|
||||||
<Compile Include="Environment\Extensions\Compilers\CSharpExtensionBuildProvider.cs" />
|
<Compile Include="Environment\Extensions\Compilers\IExtensionCompiler.cs" />
|
||||||
<Compile Include="Environment\Extensions\Compilers\CSharpExtensionCompiler.cs" />
|
<Compile Include="Environment\Extensions\Compilers\CSharpExtensionDirectoryCompiler.cs" />
|
||||||
<Compile Include="Environment\Extensions\Compilers\CSharpProjectMediumTrustCompiler.cs" />
|
<Compile Include="Environment\Extensions\Compilers\DefaultExtensionCompiler.cs" />
|
||||||
<Compile Include="Environment\Extensions\Compilers\CSharpProjectFullTrustCompiler.cs" />
|
<Compile Include="Environment\Extensions\Compilers\CSharpProjectFullTrustCompiler.cs" />
|
||||||
<Compile Include="Environment\Extensions\Compilers\CSharpProjectParser.cs" />
|
<Compile Include="Environment\Extensions\Compilers\DefaultProjectFileParser.cs" />
|
||||||
<Compile Include="Environment\IAssemblyBuilder.cs" />
|
<Compile Include="Environment\IAssemblyBuilder.cs" />
|
||||||
<Compile Include="Environment\IBuildManager.cs" />
|
<Compile Include="Environment\IBuildManager.cs" />
|
||||||
<Compile Include="FileSystems\VirtualPath\IVirtualPathProvider.cs" />
|
<Compile Include="FileSystems\VirtualPath\IVirtualPathProvider.cs" />
|
||||||
@@ -560,7 +568,6 @@
|
|||||||
<Compile Include="Localization\Localizer.cs" />
|
<Compile Include="Localization\Localizer.cs" />
|
||||||
<Compile Include="Localization\LocalizedString.cs" />
|
<Compile Include="Localization\LocalizedString.cs" />
|
||||||
<Compile Include="Localization\NullLocalizer.cs" />
|
<Compile Include="Localization\NullLocalizer.cs" />
|
||||||
<Compile Include="Environment\ServiceLocator.cs" />
|
|
||||||
<Compile Include="Logging\CastleLogger.cs" />
|
<Compile Include="Logging\CastleLogger.cs" />
|
||||||
<Compile Include="Logging\CastleLoggerFactory.cs" />
|
<Compile Include="Logging\CastleLoggerFactory.cs" />
|
||||||
<Compile Include="Logging\ILogger.cs" />
|
<Compile Include="Logging\ILogger.cs" />
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Orchard.Security.Providers {
|
|||||||
public class OrchardMembershipProvider : MembershipProvider {
|
public class OrchardMembershipProvider : MembershipProvider {
|
||||||
|
|
||||||
static IMembershipService GetService() {
|
static IMembershipService GetService() {
|
||||||
return ServiceLocator.Resolve<IMembershipService>();
|
throw new NotImplementedException("The OrchardMemberShipProvider is not supported anymore. Use the IMembershipService interface instead.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static MembershipSettings GetSettings() {
|
static MembershipSettings GetSettings() {
|
||||||
|
|||||||
Reference in New Issue
Block a user