mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
Medium Trust: changing usage of autofac metadata to avoid MEF security exception
--HG-- branch : dev
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
using Autofac.Core;
|
||||
|
||||
|
@@ -9,16 +9,12 @@ using Orchard.Utility;
|
||||
|
||||
namespace Orchard.DisplayManagement.Descriptors {
|
||||
|
||||
public interface IFeatureMetadata {
|
||||
Feature Feature { get; }
|
||||
}
|
||||
|
||||
public class DefaultShapeTableManager : IShapeTableManager {
|
||||
private readonly IEnumerable<Meta<IShapeTableProvider, IFeatureMetadata>> _bindingStrategies;
|
||||
private readonly IEnumerable<Meta<IShapeTableProvider>> _bindingStrategies;
|
||||
private readonly IExtensionManager _extensionManager;
|
||||
|
||||
public DefaultShapeTableManager(
|
||||
IEnumerable<Meta<IShapeTableProvider, IFeatureMetadata>> bindingStrategies,
|
||||
IEnumerable<Meta<IShapeTableProvider>> bindingStrategies,
|
||||
IExtensionManager extensionManager) {
|
||||
_extensionManager = extensionManager;
|
||||
_bindingStrategies = bindingStrategies;
|
||||
@@ -30,7 +26,10 @@ namespace Orchard.DisplayManagement.Descriptors {
|
||||
return _tables.GetOrAdd(themeName ?? "", x => {
|
||||
var builderFactory = new ShapeTableBuilderFactory();
|
||||
foreach (var bindingStrategy in _bindingStrategies) {
|
||||
var strategyDefaultFeature = bindingStrategy.Metadata.Feature;
|
||||
Feature strategyDefaultFeature = bindingStrategy.Metadata.ContainsKey("Feature") ?
|
||||
(Feature) bindingStrategy.Metadata["Feature"] :
|
||||
null;
|
||||
|
||||
var builder = builderFactory.CreateTableBuilder(strategyDefaultFeature);
|
||||
bindingStrategy.Value.Discover(builder);
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ namespace Orchard.Environment.AutofacUtil {
|
||||
get { return _lifetimeScope.ComponentRegistry; }
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
public void Dispose() {
|
||||
}
|
||||
|
||||
public ILifetimeScope BeginLifetimeScope() {
|
||||
|
@@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Web;
|
||||
using Autofac.Features.Metadata;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.Environment.Extensions.Models;
|
||||
|
||||
namespace Orchard.UI.Resources {
|
||||
public class ResourceManager : IResourceManager {
|
||||
@@ -14,7 +15,7 @@ namespace Orchard.UI.Resources {
|
||||
private readonly List<LinkEntry> _links = new List<LinkEntry>();
|
||||
private readonly Dictionary<string, MetaEntry> _metas = new Dictionary<string, MetaEntry>();
|
||||
private readonly Dictionary<string, IList<ResourceRequiredContext>> _builtResources = new Dictionary<string, IList<ResourceRequiredContext>>(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly IEnumerable<Meta<IResourceManifestProvider, IFeatureMetadata>> _providers;
|
||||
private readonly IEnumerable<Meta<IResourceManifestProvider>> _providers;
|
||||
private ResourceManifest _dynamicManifest;
|
||||
private List<String> _headScripts;
|
||||
private List<String> _footScripts;
|
||||
@@ -31,7 +32,7 @@ namespace Orchard.UI.Resources {
|
||||
return resourcePath;
|
||||
}
|
||||
|
||||
public ResourceManager(IEnumerable<Meta<IResourceManifestProvider, IFeatureMetadata>> resourceProviders) {
|
||||
public ResourceManager(IEnumerable<Meta<IResourceManifestProvider>> resourceProviders) {
|
||||
_providers = resourceProviders;
|
||||
}
|
||||
|
||||
@@ -40,7 +41,9 @@ namespace Orchard.UI.Resources {
|
||||
if (_manifests == null) {
|
||||
var builder = new ResourceManifestBuilder();
|
||||
foreach (var provider in _providers) {
|
||||
builder.Feature = provider.Metadata.Feature;
|
||||
builder.Feature = provider.Metadata.ContainsKey("Feature") ?
|
||||
(Feature) provider.Metadata["Feature"] :
|
||||
null;
|
||||
provider.Value.BuildManifests(builder);
|
||||
}
|
||||
_manifests = builder.ResourceManifests;
|
||||
|
Reference in New Issue
Block a user