mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -191,7 +191,7 @@ Features:
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> GetFileDependencies(DependencyDescriptor dependency, string virtualPath) {
|
public IEnumerable<string> GetDynamicModuleDependencies(DependencyDescriptor dependency, string virtualPath) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ using System.IO;
|
|||||||
using System.IO.Packaging;
|
using System.IO.Packaging;
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using Orchard.Environment;
|
||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
|
using Orchard.FileSystems.VirtualPath;
|
||||||
using Orchard.FileSystems.WebSite;
|
using Orchard.FileSystems.WebSite;
|
||||||
using Orchard.Packaging.Services;
|
using Orchard.Packaging.Services;
|
||||||
using Orchard.Tests.Stubs;
|
using Orchard.Tests.Stubs;
|
||||||
@@ -15,6 +17,8 @@ namespace Orchard.Tests.Modules.Packaging.Services {
|
|||||||
|
|
||||||
protected override void Register(ContainerBuilder builder) {
|
protected override void Register(ContainerBuilder builder) {
|
||||||
builder.RegisterType<PackageBuilder>().As<IPackageBuilder>();
|
builder.RegisterType<PackageBuilder>().As<IPackageBuilder>();
|
||||||
|
builder.RegisterType<DefaultVirtualPathProvider>().As<IVirtualPathProvider>();
|
||||||
|
builder.RegisterType<DefaultOrchardFrameworkAssemblies>().As<IOrchardFrameworkAssemblies>();
|
||||||
builder.RegisterType<InMemoryWebSiteFolder>().As<IWebSiteFolder>()
|
builder.RegisterType<InMemoryWebSiteFolder>().As<IWebSiteFolder>()
|
||||||
.As<InMemoryWebSiteFolder>().InstancePerLifetimeScope();
|
.As<InMemoryWebSiteFolder>().InstancePerLifetimeScope();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,13 +313,13 @@ namespace Orchard.Tests.Environment {
|
|||||||
Assert.That(blueprint.Dependencies.FirstOrDefault(dependency => dependency.Type.Equals(typeof(StubNestedType))), Is.Not.Null);
|
Assert.That(blueprint.Dependencies.FirstOrDefault(dependency => dependency.Type.Equals(typeof(StubNestedType))), Is.Not.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[OrchardDependencyReplace("Orchard.Tests.Environment.DefaultCompositionStrategyTests+ReplacedStubNestedType")]
|
[OrchardSuppressDependency("Orchard.Tests.Environment.DefaultCompositionStrategyTests+ReplacedStubNestedType")]
|
||||||
internal class StubNestedType : IDependency {}
|
internal class StubNestedType : IDependency {}
|
||||||
|
|
||||||
internal class ReplacedStubNestedType : IDependency {}
|
internal class ReplacedStubNestedType : IDependency {}
|
||||||
}
|
}
|
||||||
|
|
||||||
[OrchardDependencyReplace("Orchard.Tests.Environment.ReplacedStubType")]
|
[OrchardSuppressDependency("Orchard.Tests.Environment.ReplacedStubType")]
|
||||||
internal class StubType : IDependency { }
|
internal class StubType : IDependency { }
|
||||||
|
|
||||||
internal class ReplacedStubType : IDependency { }
|
internal class ReplacedStubType : IDependency { }
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace Orchard.Tests.Environment.Extensions {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> GetFileDependencies(DependencyDescriptor dependency, string virtualPath) {
|
public IEnumerable<string> GetDynamicModuleDependencies(DependencyDescriptor dependency, string virtualPath) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace Orchard.Tests.Environment.Extensions {
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> GetFileDependencies(DependencyDescriptor dependency, string virtualPath) {
|
public IEnumerable<string> GetDynamicModuleDependencies(DependencyDescriptor dependency, string virtualPath) {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace Orchard.Core.Containers.Drivers {
|
|||||||
var commonPart = part.As<ICommonPart>();
|
var commonPart = part.As<ICommonPart>();
|
||||||
|
|
||||||
var model = new ContainableViewModel();
|
var model = new ContainableViewModel();
|
||||||
if (commonPart.Container != null) {
|
if (commonPart != null && commonPart.Container != null) {
|
||||||
model.ContainerId = commonPart.Container.Id;
|
model.ContainerId = commonPart.Container.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,9 @@ namespace Orchard.Core.Containers.Drivers {
|
|||||||
var oldContainerId = model.ContainerId;
|
var oldContainerId = model.ContainerId;
|
||||||
updater.TryUpdateModel(model, "Containable", null, null);
|
updater.TryUpdateModel(model, "Containable", null, null);
|
||||||
if (oldContainerId != model.ContainerId)
|
if (oldContainerId != model.ContainerId)
|
||||||
commonPart.Container = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
|
if (commonPart != null) {
|
||||||
|
commonPart.Container = _contentManager.Get(model.ContainerId, VersionOptions.Latest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: string.isnullorempty not being recognized by linq-to-nhibernate hence the inline or
|
// note: string.isnullorempty not being recognized by linq-to-nhibernate hence the inline or
|
||||||
|
|||||||
@@ -62,19 +62,15 @@ namespace Orchard.DesignerTools.Services {
|
|||||||
private void DumpValue(object o, string name) {
|
private void DumpValue(object o, string name) {
|
||||||
string formatted = FormatValue(o);
|
string formatted = FormatValue(o);
|
||||||
_node.Add(
|
_node.Add(
|
||||||
new XElement("h3",
|
new XElement("div", new XAttribute("class", "name"), name),
|
||||||
new XElement("div", new XAttribute("class", "name"), name),
|
new XElement("div", new XAttribute("class", "value"), formatted)
|
||||||
new XElement("div", new XAttribute("class", "value"), formatted)
|
);
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DumpObject(object o, string name) {
|
private void DumpObject(object o, string name) {
|
||||||
_node.Add(
|
_node.Add(
|
||||||
new XElement("h3",
|
new XElement("div", new XAttribute("class", "name"), name),
|
||||||
new XElement("div", new XAttribute("class", "name"), name),
|
new XElement("div", new XAttribute("class", "type"), FormatType(o.GetType()))
|
||||||
new XElement("div", new XAttribute("class", "type"), FormatType(o.GetType()))
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (_parents.Count >= _levels) {
|
if (_parents.Count >= _levels) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Orchard.Caching;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
using Orchard.Environment.Descriptor;
|
using Orchard.Environment.Descriptor;
|
||||||
@@ -16,19 +17,23 @@ namespace Orchard.Modules.Services {
|
|||||||
private readonly IVirtualPathProvider _virtualPathProvider;
|
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||||
private readonly IExtensionManager _extensionManager;
|
private readonly IExtensionManager _extensionManager;
|
||||||
private readonly IShellDescriptorManager _shellDescriptorManager;
|
private readonly IShellDescriptorManager _shellDescriptorManager;
|
||||||
|
private readonly ICacheManager _cacheManager;
|
||||||
|
|
||||||
public ModuleService(
|
public ModuleService(
|
||||||
IFeatureManager featureManager,
|
IFeatureManager featureManager,
|
||||||
IOrchardServices orchardServices,
|
IOrchardServices orchardServices,
|
||||||
IVirtualPathProvider virtualPathProvider,
|
IVirtualPathProvider virtualPathProvider,
|
||||||
IExtensionManager extensionManager,
|
IExtensionManager extensionManager,
|
||||||
IShellDescriptorManager shellDescriptorManager) {
|
IShellDescriptorManager shellDescriptorManager,
|
||||||
|
ICacheManager cacheManager) {
|
||||||
|
|
||||||
Services = orchardServices;
|
Services = orchardServices;
|
||||||
|
|
||||||
_featureManager = featureManager;
|
_featureManager = featureManager;
|
||||||
_virtualPathProvider = virtualPathProvider;
|
_virtualPathProvider = virtualPathProvider;
|
||||||
_extensionManager = extensionManager;
|
_extensionManager = extensionManager;
|
||||||
_shellDescriptorManager = shellDescriptorManager;
|
_shellDescriptorManager = shellDescriptorManager;
|
||||||
|
_cacheManager = cacheManager;
|
||||||
|
|
||||||
if (_featureManager.FeatureDependencyNotification == null) {
|
if (_featureManager.FeatureDependencyNotification == null) {
|
||||||
_featureManager.FeatureDependencyNotification = GenerateWarning;
|
_featureManager.FeatureDependencyNotification = GenerateWarning;
|
||||||
@@ -95,13 +100,17 @@ namespace Orchard.Modules.Services {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="extensionDescriptor">The extension descriptor.</param>
|
/// <param name="extensionDescriptor">The extension descriptor.</param>
|
||||||
public bool IsRecentlyInstalled(ExtensionDescriptor extensionDescriptor) {
|
public bool IsRecentlyInstalled(ExtensionDescriptor extensionDescriptor) {
|
||||||
string projectFile = GetManifestPath(extensionDescriptor);
|
DateTime lastWrittenUtc = _cacheManager.Get(extensionDescriptor, descriptor => {
|
||||||
if (!string.IsNullOrEmpty(projectFile)) {
|
string projectFile = GetManifestPath(extensionDescriptor);
|
||||||
// If project file was modified less than 24 hours ago, the module was recently deployed
|
if (!string.IsNullOrEmpty(projectFile)) {
|
||||||
return DateTime.UtcNow.Subtract(_virtualPathProvider.GetFileLastWriteTimeUtc(projectFile)) < new TimeSpan(1, 0, 0, 0);
|
// If project file was modified less than 24 hours ago, the module was recently deployed
|
||||||
}
|
return _virtualPathProvider.GetFileLastWriteTimeUtc(projectFile);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return DateTime.UtcNow;
|
||||||
|
});
|
||||||
|
|
||||||
|
return DateTime.UtcNow.Subtract(lastWrittenUtc) < new TimeSpan(1, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -126,6 +135,23 @@ namespace Orchard.Modules.Services {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateWarning(string messageFormat, string featureName, IEnumerable<string> featuresInQuestion) {␍ if (featuresInQuestion.Count() < 1)␍ return;␍␍ Services.Notifier.Warning(T(␍ messageFormat,␍ featureName,␍ featuresInQuestion.Count() > 1␍ ? string.Join("",␍ featuresInQuestion.Select(␍ (fn, i) =>␍ T(i == featuresInQuestion.Count() - 1␍ ? "{0}"␍ : (i == featuresInQuestion.Count() - 2␍ ? "{0} and "␍ : "{0}, "), fn).ToString()).ToArray())␍ : featuresInQuestion.First()));␍ }
|
private void GenerateWarning(string messageFormat, string featureName, IEnumerable<string> featuresInQuestion) {
|
||||||
|
if (featuresInQuestion.Count() < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Services.Notifier.Warning(T(
|
||||||
|
messageFormat,
|
||||||
|
featureName,
|
||||||
|
featuresInQuestion.Count() > 1
|
||||||
|
? string.Join("",
|
||||||
|
featuresInQuestion.Select(
|
||||||
|
(fn, i) =>
|
||||||
|
T(i == featuresInQuestion.Count() - 1
|
||||||
|
? "{0}"
|
||||||
|
: (i == featuresInQuestion.Count() - 2
|
||||||
|
? "{0} and "
|
||||||
|
: "{0}, "), fn).ToString()).ToArray())
|
||||||
|
: featuresInQuestion.First()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,16 +6,20 @@ using System.Net.Mime;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using NuGet;
|
using NuGet;
|
||||||
|
using Orchard.Environment;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
|
using Orchard.FileSystems.VirtualPath;
|
||||||
using Orchard.FileSystems.WebSite;
|
using Orchard.FileSystems.WebSite;
|
||||||
|
using Orchard.Utility.Extensions;
|
||||||
using NuGetPackageBuilder = NuGet.PackageBuilder;
|
using NuGetPackageBuilder = NuGet.PackageBuilder;
|
||||||
|
|
||||||
namespace Orchard.Packaging.Services {
|
namespace Orchard.Packaging.Services {
|
||||||
[OrchardFeature("PackagingServices")]
|
[OrchardFeature("PackagingServices")]
|
||||||
public class PackageBuilder : IPackageBuilder {
|
public class PackageBuilder : IPackageBuilder {
|
||||||
private readonly IWebSiteFolder _webSiteFolder;
|
private readonly IWebSiteFolder _webSiteFolder;
|
||||||
|
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||||
|
private readonly IOrchardFrameworkAssemblies _frameworkAssemblies;
|
||||||
|
|
||||||
private static readonly string[] _ignoredThemeExtensions = new[] {
|
private static readonly string[] _ignoredThemeExtensions = new[] {
|
||||||
"obj", "pdb", "exclude"
|
"obj", "pdb", "exclude"
|
||||||
@@ -31,8 +35,13 @@ namespace Orchard.Packaging.Services {
|
|||||||
_ignoredThemeExtensions.Contains(Path.GetExtension(filePath) ?? "");
|
_ignoredThemeExtensions.Contains(Path.GetExtension(filePath) ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public PackageBuilder(IWebSiteFolder webSiteFolder) {
|
public PackageBuilder(IWebSiteFolder webSiteFolder,
|
||||||
|
IVirtualPathProvider virtualPathProvider,
|
||||||
|
IOrchardFrameworkAssemblies frameworkAssemblies) {
|
||||||
|
|
||||||
_webSiteFolder = webSiteFolder;
|
_webSiteFolder = webSiteFolder;
|
||||||
|
_virtualPathProvider = virtualPathProvider;
|
||||||
|
_frameworkAssemblies = frameworkAssemblies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream BuildPackage(ExtensionDescriptor extensionDescriptor) {
|
public Stream BuildPackage(ExtensionDescriptor extensionDescriptor) {
|
||||||
@@ -95,7 +104,7 @@ namespace Orchard.Packaging.Services {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EmbedReferenceFiles(CreateContext context) {
|
private void EmbedReferenceFiles(CreateContext context) {
|
||||||
var entries = context.Project
|
var entries = context.Project
|
||||||
.Elements(Ns("Project"))
|
.Elements(Ns("Project"))
|
||||||
.Elements(Ns("ItemGroup"))
|
.Elements(Ns("ItemGroup"))
|
||||||
@@ -108,13 +117,15 @@ namespace Orchard.Packaging.Services {
|
|||||||
|
|
||||||
foreach (var entry in entries) {
|
foreach (var entry in entries) {
|
||||||
var assemblyName = new AssemblyName(entry.Include.Value);
|
var assemblyName = new AssemblyName(entry.Include.Value);
|
||||||
string hintPath = entry.HintPath != null ? entry.HintPath.Value : null;
|
|
||||||
|
|
||||||
string virtualPath = "bin/" + assemblyName.Name + ".dll";
|
// If it is not a core assembly
|
||||||
if (context.SourceFolder.FileExists(context.SourcePath + virtualPath)) {
|
if (_frameworkAssemblies.GetFrameworkAssemblies().FirstOrDefault(assembly => assembly.Name.Equals(assemblyName.Name)) == null) {
|
||||||
EmbedVirtualFile(context, virtualPath, MediaTypeNames.Application.Octet);
|
string virtualPath = _virtualPathProvider.GetReferenceVirtualPath(context.SourcePath, assemblyName.Name, entry.HintPath != null ? entry.HintPath.Value : null);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(virtualPath)) {
|
||||||
|
EmbedVirtualFile(context, virtualPath, MediaTypeNames.Application.Octet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (hintPath != null) { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Orchard.Caching;
|
||||||
using Orchard.Environment.Extensions;
|
using Orchard.Environment.Extensions;
|
||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
using Orchard.Environment.Features;
|
using Orchard.Environment.Features;
|
||||||
@@ -17,16 +18,20 @@ namespace Orchard.Themes.Services {
|
|||||||
private readonly IFeatureManager _featureManager;
|
private readonly IFeatureManager _featureManager;
|
||||||
private readonly IEnumerable<IThemeSelector> _themeSelectors;
|
private readonly IEnumerable<IThemeSelector> _themeSelectors;
|
||||||
private readonly IVirtualPathProvider _virtualPathProvider;
|
private readonly IVirtualPathProvider _virtualPathProvider;
|
||||||
|
private readonly ICacheManager _cacheManager;
|
||||||
|
|
||||||
public ThemeService(
|
public ThemeService(
|
||||||
IExtensionManager extensionManager,
|
IExtensionManager extensionManager,
|
||||||
IFeatureManager featureManager,
|
IFeatureManager featureManager,
|
||||||
IEnumerable<IThemeSelector> themeSelectors,
|
IEnumerable<IThemeSelector> themeSelectors,
|
||||||
IVirtualPathProvider virtualPathProvider) {
|
IVirtualPathProvider virtualPathProvider,
|
||||||
|
ICacheManager cacheManager) {
|
||||||
|
|
||||||
_extensionManager = extensionManager;
|
_extensionManager = extensionManager;
|
||||||
_featureManager = featureManager;
|
_featureManager = featureManager;
|
||||||
_themeSelectors = themeSelectors;
|
_themeSelectors = themeSelectors;
|
||||||
_virtualPathProvider = virtualPathProvider;
|
_virtualPathProvider = virtualPathProvider;
|
||||||
|
_cacheManager = cacheManager;
|
||||||
|
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
@@ -116,15 +121,19 @@ namespace Orchard.Themes.Services {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if a theme was recently installed by using the project's last written time.
|
/// Determines if a theme was recently installed by using the project's last written time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="descriptor">The extension descriptor.</param>
|
/// <param name="extensionDescriptor">The extension descriptor.</param>
|
||||||
public bool IsRecentlyInstalled(ExtensionDescriptor descriptor) {
|
public bool IsRecentlyInstalled(ExtensionDescriptor extensionDescriptor) {
|
||||||
string projectFile = GetManifestPath(descriptor);
|
DateTime lastWrittenUtc = _cacheManager.Get(extensionDescriptor, descriptor => {
|
||||||
if (!string.IsNullOrEmpty(projectFile)) {
|
string projectFile = GetManifestPath(extensionDescriptor);
|
||||||
// If project file was modified less than 24 hours ago, the module was recently deployed
|
if (!string.IsNullOrEmpty(projectFile)) {
|
||||||
return DateTime.UtcNow.Subtract(_virtualPathProvider.GetFileLastWriteTimeUtc(projectFile)) < new TimeSpan(1, 0, 0, 0);
|
// If project file was modified less than 24 hours ago, the module was recently deployed
|
||||||
}
|
return _virtualPathProvider.GetFileLastWriteTimeUtc(projectFile);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return DateTime.UtcNow;
|
||||||
|
});
|
||||||
|
|
||||||
|
return DateTime.UtcNow.Subtract(lastWrittenUtc) < new TimeSpan(1, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetManifestPath(ExtensionDescriptor descriptor) {
|
private string GetManifestPath(ExtensionDescriptor descriptor) {
|
||||||
|
|||||||
@@ -39,15 +39,33 @@ namespace Orchard.Environment.Extensions.Compilers {
|
|||||||
.Elements(ns("Project"))
|
.Elements(ns("Project"))
|
||||||
.Elements(ns("ItemGroup"))
|
.Elements(ns("ItemGroup"))
|
||||||
.Elements(ns("Reference"))
|
.Elements(ns("Reference"))
|
||||||
.Attributes("Include")
|
.Where(c => c.Attribute("Include") != null)
|
||||||
.Select(c => new ReferenceDescriptor { SimpleName = ExtractAssemblyName(c.Value), FullName = c.Value });
|
.Select(c => {
|
||||||
|
string path = null;
|
||||||
|
XElement attribute = c.Elements(ns("HintPath")).FirstOrDefault();
|
||||||
|
if (attribute != null) {
|
||||||
|
path = attribute.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ReferenceDescriptor {
|
||||||
|
SimpleName = ExtractAssemblyName(c.Attribute("Include").Value),
|
||||||
|
FullName = c.Attribute("Include").Value,
|
||||||
|
Path = path,
|
||||||
|
ReferenceType = ReferenceType.Library
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
var projectReferences = document
|
var projectReferences = document
|
||||||
.Elements(ns("Project"))
|
.Elements(ns("Project"))
|
||||||
.Elements(ns("ItemGroup"))
|
.Elements(ns("ItemGroup"))
|
||||||
.Elements(ns("ProjectReference"))
|
.Elements(ns("ProjectReference"))
|
||||||
.Attributes("Include")
|
.Attributes("Include")
|
||||||
.Select(c => new ReferenceDescriptor { SimpleName = Path.GetFileNameWithoutExtension(c.Value), FullName = Path.GetFileNameWithoutExtension(c.Value) });
|
.Select(c => new ReferenceDescriptor {
|
||||||
|
SimpleName = Path.GetFileNameWithoutExtension(c.Value),
|
||||||
|
FullName = Path.GetFileNameWithoutExtension(c.Value),
|
||||||
|
Path = c.Value,
|
||||||
|
ReferenceType = ReferenceType.Project
|
||||||
|
});
|
||||||
|
|
||||||
return assemblyReferences.Union(projectReferences);
|
return assemblyReferences.Union(projectReferences);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Orchard.Environment.Extensions.Compilers {
|
namespace Orchard.Environment.Extensions.Compilers {
|
||||||
|
public enum ReferenceType {
|
||||||
|
Library,
|
||||||
|
Project
|
||||||
|
}
|
||||||
|
|
||||||
public class ProjectFileDescriptor {
|
public class ProjectFileDescriptor {
|
||||||
public string AssemblyName { get; set; }
|
public string AssemblyName { get; set; }
|
||||||
public IEnumerable<string> SourceFilenames { get; set; }
|
public IEnumerable<string> SourceFilenames { get; set; }
|
||||||
@@ -9,5 +14,7 @@ namespace Orchard.Environment.Extensions.Compilers {
|
|||||||
public class ReferenceDescriptor {
|
public class ReferenceDescriptor {
|
||||||
public string SimpleName { get; set; }
|
public string SimpleName { get; set; }
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
|
public string Path { get; set; }
|
||||||
|
public ReferenceType ReferenceType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ namespace Orchard.Environment.Extensions {
|
|||||||
availableExtensions.OrderByDependenciesAndPriorities(
|
availableExtensions.OrderByDependenciesAndPriorities(
|
||||||
(item, dep) => referencesByModule.ContainsKey(item.Id) &&
|
(item, dep) => referencesByModule.ContainsKey(item.Id) &&
|
||||||
referencesByModule[item.Id].Any(r => StringComparer.OrdinalIgnoreCase.Equals(dep.Id, r.Name)),
|
referencesByModule[item.Id].Any(r => StringComparer.OrdinalIgnoreCase.Equals(dep.Id, r.Name)),
|
||||||
(item) => item.Priority)
|
(item) => 0)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
return new ExtensionLoadingContext {
|
return new ExtensionLoadingContext {
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ namespace Orchard.Environment.Extensions.Folders {
|
|||||||
AntiForgery = GetValue(manifest, "AntiForgery"),
|
AntiForgery = GetValue(manifest, "AntiForgery"),
|
||||||
Zones = GetValue(manifest, "Zones"),
|
Zones = GetValue(manifest, "Zones"),
|
||||||
BaseTheme = GetValue(manifest, "BaseTheme"),
|
BaseTheme = GetValue(manifest, "BaseTheme"),
|
||||||
Priority = int.Parse(GetValue(manifest, "Priority") ?? "0")
|
|
||||||
};
|
};
|
||||||
extensionDescriptor.Features = GetFeaturesForExtension(manifest, extensionDescriptor);
|
extensionDescriptor.Features = GetFeaturesForExtension(manifest, extensionDescriptor);
|
||||||
|
|
||||||
@@ -204,7 +203,7 @@ namespace Orchard.Environment.Extensions.Folders {
|
|||||||
FeatureDescriptor defaultFeature = new FeatureDescriptor {
|
FeatureDescriptor defaultFeature = new FeatureDescriptor {
|
||||||
Id = extensionDescriptor.Id,
|
Id = extensionDescriptor.Id,
|
||||||
Name = extensionDescriptor.Name,
|
Name = extensionDescriptor.Name,
|
||||||
Priority = extensionDescriptor.Priority,
|
Priority = GetValue(manifest, "Priority") != null ? int.Parse(GetValue(manifest, "Priority")) : 0,
|
||||||
Description = GetValue(manifest, "FeatureDescription") ?? GetValue(manifest, "Description") ?? string.Empty,
|
Description = GetValue(manifest, "FeatureDescription") ?? GetValue(manifest, "Description") ?? string.Empty,
|
||||||
Dependencies = ParseFeatureDependenciesEntry(GetValue(manifest, "Dependencies")),
|
Dependencies = ParseFeatureDependenciesEntry(GetValue(manifest, "Dependencies")),
|
||||||
Extension = extensionDescriptor,
|
Extension = extensionDescriptor,
|
||||||
@@ -234,7 +233,6 @@ namespace Orchard.Environment.Extensions.Folders {
|
|||||||
if (featureDescriptorId == extensionDescriptor.Id) {
|
if (featureDescriptorId == extensionDescriptor.Id) {
|
||||||
featureDescriptor = defaultFeature;
|
featureDescriptor = defaultFeature;
|
||||||
featureDescriptor.Name = extensionDescriptor.Name;
|
featureDescriptor.Name = extensionDescriptor.Name;
|
||||||
featureDescriptor.Priority = extensionDescriptor.Priority;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
featureDescriptor = new FeatureDescriptor {
|
featureDescriptor = new FeatureDescriptor {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ using Orchard.Environment.Extensions.Models;
|
|||||||
using Orchard.FileSystems.Dependencies;
|
using Orchard.FileSystems.Dependencies;
|
||||||
using Orchard.FileSystems.VirtualPath;
|
using Orchard.FileSystems.VirtualPath;
|
||||||
using Orchard.Logging;
|
using Orchard.Logging;
|
||||||
|
using Orchard.Utility.Extensions;
|
||||||
|
|
||||||
namespace Orchard.Environment.Extensions.Loaders {
|
namespace Orchard.Environment.Extensions.Loaders {
|
||||||
public class DynamicExtensionLoader : ExtensionLoaderBase {
|
public class DynamicExtensionLoader : ExtensionLoaderBase {
|
||||||
@@ -54,13 +55,13 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
return GetDependencies(dependency.VirtualPath);
|
return GetDependencies(dependency.VirtualPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<string> GetFileDependencies(DependencyDescriptor dependency, string virtualPath){
|
public override IEnumerable<string> GetDynamicModuleDependencies(DependencyDescriptor dependency, string virtualPath) {
|
||||||
virtualPath = _virtualPathProvider.ToAppRelative(virtualPath);
|
virtualPath = _virtualPathProvider.ToAppRelative(virtualPath);
|
||||||
|
|
||||||
if (StringComparer.OrdinalIgnoreCase.Equals(virtualPath, dependency.VirtualPath)) {
|
if (StringComparer.OrdinalIgnoreCase.Equals(virtualPath, dependency.VirtualPath)) {
|
||||||
return GetSourceFiles(virtualPath);
|
return GetDependencies(virtualPath);
|
||||||
}
|
}
|
||||||
return base.GetFileDependencies(dependency, virtualPath);
|
return base.GetDynamicModuleDependencies(dependency, virtualPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Monitor(ExtensionDescriptor descriptor, Action<IVolatileToken> monitor) {
|
public override void Monitor(ExtensionDescriptor descriptor, Action<IVolatileToken> monitor) {
|
||||||
@@ -94,14 +95,14 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
if (projectPath == null)
|
if (projectPath == null)
|
||||||
return Enumerable.Empty<ExtensionReferenceProbeEntry>();
|
return Enumerable.Empty<ExtensionReferenceProbeEntry>();
|
||||||
|
|
||||||
using(var stream = _virtualPathProvider.OpenFile(projectPath)) {
|
using (var stream = _virtualPathProvider.OpenFile(projectPath)) {
|
||||||
var projectFile = _projectFileParser.Parse(stream);
|
var projectFile = _projectFileParser.Parse(stream);
|
||||||
|
|
||||||
return projectFile.References.Select(r => new ExtensionReferenceProbeEntry {
|
return projectFile.References.Select(r => new ExtensionReferenceProbeEntry {
|
||||||
Descriptor = descriptor,
|
Descriptor = descriptor,
|
||||||
Loader = this,
|
Loader = this,
|
||||||
Name = r.SimpleName,
|
Name = r.SimpleName,
|
||||||
VirtualPath = GetReferenceVirtualPath(projectPath, r.SimpleName)
|
VirtualPath = _virtualPathProvider.GetProjectReferenceVirtualPath(projectPath, r.SimpleName, r.Path)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,14 +130,6 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetReferenceVirtualPath(string projectPath, string referenceName) {
|
|
||||||
var path = _virtualPathProvider.GetDirectoryName(projectPath);
|
|
||||||
path = _virtualPathProvider.Combine(path, "bin", referenceName + ".dll");
|
|
||||||
if (_virtualPathProvider.FileExists(path))
|
|
||||||
return path;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Assembly LoadReference(DependencyReferenceDescriptor reference) {
|
public override Assembly LoadReference(DependencyReferenceDescriptor reference) {
|
||||||
// DynamicExtensionLoader has 2 types of references: assemblies from module bin directory
|
// DynamicExtensionLoader has 2 types of references: assemblies from module bin directory
|
||||||
// and .csproj.
|
// and .csproj.
|
||||||
@@ -184,17 +177,33 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> GetDependencies(string projectPath) {
|
private IEnumerable<string> GetDependencies(string projectPath) {
|
||||||
return new[] {projectPath}.Concat(GetSourceFiles(projectPath));
|
List<string> dependencies = new[] { projectPath }.ToList();
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<string> GetSourceFiles(string projectPath) {
|
|
||||||
var basePath = _virtualPathProvider.GetDirectoryName(projectPath);
|
var basePath = _virtualPathProvider.GetDirectoryName(projectPath);
|
||||||
|
|
||||||
using (var stream = _virtualPathProvider.OpenFile(projectPath)) {
|
using (var stream = _virtualPathProvider.OpenFile(projectPath)) {
|
||||||
var projectFile = _projectFileParser.Parse(stream);
|
var projectFile = _projectFileParser.Parse(stream);
|
||||||
|
|
||||||
return projectFile.SourceFilenames.Select(f => _virtualPathProvider.Combine(basePath, f));
|
// Add source files
|
||||||
|
dependencies.AddRange(projectFile.SourceFilenames.Select(f => _virtualPathProvider.Combine(basePath, f)));
|
||||||
|
|
||||||
|
// Add Project and Library References
|
||||||
|
foreach (ReferenceDescriptor referenceDescriptor in projectFile.References.Where(reference => !string.IsNullOrEmpty(reference.Path))) {
|
||||||
|
string path = referenceDescriptor.ReferenceType == ReferenceType.Library
|
||||||
|
? _virtualPathProvider.GetProjectReferenceVirtualPath(projectPath, referenceDescriptor.SimpleName, referenceDescriptor.Path)
|
||||||
|
: _virtualPathProvider.Combine(basePath, referenceDescriptor.Path);
|
||||||
|
|
||||||
|
if (_virtualPathProvider.FileExists(path)) {
|
||||||
|
dependencies.Add(path);
|
||||||
|
|
||||||
|
if (referenceDescriptor.ReferenceType == ReferenceType.Project) {
|
||||||
|
dependencies.AddRange(GetDependencies(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetProjectPath(ExtensionDescriptor descriptor) {
|
private string GetProjectPath(ExtensionDescriptor descriptor) {
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
return Enumerable.Empty<string>();
|
return Enumerable.Empty<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IEnumerable<string> GetFileDependencies(DependencyDescriptor dependency, string virtualPath) {
|
public virtual IEnumerable<string> GetDynamicModuleDependencies(DependencyDescriptor dependency, string virtualPath) {
|
||||||
return Enumerable.Empty<string>();
|
return Enumerable.Empty<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,6 @@ namespace Orchard.Environment.Extensions.Loaders {
|
|||||||
|
|
||||||
string GetWebFormAssemblyDirective(DependencyDescriptor dependency);
|
string GetWebFormAssemblyDirective(DependencyDescriptor dependency);
|
||||||
IEnumerable<string> GetWebFormVirtualDependencies(DependencyDescriptor dependency);
|
IEnumerable<string> GetWebFormVirtualDependencies(DependencyDescriptor dependency);
|
||||||
IEnumerable<string> GetFileDependencies(DependencyDescriptor dependency, string virtualPath);
|
IEnumerable<string> GetDynamicModuleDependencies(DependencyDescriptor dependency, string virtualPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,6 @@ namespace Orchard.Environment.Extensions.Models {
|
|||||||
public string AntiForgery { get; set; }
|
public string AntiForgery { get; set; }
|
||||||
public string Zones { get; set; }
|
public string Zones { get; set; }
|
||||||
public string BaseTheme { get; set; }
|
public string BaseTheme { get; set; }
|
||||||
public int Priority { get; set; }
|
|
||||||
|
|
||||||
public IEnumerable<FeatureDescriptor> Features { get; set; }
|
public IEnumerable<FeatureDescriptor> Features { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace Orchard.Environment.Extensions {
|
namespace Orchard.Environment.Extensions {
|
||||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
|
||||||
public class OrchardDependencyReplaceAttribute : Attribute {
|
public class OrchardSuppressDependencyAttribute : Attribute {
|
||||||
public OrchardDependencyReplaceAttribute(string dependency) {
|
public OrchardSuppressDependencyAttribute(string fullName) {
|
||||||
Dependency = dependency;
|
FullName = fullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Dependency { get; set; }
|
public string FullName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Orchard.Environment {
|
||||||
|
public interface IOrchardFrameworkAssemblies : IDependency {
|
||||||
|
IEnumerable<AssemblyName> GetFrameworkAssemblies();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DefaultOrchardFrameworkAssemblies : IOrchardFrameworkAssemblies {
|
||||||
|
public IEnumerable<AssemblyName> GetFrameworkAssemblies() {
|
||||||
|
return typeof (IDependency).Assembly.GetReferencedAssemblies();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,8 +77,8 @@ namespace Orchard.Environment.ShellBuilders {
|
|||||||
// Identify replaced types
|
// Identify replaced types
|
||||||
foreach(Feature feature in features) {
|
foreach(Feature feature in features) {
|
||||||
foreach (Type type in feature.ExportedTypes) {
|
foreach (Type type in feature.ExportedTypes) {
|
||||||
foreach (OrchardDependencyReplaceAttribute replacedType in type.GetCustomAttributes(typeof(OrchardDependencyReplaceAttribute), false)) {
|
foreach (OrchardSuppressDependencyAttribute replacedType in type.GetCustomAttributes(typeof(OrchardSuppressDependencyAttribute), false)) {
|
||||||
excludedTypes.Add(replacedType.Dependency);
|
excludedTypes.Add(replacedType.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
var loader = _loaders.Where(l => l.Name == desc.LoaderName).FirstOrDefault();
|
var loader = _loaders.Where(l => l.Name == desc.LoaderName).FirstOrDefault();
|
||||||
if (loader != null) {
|
if (loader != null) {
|
||||||
|
|
||||||
var otherDependencies = loader.GetFileDependencies(desc, virtualPath);
|
var otherDependencies = loader.GetDynamicModuleDependencies(desc, virtualPath);
|
||||||
if (otherDependencies.Any()) {
|
if (otherDependencies.Any()) {
|
||||||
|
|
||||||
var allDependencies = virtualPathDependencies.OfType<string>().Concat(otherDependencies);
|
var allDependencies = virtualPathDependencies.OfType<string>().Concat(otherDependencies);
|
||||||
|
|||||||
@@ -58,7 +58,12 @@ namespace Orchard.FileSystems.VirtualPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool FileExists(string virtualPath) {
|
public bool FileExists(string virtualPath) {
|
||||||
return HostingEnvironment.VirtualPathProvider.FileExists(virtualPath);
|
try {
|
||||||
|
return HostingEnvironment.VirtualPathProvider.FileExists(virtualPath);
|
||||||
|
} catch {
|
||||||
|
// Medium Trust or invalid mappings that fall outside the app folder
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DirectoryExists(string virtualPath) {
|
public bool DirectoryExists(string virtualPath) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
using System.Web.Razor.Generator;
|
using System.Web.Razor.Generator;
|
||||||
using System.Web.WebPages.Razor;
|
using System.Web.WebPages.Razor;
|
||||||
using Orchard.Environment;
|
using Orchard.Environment;
|
||||||
@@ -27,7 +29,12 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
private readonly IEnumerable<IExtensionLoader> _loaders;
|
private readonly IEnumerable<IExtensionLoader> _loaders;
|
||||||
private readonly IAssemblyLoader _assemblyLoader;
|
private readonly IAssemblyLoader _assemblyLoader;
|
||||||
|
|
||||||
public DefaultRazorCompilationEvents(IDependenciesFolder dependenciesFolder, IBuildManager buildManager, IEnumerable<IExtensionLoader> loaders, IAssemblyLoader assemblyLoader) {
|
public DefaultRazorCompilationEvents(
|
||||||
|
IDependenciesFolder dependenciesFolder,
|
||||||
|
IBuildManager buildManager,
|
||||||
|
IEnumerable<IExtensionLoader> loaders,
|
||||||
|
IAssemblyLoader assemblyLoader) {
|
||||||
|
|
||||||
_dependenciesFolder = dependenciesFolder;
|
_dependenciesFolder = dependenciesFolder;
|
||||||
_buildManager = buildManager;
|
_buildManager = buildManager;
|
||||||
_loaders = loaders;
|
_loaders = loaders;
|
||||||
@@ -35,8 +42,25 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void CodeGenerationStarted(RazorBuildProvider provider) {
|
public void CodeGenerationStarted(RazorBuildProvider provider) {
|
||||||
var descriptors = _dependenciesFolder.LoadDescriptors();
|
DependencyDescriptor moduleDependencyDescriptor = GetModuleDependencyDescriptor(provider.VirtualPath);
|
||||||
var entries = descriptors
|
|
||||||
|
IEnumerable<DependencyDescriptor> dependencyDescriptors = _dependenciesFolder.LoadDescriptors();
|
||||||
|
List<DependencyDescriptor> filteredDependencyDescriptors;
|
||||||
|
if (moduleDependencyDescriptor != null) {
|
||||||
|
// Add module
|
||||||
|
filteredDependencyDescriptors = new List<DependencyDescriptor> { moduleDependencyDescriptor };
|
||||||
|
|
||||||
|
// Add module's references
|
||||||
|
filteredDependencyDescriptors.AddRange(moduleDependencyDescriptor.References
|
||||||
|
.SelectMany(reference => dependencyDescriptors
|
||||||
|
.Where(dependency => dependency.Name == reference.Name)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Fall back for themes
|
||||||
|
filteredDependencyDescriptors = dependencyDescriptors.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
var entries = filteredDependencyDescriptors
|
||||||
.SelectMany(descriptor => _loaders
|
.SelectMany(descriptor => _loaders
|
||||||
.Where(loader => descriptor.LoaderName == loader.Name)
|
.Where(loader => descriptor.LoaderName == loader.Name)
|
||||||
.Select(loader => new {
|
.Select(loader => new {
|
||||||
@@ -70,6 +94,33 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DependencyDescriptor GetModuleDependencyDescriptor(string virtualPath) {
|
||||||
|
var appRelativePath = VirtualPathUtility.ToAppRelative(virtualPath);
|
||||||
|
var prefix = PrefixMatch(appRelativePath, new [] { "~/Modules/", "~/Core/"});
|
||||||
|
if (prefix == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var moduleName = ModuleMatch(appRelativePath, prefix);
|
||||||
|
if (moduleName == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return _dependenciesFolder.GetDescriptor(moduleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ModuleMatch(string virtualPath, string prefix) {
|
||||||
|
var index = virtualPath.IndexOf('/', prefix.Length, virtualPath.Length - prefix.Length);
|
||||||
|
if (index < 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var moduleName = virtualPath.Substring(prefix.Length, index - prefix.Length);
|
||||||
|
return (string.IsNullOrEmpty(moduleName) ? null : moduleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string PrefixMatch(string virtualPath, params string[] prefixes) {
|
||||||
|
return prefixes
|
||||||
|
.FirstOrDefault(p => virtualPath.StartsWith(p, StringComparison.OrdinalIgnoreCase));
|
||||||
|
}
|
||||||
|
|
||||||
public void CodeGenerationCompleted(RazorBuildProvider provider, CodeGenerationCompleteEventArgs e) {
|
public void CodeGenerationCompleted(RazorBuildProvider provider, CodeGenerationCompleteEventArgs e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,6 +185,7 @@
|
|||||||
<Compile Include="Environment\Features\FeatureManager.cs" />
|
<Compile Include="Environment\Features\FeatureManager.cs" />
|
||||||
<Compile Include="Environment\IAssemblyLoader.cs" />
|
<Compile Include="Environment\IAssemblyLoader.cs" />
|
||||||
<Compile Include="Environment\HostComponentsConfigModule.cs" />
|
<Compile Include="Environment\HostComponentsConfigModule.cs" />
|
||||||
|
<Compile Include="Environment\IOrchardFrameworkAssemblies.cs" />
|
||||||
<Compile Include="Environment\ViewsBackgroundCompilation.cs" />
|
<Compile Include="Environment\ViewsBackgroundCompilation.cs" />
|
||||||
<Compile Include="Environment\Warmup\StartupResult.cs" />
|
<Compile Include="Environment\Warmup\StartupResult.cs" />
|
||||||
<Compile Include="Environment\Warmup\WarmupUtility.cs" />
|
<Compile Include="Environment\Warmup\WarmupUtility.cs" />
|
||||||
@@ -488,6 +489,7 @@
|
|||||||
<Compile Include="Messaging\Services\IMessagingChannel.cs" />
|
<Compile Include="Messaging\Services\IMessagingChannel.cs" />
|
||||||
<Compile Include="IWorkContextAccessor.cs" />
|
<Compile Include="IWorkContextAccessor.cs" />
|
||||||
<Compile Include="Utility\Extensions\ControllerExtensions.cs" />
|
<Compile Include="Utility\Extensions\ControllerExtensions.cs" />
|
||||||
|
<Compile Include="Utility\Extensions\VirtualPathProviderExtensions.cs" />
|
||||||
<Compile Include="Validation\PathValidation.cs" />
|
<Compile Include="Validation\PathValidation.cs" />
|
||||||
<Compile Include="WorkContextExtensions.cs" />
|
<Compile Include="WorkContextExtensions.cs" />
|
||||||
<Compile Include="Mvc\ViewEngines\Razor\RazorCompilationEventsShim.cs" />
|
<Compile Include="Mvc\ViewEngines\Razor\RazorCompilationEventsShim.cs" />
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using Autofac.Features.Metadata;
|
|||||||
using Orchard.Environment.Extensions.Models;
|
using Orchard.Environment.Extensions.Models;
|
||||||
|
|
||||||
namespace Orchard.UI.Resources {
|
namespace Orchard.UI.Resources {
|
||||||
public class ResourceManager : IResourceManager {
|
public class ResourceManager : IResourceManager, IUnitOfWorkDependency {
|
||||||
private readonly Dictionary<Tuple<String, String>, RequireSettings> _required = new Dictionary<Tuple<String, String>, RequireSettings>();
|
private readonly Dictionary<Tuple<String, String>, RequireSettings> _required = new Dictionary<Tuple<String, String>, RequireSettings>();
|
||||||
private readonly List<LinkEntry> _links = new List<LinkEntry>();
|
private readonly List<LinkEntry> _links = new List<LinkEntry>();
|
||||||
private readonly Dictionary<string, MetaEntry> _metas = new Dictionary<string, MetaEntry> {
|
private readonly Dictionary<string, MetaEntry> _metas = new Dictionary<string, MetaEntry> {
|
||||||
@@ -234,11 +234,14 @@ namespace Orchard.UI.Resources {
|
|||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (allResources.Contains(resource)) {
|
// Settings is given so they can cascade down into dependencies. For example, if Foo depends on Bar, and Foo's required
|
||||||
settings = ((RequireSettings) allResources[resource]).Combine(settings);
|
// location is Head, so too should Bar's location.
|
||||||
}
|
// forge the effective require settings for this resource
|
||||||
settings.Type = resource.Type;
|
// (1) If a require exists for the resource, combine with it. Last settings in gets preference for its specified values.
|
||||||
settings.Name = resource.Name;
|
// (2) If no require already exists, form a new settings object based on the given one but with its own type/name.
|
||||||
|
settings = allResources.Contains(resource)
|
||||||
|
? ((RequireSettings)allResources[resource]).Combine(settings)
|
||||||
|
: new RequireSettings { Type = resource.Type, Name = resource.Name }.Combine(settings);
|
||||||
if (resource.Dependencies != null) {
|
if (resource.Dependencies != null) {
|
||||||
var dependencies = from d in resource.Dependencies
|
var dependencies = from d in resource.Dependencies
|
||||||
select FindResource(new RequireSettings { Type = resource.Type, Name = d });
|
select FindResource(new RequireSettings { Type = resource.Type, Name = d });
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using Orchard.FileSystems.VirtualPath;
|
||||||
|
|
||||||
|
namespace Orchard.Utility.Extensions {
|
||||||
|
public static class VirtualPathProviderExtensions {
|
||||||
|
public static string GetProjectReferenceVirtualPath(this IVirtualPathProvider virtualPathProvider, string projectPath, string referenceName, string hintPath) {
|
||||||
|
|
||||||
|
string basePath = virtualPathProvider.GetDirectoryName(projectPath);
|
||||||
|
string virtualPath = virtualPathProvider.GetReferenceVirtualPath(basePath, referenceName, hintPath);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(virtualPath)) {
|
||||||
|
return virtualPathProvider.Combine(basePath, virtualPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetReferenceVirtualPath(this IVirtualPathProvider virtualPathProvider, string basePath, string referenceName, string hintPath) {
|
||||||
|
// Check if hint path is valid
|
||||||
|
if (!string.IsNullOrEmpty(hintPath)) {
|
||||||
|
if (virtualPathProvider.FileExists(virtualPathProvider.Combine(basePath, hintPath)))
|
||||||
|
return hintPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to bin directory
|
||||||
|
string relativePath = virtualPathProvider.Combine("bin", referenceName + ".dll");
|
||||||
|
if (virtualPathProvider.FileExists(virtualPathProvider.Combine(basePath, relativePath)))
|
||||||
|
return relativePath;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user