mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
parent
731b223f82
commit
05079efdd3
18
src/Orchard/Data/MapAsRecordAttribute.cs
Normal file
18
src/Orchard/Data/MapAsRecordAttribute.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
|
||||
namespace Orchard.Data {
|
||||
/// <summary>
|
||||
/// Marks whether a class should be mapped as an NHibernate record
|
||||
/// </summary>
|
||||
public class MapAsRecordAttribute : Attribute {
|
||||
private readonly bool _enabled;
|
||||
|
||||
public MapAsRecordAttribute() : this(true) { }
|
||||
|
||||
public MapAsRecordAttribute(bool enabled) {
|
||||
_enabled = enabled;
|
||||
}
|
||||
|
||||
public bool Enabled => _enabled;
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using System.Web.Mvc;
|
||||
using Autofac.Core;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Environment.Extensions;
|
||||
@ -96,7 +97,7 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
}
|
||||
|
||||
var feature = availableFeatures[shellFeature];
|
||||
|
||||
|
||||
foreach (var childDependency in ExpandDependenciesInternal(availableFeatures, feature.Dependencies, dependentFeatureDescriptor: feature))
|
||||
yield return childDependency;
|
||||
|
||||
@ -197,7 +198,12 @@ namespace Orchard.Environment.ShellBuilders {
|
||||
}
|
||||
|
||||
private static bool IsRecord(Type type) {
|
||||
return ((type.Namespace ?? "").EndsWith(".Models") || (type.Namespace ?? "").EndsWith(".Records")) &&
|
||||
var mapAsRecordAttr = type.GetCustomAttributes(typeof(MapAsRecordAttribute), false)
|
||||
.OfType<MapAsRecordAttribute>()
|
||||
.FirstOrDefault();
|
||||
|
||||
return ((type.Namespace ?? "").EndsWith(".Models") || (type.Namespace ?? "").EndsWith(".Records") || mapAsRecordAttr?.Enabled == true) &&
|
||||
mapAsRecordAttr?.Enabled != false &&
|
||||
type.GetProperty("Id") != null &&
|
||||
(type.GetProperty("Id").GetAccessors()).All(x => x.IsVirtual) &&
|
||||
!type.IsSealed &&
|
||||
|
@ -150,6 +150,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="ContentManagement\Extensions\DriverResultExtensions.cs" />
|
||||
<Compile Include="ContentManagement\Handlers\CloneContentContext.cs" />
|
||||
<Compile Include="Data\MapAsRecordAttribute.cs" />
|
||||
<Compile Include="Data\Migration\Interpreters\PostgreSqlCommandInterpreter.cs" />
|
||||
<Compile Include="DisplayManagement\Descriptors\ShapePlacementStrategy\DefaultPlacementParseMatchProviders.cs" />
|
||||
<Compile Include="DisplayManagement\Descriptors\ShapePlacementStrategy\IPlacementParseMatchProvider.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user