mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +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.Linq;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Core;
|
using Autofac.Core;
|
||||||
|
|
||||||
|
@@ -9,16 +9,12 @@ using Orchard.Utility;
|
|||||||
|
|
||||||
namespace Orchard.DisplayManagement.Descriptors {
|
namespace Orchard.DisplayManagement.Descriptors {
|
||||||
|
|
||||||
public interface IFeatureMetadata {
|
|
||||||
Feature Feature { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DefaultShapeTableManager : IShapeTableManager {
|
public class DefaultShapeTableManager : IShapeTableManager {
|
||||||
private readonly IEnumerable<Meta<IShapeTableProvider, IFeatureMetadata>> _bindingStrategies;
|
private readonly IEnumerable<Meta<IShapeTableProvider>> _bindingStrategies;
|
||||||
private readonly IExtensionManager _extensionManager;
|
private readonly IExtensionManager _extensionManager;
|
||||||
|
|
||||||
public DefaultShapeTableManager(
|
public DefaultShapeTableManager(
|
||||||
IEnumerable<Meta<IShapeTableProvider, IFeatureMetadata>> bindingStrategies,
|
IEnumerable<Meta<IShapeTableProvider>> bindingStrategies,
|
||||||
IExtensionManager extensionManager) {
|
IExtensionManager extensionManager) {
|
||||||
_extensionManager = extensionManager;
|
_extensionManager = extensionManager;
|
||||||
_bindingStrategies = bindingStrategies;
|
_bindingStrategies = bindingStrategies;
|
||||||
@@ -30,7 +26,10 @@ namespace Orchard.DisplayManagement.Descriptors {
|
|||||||
return _tables.GetOrAdd(themeName ?? "", x => {
|
return _tables.GetOrAdd(themeName ?? "", x => {
|
||||||
var builderFactory = new ShapeTableBuilderFactory();
|
var builderFactory = new ShapeTableBuilderFactory();
|
||||||
foreach (var bindingStrategy in _bindingStrategies) {
|
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);
|
var builder = builderFactory.CreateTableBuilder(strategyDefaultFeature);
|
||||||
bindingStrategy.Value.Discover(builder);
|
bindingStrategy.Value.Discover(builder);
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using System.Web;
|
using System.Web;
|
||||||
using Autofac.Features.Metadata;
|
using Autofac.Features.Metadata;
|
||||||
using Orchard.DisplayManagement.Descriptors;
|
using Orchard.DisplayManagement.Descriptors;
|
||||||
|
using Orchard.Environment.Extensions.Models;
|
||||||
|
|
||||||
namespace Orchard.UI.Resources {
|
namespace Orchard.UI.Resources {
|
||||||
public class ResourceManager : IResourceManager {
|
public class ResourceManager : IResourceManager {
|
||||||
@@ -14,7 +15,7 @@ namespace Orchard.UI.Resources {
|
|||||||
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>();
|
||||||
private readonly Dictionary<string, IList<ResourceRequiredContext>> _builtResources = new Dictionary<string, IList<ResourceRequiredContext>>(StringComparer.OrdinalIgnoreCase);
|
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 ResourceManifest _dynamicManifest;
|
||||||
private List<String> _headScripts;
|
private List<String> _headScripts;
|
||||||
private List<String> _footScripts;
|
private List<String> _footScripts;
|
||||||
@@ -31,7 +32,7 @@ namespace Orchard.UI.Resources {
|
|||||||
return resourcePath;
|
return resourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceManager(IEnumerable<Meta<IResourceManifestProvider, IFeatureMetadata>> resourceProviders) {
|
public ResourceManager(IEnumerable<Meta<IResourceManifestProvider>> resourceProviders) {
|
||||||
_providers = resourceProviders;
|
_providers = resourceProviders;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +41,9 @@ namespace Orchard.UI.Resources {
|
|||||||
if (_manifests == null) {
|
if (_manifests == null) {
|
||||||
var builder = new ResourceManifestBuilder();
|
var builder = new ResourceManifestBuilder();
|
||||||
foreach (var provider in _providers) {
|
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);
|
provider.Value.BuildManifests(builder);
|
||||||
}
|
}
|
||||||
_manifests = builder.ResourceManifests;
|
_manifests = builder.ResourceManifests;
|
||||||
|
Reference in New Issue
Block a user