Adding fields to metadata definitions

Refactoring some component and record names
Made content definition model immutable, with builder pattern for creation and alteration
Moving records and storage out of base framework assembly
Splitting into separate ContentTypeRecord and ContentTypeDefinitionRecord
Changing MetaData module's MetaDataController to AdminController
Introduced a ContentHandlerBase : IContentHandler to provide virtual no-op implementation of fairly large interface

--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-06-04 13:37:34 -07:00
parent dcc51f28c6
commit 83f1de1fc9
47 changed files with 1222 additions and 427 deletions

View File

@@ -6,7 +6,6 @@ using JetBrains.Annotations;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.Core.Common; using Orchard.Core.Common;
using Orchard.Core.Common.Handlers; using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
@@ -47,8 +46,6 @@ namespace Orchard.Core.Tests.Common.Providers {
get { get {
return new[] { return new[] {
typeof(ContentTypeRecord), typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
typeof(CommonRecord), typeof(CommonRecord),

View File

@@ -6,7 +6,6 @@ using NUnit.Framework;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Core.Common.Services; using Orchard.Core.Common.Services;
@@ -182,8 +181,6 @@ namespace Orchard.Core.Tests.Common.Services {
return new[] { return new[] {
typeof(RoutableRecord), typeof(RoutableRecord),
typeof(ContentTypeRecord), typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
typeof(CommonRecord), typeof(CommonRecord),

View File

@@ -109,6 +109,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scheduling\ScheduledTaskManagerTests.cs" /> <Compile Include="Scheduling\ScheduledTaskManagerTests.cs" />
<Compile Include="Scheduling\ScheduledTaskExecutorTests.cs" /> <Compile Include="Scheduling\ScheduledTaskExecutorTests.cs" />
<Compile Include="Settings\Metadata\ContentDefinitionManagerTests.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Orchard.Tests.Modules\Orchard.Tests.Modules.csproj"> <ProjectReference Include="..\Orchard.Tests.Modules\Orchard.Tests.Modules.csproj">

View File

@@ -4,7 +4,6 @@ using Autofac;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models; using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services; using Orchard.Core.Scheduling.Services;
@@ -39,8 +38,6 @@ namespace Orchard.Core.Tests.Scheduling {
get { get {
return new[] { return new[] {
typeof(ContentTypeRecord), typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
typeof(ScheduledTaskRecord), typeof(ScheduledTaskRecord),

View File

@@ -5,7 +5,6 @@ using Autofac;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models; using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services; using Orchard.Core.Scheduling.Services;
@@ -42,8 +41,6 @@ namespace Orchard.Core.Tests.Scheduling {
get { get {
return new[] { return new[] {
typeof(ContentTypeRecord), typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
typeof(ScheduledTaskRecord), typeof(ScheduledTaskRecord),

View File

@@ -0,0 +1,211 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Autofac;
using Moq;
using NHibernate;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.Core.Settings.Metadata;
using Orchard.Core.Settings.Metadata.Records;
using Orchard.Data;
using Orchard.Tests;
using Orchard.Tests.Utility;
namespace Orchard.Core.Tests.Settings.Metadata {
[TestFixture]
public class ContentDefinitionManagerTests {
private string _databaseFileName;
private ISessionFactory _sessionFactory;
private ISession _session;
private IContainer _container;
[TestFixtureSetUp]
public void InitFixture() {
_databaseFileName = Path.GetTempFileName();
_sessionFactory = DataUtility.CreateSessionFactory(
_databaseFileName,
typeof(ContentTypeDefinitionRecord),
typeof(ContentTypePartDefinitionRecord),
typeof(ContentPartDefinitionRecord),
typeof(ContentPartFieldDefinitionRecord),
typeof(ContentFieldDefinitionRecord)
);
}
[SetUp]
public void Init() {
var builder = new ContainerBuilder();
builder.RegisterAutoMocking();
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterType(typeof(SettingsFormatter))
.As(typeof(IMapper<XElement, IDictionary<string, string>>))
.As(typeof(IMapper<IDictionary<string, string>, XElement>));
_container = builder.Build();
_container.Mock<ISessionLocator>()
.Setup(x => x.For(It.IsAny<Type>()))
.Returns(() => _session);
_session = _sessionFactory.OpenSession();
foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
foreach (var killRecord in _session.CreateCriteria(killType).List()) {
_session.Delete(killRecord);
}
}
_session.Flush();
}
void ResetSession() {
_session.Flush();
_session.Dispose();
_session = _sessionFactory.OpenSession();
}
[TearDown]
public void Term() {
_session.Dispose();
}
[TestFixtureTearDown]
public void TermFixture() {
File.Delete(_databaseFileName);
}
[Test]
public void NoTypesAreAvailableByDefault() {
var types = _container.Resolve<IContentDefinitionManager>().ListTypeDefinitions();
Assert.That(types.Count(), Is.EqualTo(0));
}
[Test]
public void TypeRecordsAreReturned() {
var repository = _container.Resolve<IRepository<ContentTypeDefinitionRecord>>();
repository.Create(new ContentTypeDefinitionRecord { Name = "alpha" });
repository.Create(new ContentTypeDefinitionRecord { Name = "beta" });
ResetSession();
var types = _container.Resolve<IContentDefinitionManager>().ListTypeDefinitions();
Assert.That(types.Count(), Is.EqualTo(2));
}
[Test]
public void TypeSettingsAreParsed() {
var repository = _container.Resolve<IRepository<ContentTypeDefinitionRecord>>();
repository.Create(new ContentTypeDefinitionRecord { Name = "alpha", Settings = "<settings a='1' b='2'/>" });
ResetSession();
var alpha = _container.Resolve<IContentDefinitionManager>().ListTypeDefinitions().Single();
Assert.That(alpha.Settings["a"], Is.EqualTo("1"));
Assert.That(alpha.Settings["b"], Is.EqualTo("2"));
}
[Test]
public void ContentTypesWithSettingsCanBeCreatedAndModified() {
var manager = _container.Resolve<IContentDefinitionManager>();
manager.StoreTypeDefinition(new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithSetting("a", "1")
.WithSetting("b", "2")
.Build());
manager.StoreTypeDefinition(new ContentTypeDefinitionBuilder()
.Named("beta")
.WithSetting("c", "3")
.WithSetting("d", "4")
.Build());
ResetSession();
var types1 = manager.ListTypeDefinitions();
Assert.That(types1.Count(), Is.EqualTo(2));
var alpha1 = types1.Single(t => t.Name == "alpha");
Assert.That(alpha1.Settings["a"], Is.EqualTo("1"));
manager.StoreTypeDefinition(new ContentTypeDefinitionBuilder(alpha1).WithSetting("a", "5").Build());
ResetSession();
var types2 = manager.ListTypeDefinitions();
Assert.That(types2.Count(), Is.EqualTo(2));
var alpha2 = types2.Single(t => t.Name == "alpha");
Assert.That(alpha2.Settings["a"], Is.EqualTo("5"));
Assert.That(alpha2.Settings["a"], Is.EqualTo("5"));
}
[Test]
public void StubPartDefinitionsAreCreatedWhenContentTypesAreStored() {
var manager = _container.Resolve<IContentDefinitionManager>();
manager.StoreTypeDefinition(new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithPart("foo", pb => { })
.Build());
ResetSession();
var fooRecord = _container.Resolve<IRepository<ContentPartDefinitionRecord>>().Fetch(r => r.Name == "foo").SingleOrDefault();
Assert.That(fooRecord, Is.Not.Null);
Assert.That(fooRecord.Name, Is.EqualTo("foo"));
var foo = manager.GetPartDefinition("foo");
Assert.That(foo, Is.Not.Null);
Assert.That(foo.Name, Is.EqualTo("foo"));
var alpha = manager.GetTypeDefinition("alpha");
Assert.That(alpha, Is.Not.Null);
Assert.That(alpha.Parts.Count(), Is.EqualTo(1));
Assert.That(alpha.Parts.Single().PartDefinition.Name, Is.EqualTo("foo"));
}
[Test]
public void GettingDefinitionsByNameCanReturnNullAndWillAcceptNullEmptyOrInvalidNames() {
var manager = _container.Resolve<IContentDefinitionManager>();
Assert.That(manager.GetTypeDefinition("no such name"), Is.Null);
Assert.That(manager.GetTypeDefinition(string.Empty), Is.Null);
Assert.That(manager.GetTypeDefinition(null), Is.Null);
Assert.That(manager.GetPartDefinition("no such name"), Is.Null);
Assert.That(manager.GetPartDefinition(string.Empty), Is.Null);
Assert.That(manager.GetPartDefinition(null), Is.Null);
}
[Test]
public void PartsAreRemovedWhenNotReferencedButPartDefinitionRemains() {
var manager = _container.Resolve<IContentDefinitionManager>();
manager.StoreTypeDefinition(
new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithPart("foo", pb => { })
.WithPart("bar", pb => { })
.Build());
AssertThatTypeHasParts("alpha","foo","bar");
Assert.That(manager.ListPartDefinitions().Count(), Is.EqualTo(2));
ResetSession();
AssertThatTypeHasParts("alpha","foo","bar");
Assert.That(manager.ListPartDefinitions().Count(), Is.EqualTo(2));
manager.StoreTypeDefinition(
new ContentTypeDefinitionBuilder(manager.GetTypeDefinition("alpha"))
.WithPart("frap", pb => { })
.RemovePart("bar")
.Build());
AssertThatTypeHasParts("alpha","foo","frap");
Assert.That(manager.ListPartDefinitions().Count(), Is.EqualTo(3));
ResetSession();
AssertThatTypeHasParts("alpha","foo","frap");
Assert.That(manager.ListPartDefinitions().Count(), Is.EqualTo(3));
}
private void AssertThatTypeHasParts(string typeName, params string[] partNames) {
var type = _container.Resolve<IContentDefinitionManager>().GetTypeDefinition(typeName);
Assert.That(type, Is.Not.Null);
Assert.That(type.Parts.Count(), Is.EqualTo(partNames.Count()));
foreach(var partName in partNames) {
Assert.That(type.Parts.Select(p=>p.PartDefinition.Name), Has.Some.EqualTo(partName));
}
}
}
}

View File

@@ -6,7 +6,6 @@ using System.Web.Routing;
using Autofac; using Autofac;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data; using Orchard.Data;
using Orchard.Environment; using Orchard.Environment;
using Orchard.ContentManagement; using Orchard.ContentManagement;
@@ -47,8 +46,6 @@ namespace Orchard.Tests.Modules.Users.Controllers {
get { get {
return new[] { typeof(UserRecord), return new[] { typeof(UserRecord),
typeof(ContentTypeRecord), typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
}; };

View File

@@ -3,7 +3,6 @@ using System.Web.Security;
using Autofac; using Autofac;
using NHibernate; using NHibernate;
using NUnit.Framework; using NUnit.Framework;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data; using Orchard.Data;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
@@ -42,9 +41,7 @@ namespace Orchard.Tests.Modules.Users.Services {
typeof(UserRecord), typeof(UserRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentTypeRecord), typeof(ContentTypeRecord));
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord));
} }
[TestFixtureTearDown] [TestFixtureTearDown]

View File

@@ -2,7 +2,6 @@
using Autofac; using Autofac;
using NHibernate; using NHibernate;
using NUnit.Framework; using NUnit.Framework;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data; using Orchard.Data;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
@@ -28,9 +27,7 @@ namespace Orchard.Tests.ContentManagement {
typeof(EpsilonRecord), typeof(EpsilonRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentTypeRecord), typeof(ContentTypeRecord));
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord));
} }
[TestFixtureTearDown] [TestFixtureTearDown]

View File

@@ -1,62 +0,0 @@
using Autofac;
using NHibernate;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Records;
using Orchard.Data;
namespace Orchard.Tests.ContentManagement{
[TestFixture]
public class ContentTypeMetaDataTests
{
private IContainer _container;
private ISessionFactory _sessionFactory;
private ISession _session;
[TestFixtureSetUp]
public void InitFixture()
{
var databaseFileName = System.IO.Path.GetTempFileName();
_sessionFactory = DataUtility.CreateSessionFactory(
databaseFileName,
typeof(ContentTypeRecord),
typeof(ContentItemRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemVersionRecord));
}
[TestFixtureTearDown]
public void TermFixture()
{
}
[SetUp]
public void Init()
{
var builder = new ContainerBuilder();
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<ContentTypeService>().As<IContentTypeService>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
_container = builder.Build();
}
[Test]
public void MapandUnMapContentTypeToContentPart()
{
var contentTypeService = _container.Resolve<IContentTypeService>();
contentTypeService.MapContentTypeToContentPart("foo", "bar");
Assert.IsTrue(contentTypeService.ValidateContentTypeToContentPartMapping("foo","bar"),"Content Type not successfully mapped");
contentTypeService.UnMapContentTypeToContentPart("foo", "bar");
Assert.IsFalse(contentTypeService.ValidateContentTypeToContentPartMapping("foo", "bar"), "Content Type mapping not successfully deleted");
}
}
}

View File

@@ -4,7 +4,6 @@ using System.Linq;
using Autofac; using Autofac;
using NHibernate; using NHibernate;
using NUnit.Framework; using NUnit.Framework;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data; using Orchard.Data;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
@@ -26,8 +25,6 @@ namespace Orchard.Tests.ContentManagement {
_sessionFactory = DataUtility.CreateSessionFactory( _sessionFactory = DataUtility.CreateSessionFactory(
databaseFileName, databaseFileName,
typeof(ContentTypeRecord), typeof(ContentTypeRecord),
typeof(ContentTypePartRecord),
typeof(ContentTypePartNameRecord),
typeof(ContentItemRecord), typeof(ContentItemRecord),
typeof(ContentItemVersionRecord), typeof(ContentItemVersionRecord),
typeof(GammaRecord), typeof(GammaRecord),

View File

@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData.Builders;
namespace Orchard.Tests.ContentManagement.MetaData.Builders {
[TestFixture]
public class ContentTypeDefinitionBuilderTests {
[Test]
public void ContentTypeNameAndSettingsFromScratch() {
var contentTypeDefinition = new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithSetting("a", "1")
.WithSetting("b", "2")
.Build();
Assert.That(contentTypeDefinition.Name, Is.EqualTo("alpha"));
Assert.That(contentTypeDefinition.Settings.Count(), Is.EqualTo(2));
Assert.That(contentTypeDefinition.Settings["a"], Is.EqualTo("1"));
Assert.That(contentTypeDefinition.Settings["b"], Is.EqualTo("2"));
}
[Test]
public void ContentRebuildWithoutModification() {
var contentTypeDefinition1 = new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithSetting("a", "1")
.WithSetting("b", "2")
.Build();
var contentTypeDefinition2 = new ContentTypeDefinitionBuilder(contentTypeDefinition1)
.Build();
Assert.That(contentTypeDefinition1, Is.Not.SameAs(contentTypeDefinition2));
Assert.That(contentTypeDefinition2.Name, Is.EqualTo("alpha"));
Assert.That(contentTypeDefinition2.Settings.Count(), Is.EqualTo(2));
Assert.That(contentTypeDefinition2.Settings["a"], Is.EqualTo("1"));
Assert.That(contentTypeDefinition2.Settings["b"], Is.EqualTo("2"));
}
[Test]
public void ContentRebuildWithModification() {
var contentTypeDefinition1 = new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithSetting("a", "1")
.WithSetting("b", "2")
.Build();
var contentTypeDefinition2 = new ContentTypeDefinitionBuilder(contentTypeDefinition1)
.Named("beta")
.WithSetting("b", "22")
.WithSetting("c", "3")
.Build();
Assert.That(contentTypeDefinition1, Is.Not.SameAs(contentTypeDefinition2));
Assert.That(contentTypeDefinition1.Name, Is.EqualTo("alpha"));
Assert.That(contentTypeDefinition1.Settings.Count(), Is.EqualTo(2));
Assert.That(contentTypeDefinition1.Settings["a"], Is.EqualTo("1"));
Assert.That(contentTypeDefinition1.Settings["b"], Is.EqualTo("2"));
Assert.That(contentTypeDefinition2.Name, Is.EqualTo("beta"));
Assert.That(contentTypeDefinition2.Settings.Count(), Is.EqualTo(3));
Assert.That(contentTypeDefinition2.Settings["a"], Is.EqualTo("1"));
Assert.That(contentTypeDefinition2.Settings["b"], Is.EqualTo("22"));
Assert.That(contentTypeDefinition2.Settings["c"], Is.EqualTo("3"));
}
[Test]
public void AddingPartWithSettings() {
var contentTypeDefinition = new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithSetting("a", "1")
.WithSetting("b", "2")
.WithPart("foo", pb => pb.WithSetting("x", "10").WithSetting("y", "11"))
.Build();
Assert.That(contentTypeDefinition.Name, Is.EqualTo("alpha"));
Assert.That(contentTypeDefinition.Parts.Count(), Is.EqualTo(1));
Assert.That(contentTypeDefinition.Parts.Single().PartDefinition.Name, Is.EqualTo("foo"));
Assert.That(contentTypeDefinition.Parts.Single().Settings.Count(), Is.EqualTo(2));
Assert.That(contentTypeDefinition.Parts.Single().Settings["x"], Is.EqualTo("10"));
Assert.That(contentTypeDefinition.Parts.Single().Settings["y"], Is.EqualTo("11"));
}
[Test]
public void CanAlterPartSettingsByNameDuringBuild() {
var contentTypeDefinition = new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithSetting("a", "1")
.WithSetting("b", "2")
.WithPart("foo", pb => pb.WithSetting("x", "10"))
.WithPart("foo", pb => pb.WithSetting("y", "11"))
.Build();
Assert.That(contentTypeDefinition.Name, Is.EqualTo("alpha"));
Assert.That(contentTypeDefinition.Parts.Count(), Is.EqualTo(1));
Assert.That(contentTypeDefinition.Parts.Single().PartDefinition.Name, Is.EqualTo("foo"));
Assert.That(contentTypeDefinition.Parts.Single().Settings.Count(), Is.EqualTo(2));
Assert.That(contentTypeDefinition.Parts.Single().Settings["x"], Is.EqualTo("10"));
Assert.That(contentTypeDefinition.Parts.Single().Settings["y"], Is.EqualTo("11"));
}
[Test]
public void CanAlterPartSettingsByNameDuringRebuild() {
var contentTypeDefinition1 = new ContentTypeDefinitionBuilder()
.Named("alpha")
.WithPart("foo", pb => pb.WithSetting("x", "10").WithSetting("y", "11"))
.Build();
var contentTypeDefinition2 = new ContentTypeDefinitionBuilder(contentTypeDefinition1)
.WithPart("foo", pb => pb.WithSetting("x", "12").WithSetting("z", "13"))
.Build();
Assert.That(contentTypeDefinition1.Name, Is.EqualTo("alpha"));
Assert.That(contentTypeDefinition1.Parts.Count(), Is.EqualTo(1));
Assert.That(contentTypeDefinition1.Parts.Single().PartDefinition.Name, Is.EqualTo("foo"));
Assert.That(contentTypeDefinition1.Parts.Single().Settings.Count(), Is.EqualTo(2));
Assert.That(contentTypeDefinition1.Parts.Single().Settings["x"], Is.EqualTo("10"));
Assert.That(contentTypeDefinition1.Parts.Single().Settings["y"], Is.EqualTo("11"));
Assert.That(contentTypeDefinition2.Name, Is.EqualTo("alpha"));
Assert.That(contentTypeDefinition2.Parts.Count(), Is.EqualTo(1));
Assert.That(contentTypeDefinition2.Parts.Single().PartDefinition.Name, Is.EqualTo("foo"));
Assert.That(contentTypeDefinition2.Parts.Single().Settings.Count(), Is.EqualTo(3));
Assert.That(contentTypeDefinition2.Parts.Single().Settings["x"], Is.EqualTo("12"));
Assert.That(contentTypeDefinition2.Parts.Single().Settings["y"], Is.EqualTo("11"));
Assert.That(contentTypeDefinition2.Parts.Single().Settings["z"], Is.EqualTo("13"));
}
[Test, IgnoreAttribute("Merging not yet implemented")]
public void ContentMergeOverlaysSettings() {
Assert.Fail();
}
}
}

View File

@@ -148,12 +148,12 @@
<Compile Include="ContentManagement\ContentQueryTests.cs"> <Compile Include="ContentManagement\ContentQueryTests.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="ContentManagement\ContentTypeMetaDataTests.cs" />
<Compile Include="ContentManagement\DefaultContentManagerTests.cs"> <Compile Include="ContentManagement\DefaultContentManagerTests.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="ContentManagement\Handlers\ContentHandlerTests.cs" /> <Compile Include="ContentManagement\Handlers\ContentHandlerTests.cs" />
<Compile Include="ContentManagement\Handlers\ModelBuilderTests.cs" /> <Compile Include="ContentManagement\Handlers\ModelBuilderTests.cs" />
<Compile Include="ContentManagement\MetaData\Builders\ContentTypeDefinitionBuilderTests.cs" />
<Compile Include="ContentManagement\Models\Alpha.cs" /> <Compile Include="ContentManagement\Models\Alpha.cs" />
<Compile Include="ContentManagement\Models\AlphaHandler.cs" /> <Compile Include="ContentManagement\Models\AlphaHandler.cs" />
<Compile Include="ContentManagement\Models\Beta.cs" /> <Compile Include="ContentManagement\Models\Beta.cs" />

View File

@@ -143,6 +143,12 @@
<Compile Include="Scheduling\Services\ScheduledTaskExecutor.cs" /> <Compile Include="Scheduling\Services\ScheduledTaskExecutor.cs" />
<Compile Include="Scheduling\Models\Task.cs" /> <Compile Include="Scheduling\Models\Task.cs" />
<Compile Include="Settings\Drivers\SiteSettingsDriver.cs" /> <Compile Include="Settings\Drivers\SiteSettingsDriver.cs" />
<Compile Include="Settings\Metadata\ContentDefinitionManager.cs" />
<Compile Include="Settings\Metadata\Records\ContentFieldDefinitionRecord.cs" />
<Compile Include="Settings\Metadata\Records\ContentPartDefinitionRecord.cs" />
<Compile Include="Settings\Metadata\Records\ContentPartFieldDefinitionRecord.cs" />
<Compile Include="Settings\Metadata\Records\ContentTypeDefinitionRecord.cs" />
<Compile Include="Settings\Metadata\Records\ContentTypePartDefinitionRecord.cs" />
<Compile Include="Settings\Models\SiteSettingsRecord.cs" /> <Compile Include="Settings\Models\SiteSettingsRecord.cs" />
<Compile Include="Settings\Permissions.cs" /> <Compile Include="Settings\Permissions.cs" />
<Compile Include="Settings\State\Records\ShellFeatureStateRecord.cs" /> <Compile Include="Settings\State\Records\ShellFeatureStateRecord.cs" />

View File

@@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.Core.Settings.Metadata.Records;
using Orchard.Data;
using Orchard.Logging;
using Orchard.Utility.Extensions;
namespace Orchard.Core.Settings.Metadata {
public class ContentDefinitionManager : Component, IContentDefinitionManager {
private readonly IRepository<ContentTypeDefinitionRecord> _typeDefinitionRepository;
private readonly IRepository<ContentPartDefinitionRecord> _partDefinitionRepository;
private readonly IMapper<XElement, IDictionary<string, string>> _settingsReader;
private readonly IMapper<IDictionary<string, string>, XElement> _settingsWriter;
public ContentDefinitionManager(
IRepository<ContentTypeDefinitionRecord> typeDefinitionRepository,
IRepository<ContentPartDefinitionRecord> partDefinitionRepository,
IMapper<XElement, IDictionary<string, string>> settingsReader,
IMapper<IDictionary<string, string>, XElement> settingsWriter) {
_typeDefinitionRepository = typeDefinitionRepository;
_partDefinitionRepository = partDefinitionRepository;
_settingsReader = settingsReader;
_settingsWriter = settingsWriter;
}
public ContentTypeDefinition GetTypeDefinition(string name) {
return _typeDefinitionRepository.Fetch(x => x.Name == name).Select(Build).SingleOrDefault();
}
public ContentPartDefinition GetPartDefinition(string name) {
return _partDefinitionRepository.Fetch(x => x.Name == name).Select(Build).SingleOrDefault();
}
public IEnumerable<ContentTypeDefinition> ListTypeDefinitions() {
return _typeDefinitionRepository.Fetch(x => !x.Hidden).Select(Build).ToReadOnlyCollection();
}
public IEnumerable<ContentPartDefinition> ListPartDefinitions() {
return _partDefinitionRepository.Fetch(x => !x.Hidden).Select(Build).ToReadOnlyCollection();
}
public void StoreTypeDefinition(ContentTypeDefinition contentTypeDefinition) {
Apply(contentTypeDefinition, Acquire(contentTypeDefinition));
}
public void StorePartDefinition(ContentPartDefinition contentPartDefinition) {
throw new NotImplementedException();
}
private ContentTypeDefinitionRecord Acquire(ContentTypeDefinition contentTypeDefinition) {
var result = _typeDefinitionRepository.Fetch(x => x.Name == contentTypeDefinition.Name).SingleOrDefault();
if (result == null) {
result = new ContentTypeDefinitionRecord { Name = contentTypeDefinition.Name };
_typeDefinitionRepository.Create(result);
}
return result;
}
private ContentPartDefinitionRecord Acquire(ContentPartDefinition contentPartDefinition) {
var result = _partDefinitionRepository.Fetch(x => x.Name == contentPartDefinition.Name).SingleOrDefault();
if (result == null) {
result = new ContentPartDefinitionRecord { Name = contentPartDefinition.Name };
_partDefinitionRepository.Create(result);
}
return result;
}
private void Apply(ContentTypeDefinition model, ContentTypeDefinitionRecord record) {
record.Settings = _settingsWriter.Map(model.Settings).ToString();
var toRemove = record.ContentTypePartDefinitionRecords
.Where(partDefinitionRecord => !model.Parts.Any(part => partDefinitionRecord.ContentPartDefinitionRecord.Name == part.PartDefinition.Name))
.ToList();
foreach (var remove in toRemove) {
record.ContentTypePartDefinitionRecords.Remove(remove);
}
foreach (var part in model.Parts) {
var partName = part.PartDefinition.Name;
var typePartRecord = record.ContentTypePartDefinitionRecords.SingleOrDefault(r => r.ContentPartDefinitionRecord.Name == partName);
if (typePartRecord == null) {
typePartRecord = new ContentTypePartDefinitionRecord { ContentPartDefinitionRecord = Acquire(part.PartDefinition) };
record.ContentTypePartDefinitionRecords.Add(typePartRecord);
}
Apply(part, typePartRecord);
}
}
private void Apply(ContentTypeDefinition.Part model, ContentTypePartDefinitionRecord record) {
record.Settings = Compose(_settingsWriter.Map(model.Settings));
}
ContentTypeDefinition Build(ContentTypeDefinitionRecord source) {
return new ContentTypeDefinition(
source.Name,
source.ContentTypePartDefinitionRecords.Select(Build),
_settingsReader.Map(Parse(source.Settings)));
}
ContentTypeDefinition.Part Build(ContentTypePartDefinitionRecord source) {
return new ContentTypeDefinition.Part(
Build(source.ContentPartDefinitionRecord),
_settingsReader.Map(Parse(source.Settings)));
}
ContentPartDefinition Build(ContentPartDefinitionRecord source) {
return new ContentPartDefinition(
source.Name,
source.ContentPartFieldDefinitionRecords.Select(Build),
_settingsReader.Map(Parse(source.Settings)));
}
ContentPartDefinition.Field Build(ContentPartFieldDefinitionRecord source) {
return new ContentPartDefinition.Field(
Build(source.ContentFieldDefinitionRecord),
source.Name,
_settingsReader.Map(Parse(source.Settings)));
}
ContentFieldDefinition Build(ContentFieldDefinitionRecord source) {
return new ContentFieldDefinition(source.Name);
}
XElement Parse(string settings) {
if (string.IsNullOrEmpty(settings))
return null;
try {
return XElement.Parse(settings);
}
catch (Exception ex) {
Logger.Error(ex, "Unable to parse settings xml");
return null;
}
}
string Compose(XElement map) {
if (map == null)
return null;
return map.ToString();
}
}
}

View File

@@ -0,0 +1,6 @@
namespace Orchard.Core.Settings.Metadata.Records {
public class ContentFieldDefinitionRecord {
public virtual int Id { get; set; }
public virtual string Name { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
using Orchard.Data.Conventions;
namespace Orchard.Core.Settings.Metadata.Records {
public class ContentPartDefinitionRecord {
public ContentPartDefinitionRecord() {
ContentPartFieldDefinitionRecords = new List<ContentPartFieldDefinitionRecord>();
}
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual bool Hidden { get; set; }
public virtual string Settings { get; set; }
[CascadeAllDeleteOrphan]
public virtual IList<ContentPartFieldDefinitionRecord> ContentPartFieldDefinitionRecords { get; set; }
}
}

View File

@@ -0,0 +1,8 @@
namespace Orchard.Core.Settings.Metadata.Records {
public class ContentPartFieldDefinitionRecord {
public virtual int Id { get; set; }
public virtual ContentFieldDefinitionRecord ContentFieldDefinitionRecord { get; set; }
public virtual string Name { get; set; }
public virtual string Settings { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
using Orchard.Data.Conventions;
namespace Orchard.Core.Settings.Metadata.Records {
public class ContentTypeDefinitionRecord {
public ContentTypeDefinitionRecord() {
ContentTypePartDefinitionRecords = new List<ContentTypePartDefinitionRecord>();
}
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual bool Hidden { get; set; }
public virtual string Settings { get; set; }
[CascadeAllDeleteOrphan]
public virtual IList<ContentTypePartDefinitionRecord> ContentTypePartDefinitionRecords { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace Orchard.Core.Settings.Metadata.Records {
public class ContentTypePartDefinitionRecord {
public virtual int Id { get; set; }
public virtual ContentPartDefinitionRecord ContentPartDefinitionRecord { get; set; }
public virtual string Settings { get; set; }
}
}

View File

@@ -12,7 +12,7 @@ namespace Orchard.MetaData {
{ {
builder.Add(T("Content Types"), "5", builder.Add(T("Content Types"), "5",
menu => menu menu => menu
.Add(T("Content Types"), "1.0", item => item.Action("ContentTypeList", "MetaData", new { area = "Orchard.MetaData" }).Permission(Permissions.ManageMetaData)) .Add(T("Content Types"), "1.0", item => item.Action("ContentTypeList", "Admin", new { area = "Orchard.MetaData" }).Permission(Permissions.ManageMetaData))
); );
} }

View File

@@ -0,0 +1,82 @@
using System.Web.Mvc;
using Orchard.ContentManagement.MetaData;
using Orchard.Localization;
using Orchard.MetaData.ViewModels;
namespace Orchard.MetaData.Controllers {
public class AdminController : Controller {
private readonly IContentDefinitionManager _contentDefinitionManager;
public IOrchardServices Services { get; set; }
public AdminController(IOrchardServices services, IContentDefinitionManager contentDefinitionManager) {
_contentDefinitionManager = contentDefinitionManager;
Services = services;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
//
// GET: /ContentTypeList/
public ActionResult ContentTypeList(string id) {
if (!Services.Authorizer.Authorize(Permissions.ManageMetaData, T("Not allowed to manage MetaData")))
return new HttpUnauthorizedResult();
var contentTypes = _contentDefinitionManager.ListTypeDefinitions();
var contentParts = _contentDefinitionManager.ListPartDefinitions();
var model = new ContentTypesIndexViewModel();
foreach (var contentType in contentTypes) {
var contentTypeEntry = new ContentTypeEntry { Name = contentType.Name, DisplayName = contentType.Name };
if (contentType.Name == id) {
foreach (var contentTypePartNameRecord in contentParts) {
var contentTypePartEntry = new ContentTypePartEntry { Name = contentTypePartNameRecord.Name };
foreach (var contentTypePartEntryTest in contentType.Parts) {
if (contentTypePartEntryTest.PartDefinition.Name == contentTypePartEntry.Name) {
contentTypePartEntry.Selected = true;
}
}
model.ContentTypeParts.Add(contentTypePartEntry);
}
model.SelectedContentType = contentTypeEntry;
}
model.ContentTypes.Add(contentTypeEntry);
}
return View(model);
}
//
// POST: /ContentTypeList/Save
[HttpPost]
public ActionResult Save(string id, FormCollection collection) {
if (!Services.Authorizer.Authorize(Permissions.ManageMetaData, T("Not allowed to manage MetaData")))
return new HttpUnauthorizedResult();
var existingDefinition = _contentDefinitionManager.GetTypeDefinition(id);
_contentDefinitionManager.AlterTypeDefinition(id, alter => {
foreach(var part in existingDefinition.Parts) {
alter.RemovePart(part.PartDefinition.Name);
}
foreach (var formKey in collection.AllKeys) {
if (formKey.Contains("part_")) {
var partName = formKey.Replace("part_", "");
alter.WithPart(partName);
}
}
});
return RedirectToAction("ContentTypeList", new { id });
}
}
}

View File

@@ -1,84 +0,0 @@
using System.Web.Mvc;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.Localization;
using Orchard.MetaData.ViewModels;
using Orchard.UI.Admin;
namespace Orchard.MetaData.Controllers
{
[Admin]
public class MetaDataController : Controller
{
private readonly IContentTypeService _contentTypeService;
public IOrchardServices Services { get; set; }
public MetaDataController(IOrchardServices services, IContentTypeService contentTypeService)
{
_contentTypeService = contentTypeService;
Services = services;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
//
// GET: /ContentTypeList/
public ActionResult ContentTypeList(string id) {
if (!Services.Authorizer.Authorize(Permissions.ManageMetaData, T("Not allowed to manage MetaData")))
return new HttpUnauthorizedResult();
var contentTypes = _contentTypeService.GetContentTypes();
var contentTypePartNames = _contentTypeService.GetContentTypePartNames();
var model = new ContentTypesIndexViewModel();
foreach(var contentType in contentTypes) {
var contentTypeEntry = new ContentTypeEntry {Name = contentType.Name,DisplayName = contentType.Name};
if (contentType.Name==id) {
foreach(var contentTypePartNameRecord in contentTypePartNames) {
var contentTypePartEntry = new ContentTypePartEntry { Name = contentTypePartNameRecord.PartName };
foreach(var contentTypePartEntryTest in contentType.ContentParts) {
if (contentTypePartEntryTest.PartName.PartName==contentTypePartEntry.Name) {
contentTypePartEntry.Selected = true;
}
}
model.ContentTypeParts.Add(contentTypePartEntry);
}
model.SelectedContentType = contentTypeEntry;
}
model.ContentTypes.Add(contentTypeEntry);
}
return View(model);
}
//
// POST: /ContentTypeList/Save
[HttpPost]
public ActionResult Save(string id, FormCollection collection)
{
if (!Services.Authorizer.Authorize(Permissions.ManageMetaData, T("Not allowed to manage MetaData")))
return new HttpUnauthorizedResult();
var contentTypeRecord = _contentTypeService.GetContentTypeRecord(id);
//using a while loop because we are removing items from the collection
while (contentTypeRecord.ContentParts.Count>0) {
_contentTypeService.UnMapContentTypeToContentPart(contentTypeRecord.Name, contentTypeRecord.ContentParts[0].PartName.PartName);
}
foreach(var formKey in collection.AllKeys) {
if (formKey.Contains("part_")) {
var partName = formKey.Replace("part_", "");
_contentTypeService.MapContentTypeToContentPart(contentTypeRecord.Name,partName);
}
}
return RedirectToAction("ContentTypeList", new { id });
}
}
}

View File

@@ -66,7 +66,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AdminMenu.cs" /> <Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\MetaDataController.cs" /> <Compile Include="Controllers\AdminController.cs" />
<Compile Include="Permissions.cs" /> <Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\ContentTypesViewModel.cs" /> <Compile Include="ViewModels\ContentTypesViewModel.cs" />
@@ -74,7 +74,7 @@
<ItemGroup> <ItemGroup>
<Content Include="Module.txt" /> <Content Include="Module.txt" />
<Content Include="Web.config" /> <Content Include="Web.config" />
<Content Include="Views\MetaData\ContentTypeList.ascx" /> <Content Include="Views\Admin\ContentTypeList.ascx" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj"> <ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">

View File

@@ -3,6 +3,8 @@ using System.Linq;
using System.Web; using System.Web;
using Orchard.Comments.Models; using Orchard.Comments.Models;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Core.Navigation.Models; using Orchard.Core.Navigation.Models;
using Orchard.Core.Settings.Models; using Orchard.Core.Settings.Models;
@@ -169,23 +171,10 @@ namespace Orchard.Setup.Services {
authenticationService.SignIn(user, true); authenticationService.SignIn(user, true);
} }
//Add ContentType mappings var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
var contentTypeService = environment.Resolve<IContentTypeService>(); contentDefinitionManager.AlterTypeDefinition("blogpost", cfg => cfg.WithPart("HasComments").WithPart("HasTags"));
contentDefinitionManager.AlterTypeDefinition("page", cfg => cfg.WithPart("HasComments").WithPart("HasTags"));
//Add ContentTypePartNames to MetaData contentDefinitionManager.AlterTypeDefinition("sandboxpage", cfg => cfg.WithPart("HasComments").WithPart("HasTags"));
contentTypeService.AddContentTypePartNameToMetaData("HasComments");
contentTypeService.AddContentTypePartNameToMetaData("HasTags");
//Add mappings from ContentTypes to ContentParts to MetaData
contentTypeService.MapContentTypeToContentPart("blogpost","HasComments");
contentTypeService.MapContentTypeToContentPart("page", "HasComments");
contentTypeService.MapContentTypeToContentPart("sandboxpage", "HasComments");
contentTypeService.MapContentTypeToContentPart("blogpost", "HasTags");
contentTypeService.MapContentTypeToContentPart("page", "HasTags");
contentTypeService.MapContentTypeToContentPart("sandboxpage", "HasTags");
} }
catch { catch {
environment.Resolve<ITransactionManager>().Cancel(); environment.Resolve<ITransactionManager>().Cancel();

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.ContentManagement {
public class ContentField {
public string Name { get; set; }
public ContentFieldDefinition Definition { get; set; }
}
}

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
namespace Orchard.ContentManagement { namespace Orchard.ContentManagement {
@@ -17,6 +18,7 @@ namespace Orchard.ContentManagement {
public int Version { get { return VersionRecord == null ? 0 : VersionRecord.Number; } } public int Version { get { return VersionRecord == null ? 0 : VersionRecord.Number; } }
public string ContentType { get; set; } public string ContentType { get; set; }
public ContentTypeDefinition TypeDefinition { get; set; }
public ContentItemRecord Record { get { return VersionRecord == null ? null : VersionRecord.ContentItemRecord; } } public ContentItemRecord Record { get { return VersionRecord == null ? null : VersionRecord.ContentItemRecord; } }
public ContentItemVersionRecord VersionRecord { get; set; } public ContentItemVersionRecord VersionRecord { get; set; }

View File

@@ -1,8 +1,12 @@
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Utilities; using Orchard.ContentManagement.Utilities;
namespace Orchard.ContentManagement { namespace Orchard.ContentManagement {
public abstract class ContentPart : IContent { public abstract class ContentPart : IContent {
public virtual ContentItem ContentItem { get; set; } public virtual ContentItem ContentItem { get; set; }
public ContentTypeDefinition TypeDefinition { get; set; }
public ContentTypeDefinition.Part TypePartDefinition { get; set; }
public ContentPartDefinition PartDefinition { get; set; }
} }
public class ContentPart<TRecord> : ContentPart { public class ContentPart<TRecord> : ContentPart {

View File

@@ -5,7 +5,7 @@ using Orchard.Logging;
namespace Orchard.ContentManagement.Drivers { namespace Orchard.ContentManagement.Drivers {
[UsedImplicitly] [UsedImplicitly]
public class ContentItemDriverHandler : IContentHandler { public class ContentItemDriverHandler : ContentHandlerBase {
private readonly IEnumerable<IContentItemDriver> _drivers; private readonly IEnumerable<IContentItemDriver> _drivers;
public ContentItemDriverHandler(IEnumerable<IContentItemDriver> drivers) { public ContentItemDriverHandler(IEnumerable<IContentItemDriver> drivers) {
@@ -15,33 +15,17 @@ namespace Orchard.ContentManagement.Drivers {
public ILogger Logger { get; set; } public ILogger Logger { get; set; }
IEnumerable<ContentType> IContentHandler.GetContentTypes() { public override IEnumerable<ContentType> GetContentTypes() {
var contentTypes = new List<ContentType>(); var contentTypes = new List<ContentType>();
_drivers.Invoke(driver=>contentTypes.AddRange(driver.GetContentTypes()), Logger); _drivers.Invoke(driver=>contentTypes.AddRange(driver.GetContentTypes()), Logger);
return contentTypes; return contentTypes;
} }
void IContentHandler.Activating(ActivatingContentContext context) { } public override void GetContentItemMetadata(GetContentItemMetadataContext context) {
void IContentHandler.Activated(ActivatedContentContext context) { }
void IContentHandler.Creating(CreateContentContext context) { }
void IContentHandler.Created(CreateContentContext context) { }
void IContentHandler.Loading(LoadContentContext context) { }
void IContentHandler.Loaded(LoadContentContext context) { }
void IContentHandler.Versioning(VersionContentContext context) { }
void IContentHandler.Versioned(VersionContentContext context) { }
void IContentHandler.Publishing(PublishContentContext context) { }
void IContentHandler.Published(PublishContentContext context) { }
void IContentHandler.Removing(RemoveContentContext context) { }
void IContentHandler.Removed(RemoveContentContext context) { }
void IContentHandler.Indexing(IndexContentContext context) { }
void IContentHandler.Indexed(IndexContentContext context) { }
void IContentHandler.GetContentItemMetadata(GetContentItemMetadataContext context) {
_drivers.Invoke(driver => driver.GetContentItemMetadata(context), Logger); _drivers.Invoke(driver => driver.GetContentItemMetadata(context), Logger);
} }
void IContentHandler.BuildDisplayModel(BuildDisplayModelContext context) { public override void BuildDisplayModel(BuildDisplayModelContext context) {
_drivers.Invoke(driver => { _drivers.Invoke(driver => {
var result = driver.BuildDisplayModel(context); var result = driver.BuildDisplayModel(context);
if (result != null) if (result != null)
@@ -49,7 +33,7 @@ namespace Orchard.ContentManagement.Drivers {
}, Logger); }, Logger);
} }
void IContentHandler.BuildEditorModel(BuildEditorModelContext context) { public override void BuildEditorModel(BuildEditorModelContext context) {
_drivers.Invoke(driver => { _drivers.Invoke(driver => {
var result = driver.BuildEditorModel(context); var result = driver.BuildEditorModel(context);
if (result != null) if (result != null)
@@ -57,7 +41,7 @@ namespace Orchard.ContentManagement.Drivers {
}, Logger); }, Logger);
} }
void IContentHandler.UpdateEditorModel(UpdateEditorModelContext context) { public override void UpdateEditorModel(UpdateEditorModelContext context) {
_drivers.Invoke(driver => { _drivers.Invoke(driver => {
var result = driver.UpdateEditorModel(context); var result = driver.UpdateEditorModel(context);
if (result != null) if (result != null)

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Orchard.ContentManagement.Handlers {
public class ContentHandlerBase : IContentHandler {
public virtual IEnumerable<ContentType> GetContentTypes() {
return Enumerable.Empty<ContentType>();
}
public virtual void Activating(ActivatingContentContext context) {
}
public virtual void Activated(ActivatedContentContext context) {
}
public virtual void Creating(CreateContentContext context) {
}
public virtual void Created(CreateContentContext context) {
}
public virtual void Loading(LoadContentContext context) {
}
public virtual void Loaded(LoadContentContext context) {
}
public virtual void Versioning(VersionContentContext context) {
}
public virtual void Versioned(VersionContentContext context) {
}
public virtual void Publishing(PublishContentContext context) {
}
public virtual void Published(PublishContentContext context) {
}
public virtual void Removing(RemoveContentContext context) {
}
public virtual void Removed(RemoveContentContext context) {
}
public virtual void Indexing(IndexContentContext context) {
}
public virtual void Indexed(IndexContentContext context) {
}
public virtual void GetContentItemMetadata(GetContentItemMetadataContext context) {
}
public virtual void BuildDisplayModel(BuildDisplayModelContext context) {
}
public virtual void BuildEditorModel(BuildEditorModelContext context) {
}
public virtual void UpdateEditorModel(UpdateEditorModelContext context) {
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using Orchard.Events; using Orchard.Events;
namespace Orchard.ContentManagement.Handlers { namespace Orchard.ContentManagement.Handlers {

View File

@@ -0,0 +1,19 @@
using System;
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.ContentManagement.MetaData.Builders {
public class ContentPartDefinitionBuilder {
public ContentPartDefinitionBuilder(ContentPartDefinition partDefinition) {
throw new NotImplementedException();
}
public ContentPartDefinition Build() {
throw new NotImplementedException();
}
public ContentPartDefinitionBuilder WithSetting(string name, string value) {
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.ContentManagement.MetaData.Builders {
public class ContentTypeDefinitionBuilder {
private string _name;
private readonly IList<ContentTypeDefinition.Part> _parts;
private readonly IDictionary<string, string> _settings;
public ContentTypeDefinitionBuilder()
: this(new ContentTypeDefinition(null)) {
}
public ContentTypeDefinitionBuilder(ContentTypeDefinition existing) {
if (existing == null) {
_parts = new List<ContentTypeDefinition.Part>();
_settings = new Dictionary<string, string>();
}
else {
_name = existing.Name;
_parts = existing.Parts.ToList();
_settings = existing.Settings.ToDictionary(kv => kv.Key, kv => kv.Value);
}
}
private void Init(ContentTypeDefinition existing) {
}
public ContentTypeDefinition Build() {
return new ContentTypeDefinition(_name, _parts, _settings);
}
public ContentTypeDefinitionBuilder Named(string name) {
_name = name;
return this;
}
public ContentTypeDefinitionBuilder WithSetting(string name, string value) {
_settings[name] = value;
return this;
}
public ContentTypeDefinitionBuilder RemovePart(string partName) {
var existingPart = _parts.SingleOrDefault(x => x.PartDefinition.Name == partName);
if (existingPart != null) {
_parts.Remove(existingPart);
}
return this;
}
public ContentTypeDefinitionBuilder WithPart(string partName) {
return WithPart(partName, configuration => { });
}
public ContentTypeDefinitionBuilder WithPart(string partName, Action<PartConfigurer> configuration) {
return WithPart(new ContentPartDefinition(partName), configuration);
}
public ContentTypeDefinitionBuilder WithPart(ContentPartDefinition partDefinition, Action<PartConfigurer> configuration) {
var existingPart = _parts.SingleOrDefault(x => x.PartDefinition.Name == partDefinition.Name);
if (existingPart != null) {
_parts.Remove(existingPart);
}
else {
existingPart = new ContentTypeDefinition.Part(partDefinition, new Dictionary<string, string>());
}
var configurer = new PartConfigurerImpl(existingPart);
configuration(configurer);
_parts.Add(configurer.Build());
return this;
}
public abstract class PartConfigurer {
protected readonly IDictionary<string, string> _settings;
protected PartConfigurer(ContentTypeDefinition.Part part) {
_settings = part.Settings.ToDictionary(kv => kv.Key, kv => kv.Value);
}
public PartConfigurer WithSetting(string name, string value) {
_settings[name] = value;
return this;
}
}
class PartConfigurerImpl : PartConfigurer {
private readonly ContentPartDefinition _partDefinition;
public PartConfigurerImpl(ContentTypeDefinition.Part part)
: base(part) {
_partDefinition = part.PartDefinition;
}
public ContentTypeDefinition.Part Build() {
return new ContentTypeDefinition.Part(_partDefinition, _settings);
}
}
}
}

View File

@@ -1,32 +1,27 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
namespace Orchard.ContentManagement.MetaData { namespace Orchard.ContentManagement.MetaData {
public class ContentPartHandler : ContentHandler { public class ContentPartHandler : ContentHandlerBase {
private readonly IEnumerable<IContentPartDriver> _contentPartDrivers; private readonly IEnumerable<IContentPartDriver> _contentPartDrivers;
private readonly IContentTypeService _contentTypeService; private readonly IContentDefinitionManager _contentDefinitionManager;
public ContentPartHandler(IEnumerable<IContentPartDriver> contentPartDrivers, IContentTypeService contentTypeService) { public ContentPartHandler(IEnumerable<IContentPartDriver> contentPartDrivers, IContentDefinitionManager contentDefinitionManager) {
_contentPartDrivers = contentPartDrivers; _contentPartDrivers = contentPartDrivers;
_contentTypeService = contentTypeService; _contentDefinitionManager = contentDefinitionManager;
} }
protected override void Activating(ActivatingContentContext context) { public override void Activating(ActivatingContentContext context) {
var contentTypeRecord = _contentTypeService.GetContentTypeRecord(context.ContentType); var contentTypeRecord = _contentDefinitionManager.GetTypeDefinition(context.ContentType);
if (contentTypeRecord == null) if (contentTypeRecord == null)
return; return;
var contentPartInfos = _contentPartDrivers.SelectMany(cpp => cpp.GetPartInfo()).ToList(); foreach(var partInfo in _contentPartDrivers.SelectMany(cpp => cpp.GetPartInfo())) {
var partName = partInfo.PartName;
foreach (var contentTypePartRecord in contentTypeRecord.ContentParts) { if (contentTypeRecord.Parts.Any(p=>p.PartDefinition.Name == partName)) {
// We might have a part in the database, but the corresponding feature might not context.Builder.Weld(partInfo.Factory());
// be enabled anymore, so we need to be resilient to that situation.
var contentPartInfo = contentPartInfos.SingleOrDefault(x => x.PartName == contentTypePartRecord.PartName.PartName);
if (contentPartInfo != null) {
context.Builder.Weld(contentPartInfo.Factory());
} }
} }
} }

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
namespace Orchard.ContentManagement.MetaData {
public interface IContentDefinitionManager : IDependency {
IEnumerable<ContentTypeDefinition> ListTypeDefinitions();
IEnumerable<ContentPartDefinition> ListPartDefinitions();
ContentTypeDefinition GetTypeDefinition(string name);
ContentPartDefinition GetPartDefinition(string name);
void StoreTypeDefinition(ContentTypeDefinition contentTypeDefinition);
void StorePartDefinition(ContentPartDefinition contentPartDefinition);
}
public static class ContentDefinitionManagerExtensions{
public static void AlterTypeDefinition(this IContentDefinitionManager manager, string name, Action<ContentTypeDefinitionBuilder> alteration) {
var typeDefinition = manager.GetTypeDefinition(name) ?? new ContentTypeDefinition(name);
var builder = new ContentTypeDefinitionBuilder(typeDefinition);
alteration(builder);
manager.StoreTypeDefinition(builder.Build());
}
public static void AlterPartDefinition(this IContentDefinitionManager manager, string name, Action<ContentPartDefinitionBuilder> alteration) {
var partDefinition = manager.GetPartDefinition(name) ?? new ContentPartDefinition(name);
var builder = new ContentPartDefinitionBuilder(partDefinition);
alteration(builder);
manager.StorePartDefinition(builder.Build());
}
}
}

View File

@@ -0,0 +1,9 @@
namespace Orchard.ContentManagement.MetaData.Models {
public class ContentFieldDefinition {
public ContentFieldDefinition(string name) {
Name = name;
}
public string Name { get; private set; }
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Orchard.Utility.Extensions;
namespace Orchard.ContentManagement.MetaData.Models {
public class ContentPartDefinition {
public ContentPartDefinition(string name, IEnumerable<Field> fields, IDictionary<string, string> settings) {
Name = name;
Fields = fields.ToReadOnlyCollection();
Settings = settings;
}
public ContentPartDefinition(string name) {
Name = name;
Fields = Enumerable.Empty<Field>();
Settings = new Dictionary<string, string>();
}
public string Name { get; private set; }
public IEnumerable<Field> Fields { get; private set; }
public IDictionary<string, string> Settings { get; private set; }
public class Field {
public Field(ContentFieldDefinition contentFieldDefinition, string name, IDictionary<string, string> settings) {
FieldDefinition = contentFieldDefinition;
Name = name;
Settings = settings;
}
public string Name { get; private set; }
public ContentFieldDefinition FieldDefinition { get; private set; }
public IDictionary<string, string> Settings { get; private set; }
}
}
}

View File

@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Linq;
namespace Orchard.ContentManagement.MetaData.Models {
public class ContentTypeDefinition {
public ContentTypeDefinition(string name, IEnumerable<Part> parts, IDictionary<string, string> settings) {
Name = name;
Parts = parts;
Settings = settings;
}
public ContentTypeDefinition(string name) {
Name = name;
Parts = Enumerable.Empty<Part>();
Settings = new Dictionary<string, string>();
}
public string Name { get; private set; }
public IEnumerable<Part> Parts { get; private set; }
public IDictionary<string, string> Settings { get; private set; }
public class Part {
public Part(ContentPartDefinition contentPartDefinition, IDictionary<string, string> settings) {
PartDefinition = contentPartDefinition;
Settings = settings;
}
public ContentPartDefinition PartDefinition { get; private set; }
public IDictionary<string, string> Settings { get; private set; }
}
}
}

View File

@@ -1,6 +0,0 @@
namespace Orchard.ContentManagement.MetaData.Records {
public class ContentTypePartNameRecord {
public virtual int Id { get; set; }
public virtual string PartName { get; set; }
}
}

View File

@@ -1,6 +0,0 @@
namespace Orchard.ContentManagement.MetaData.Records {
public class ContentTypePartRecord {
public virtual int Id { get; set; }
public virtual ContentTypePartNameRecord PartName { get; set; }
}
}

View File

@@ -1,81 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records;
using Orchard.Data;
namespace Orchard.ContentManagement.MetaData.Services {
[UsedImplicitly]
public class ContentTypeService : IContentTypeService {
private readonly IRepository<ContentTypeRecord> _contentTypeRepository;
private readonly IRepository<ContentTypePartNameRecord> _contentTypePartNameRepository;
private readonly IRepository<ContentTypePartRecord> _contentTypePartRepository;
public ContentTypeService(IRepository<ContentTypePartRecord> contentTypePartRepository, IRepository<ContentTypeRecord> contentTypeRepository, IRepository<ContentTypePartNameRecord> contentTypePartNameRepository) {
_contentTypeRepository = contentTypeRepository;
_contentTypePartNameRepository = contentTypePartNameRepository;
_contentTypePartRepository = contentTypePartRepository;
}
public ContentTypeRecord GetContentTypeRecord(string contentTypeName) {
return _contentTypeRepository.Fetch(x => x.Name == contentTypeName).SingleOrDefault();
}
public ContentTypePartNameRecord GetContentPartNameRecord(string name) {
return _contentTypePartNameRepository.Fetch(x => x.PartName == name).SingleOrDefault();
}
public IEnumerable<ContentTypeRecord> GetContentTypes() {
return _contentTypeRepository.Table.ToList();
}
public IEnumerable<ContentTypePartNameRecord> GetContentTypePartNames() {
return _contentTypePartNameRepository.Table.ToList();
}
public void MapContentTypeToContentPart(string contentType, string contentPart) {
// Create content type if needed
var contentTypeRecord = GetContentTypeRecord(contentType);
if (contentTypeRecord == null) {
contentTypeRecord = new ContentTypeRecord { Name = contentType };
_contentTypeRepository.Create(contentTypeRecord);
}
// Create part name if needed
var contentTypePartNameRecord = GetContentPartNameRecord(contentPart);
if (contentTypePartNameRecord == null) {
contentTypePartNameRecord = new ContentTypePartNameRecord { PartName = contentPart };
_contentTypePartNameRepository.Create(contentTypePartNameRecord);
}
// Add part name to content type
var contentTypePartRecord = new ContentTypePartRecord { PartName = contentTypePartNameRecord };
contentTypeRecord.ContentParts.Add(contentTypePartRecord);
}
public void UnMapContentTypeToContentPart(string contentType, string contentPart) {
var contentTypeRecord = GetContentTypeRecord(contentType);
var contentTypePartNameRecord = _contentTypePartNameRepository.Fetch(x => x.PartName == contentPart).Single();
var contentTypePartRecord = contentTypeRecord.ContentParts.Single(x => x.PartName == contentTypePartNameRecord);
contentTypeRecord.ContentParts.Remove(contentTypePartRecord);
}
public bool ValidateContentTypeToContentPartMapping(string contentType, string contentPart) {
var contentTypeRecord = GetContentTypeRecord(contentType) ?? new ContentTypeRecord();
if (contentTypeRecord.ContentParts.Count == 0)
return false;
var contentTypePart = contentTypeRecord.ContentParts.Single(x => x.PartName.PartName == contentPart);
return contentTypePart != null;
}
public void AddContentTypePartNameToMetaData(string contentTypePartName) {
var contentTypePartNameRecord = new ContentTypePartNameRecord() {
PartName = contentTypePartName
};
_contentTypePartNameRepository.Update(contentTypePartNameRecord);
}
}
}

View File

@@ -1,17 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement.MetaData.Records;
using Orchard.ContentManagement.Records;
namespace Orchard.ContentManagement.MetaData.Services
{
public interface IContentTypeService : IDependency {
void MapContentTypeToContentPart(string contentType, string contentPart);
void UnMapContentTypeToContentPart(string contentType, string contentPart);
void AddContentTypePartNameToMetaData(string contentTypePartName);
ContentTypeRecord GetContentTypeRecord(string contentTypeName);
bool ValidateContentTypeToContentPartMapping(string contentType, string contentPart);
IEnumerable<ContentTypeRecord> GetContentTypes();
IEnumerable<ContentTypePartNameRecord> GetContentTypePartNames();
ContentTypePartNameRecord GetContentPartNameRecord(string name);
}
}

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace Orchard.ContentManagement.MetaData.Services {
public class SettingsFormatter :
IMapper<XElement, IDictionary<string, string>>,
IMapper<IDictionary<string, string>, XElement> {
public IDictionary<string, string> Map(XElement source) {
if (source == null)
return new Dictionary<string, string>();
return source.Attributes().ToDictionary(attr => attr.Name.LocalName, attr => attr.Value);
}
public XElement Map(IDictionary<string, string> source) {
if (source == null)
return new XElement("settings");
return new XElement("settings", source.Select(kv => new XAttribute(kv.Key, kv.Value)));
}
}
}

View File

@@ -1,15 +1,7 @@
using System.Collections.Generic; namespace Orchard.ContentManagement.Records {
using Orchard.ContentManagement.MetaData.Records;
using Orchard.Data.Conventions;
namespace Orchard.ContentManagement.Records {
public class ContentTypeRecord { public class ContentTypeRecord {
public ContentTypeRecord() {
ContentParts = new List<ContentTypePartRecord>();
}
public virtual int Id { get; set; } public virtual int Id { get; set; }
public virtual string Name { get; set; } public virtual string Name { get; set; }
[CascadeAllDeleteOrphan]
public virtual IList<ContentTypePartRecord> ContentParts { get; set; }
} }
} }

View File

@@ -47,15 +47,15 @@ namespace Orchard.Data {
} }
bool IInterceptor.OnLoad(object entity, object id, object[] state, string[] propertyNames, IType[] types) { bool IInterceptor.OnLoad(object entity, object id, object[] state, string[] propertyNames, IType[] types) {
return true; return false;
} }
bool IInterceptor.OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types) { bool IInterceptor.OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types) {
return true; return false;
} }
bool IInterceptor.OnSave(object entity, object id, object[] state, string[] propertyNames, IType[] types) { bool IInterceptor.OnSave(object entity, object id, object[] state, string[] propertyNames, IType[] types) {
return true; return false;
} }
void IInterceptor.OnDelete(object entity, object id, object[] state, string[] propertyNames, IType[] types) { void IInterceptor.OnDelete(object entity, object id, object[] state, string[] propertyNames, IType[] types) {

View File

@@ -119,6 +119,7 @@
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Yaml, Version=1.0.3370.39839, Culture=neutral, PublicKeyToken=187a3d240e44a135, processorArchitecture=MSIL"> <Reference Include="Yaml, Version=1.0.3370.39839, Culture=neutral, PublicKeyToken=187a3d240e44a135, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\yaml\Yaml.dll</HintPath> <HintPath>..\..\lib\yaml\Yaml.dll</HintPath>
@@ -129,6 +130,211 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ContentManagement\Aspects\ICommonAspect.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\ContentExtensions.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\ContentField.cs" />
<Compile Include="ContentManagement\ContentItem.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\ContentItemMetadata.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\ContentModule.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\ContentPart.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\ContentType.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\DefaultContentManager.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\DefaultContentManagerSession.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\DefaultContentQuery.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\AutomaticContentPartDriver.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\CombinedResult.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\ContentItemDriver.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\ContentItemDriverHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\ContentItemTemplateResult.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\ContentPartDriver.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\ContentPartDriverHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\ContentPartTemplateResult.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\DriverResult.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Drivers\IContentItemDriver.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Extenstions\UrlHelperExtensions.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\ActivatedContentContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\ActivatingContentContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\ActivatingFilter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\BuildDisplayModelContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\BuildEditorModelContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\ContentContextBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\ContentHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\ContentHandlerBase.cs" />
<Compile Include="ContentManagement\Handlers\ContentItemBuilder.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\ContentItemTemplates.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\CreateContentContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\GetContentItemMetadataContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\IContentActivatingFilter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\IContentFilter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\IContentHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\IContentStorageFilter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\IContentTemplateFilter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\LoadContentContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\PublishContentContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\RemoveContentContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\StorageFilter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\StorageFilterBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\StorageVersionFilter.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\TemplateFilterBase.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\TemplateFilterForRecord.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\UpdateEditorModelContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Handlers\VersionContentContext.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\IContent.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\IContentManager.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\IContentManagerSession.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\IContentQuery.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\IUpdateModel.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\MetaData\Builders\ContentPartDefinitionBuilder.cs" />
<Compile Include="ContentManagement\MetaData\Builders\ContentTypeDefinitionBuilder.cs" />
<Compile Include="ContentManagement\MetaData\ContentPartHandler.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\MetaData\ContentPartInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\MetaData\IContentDefinitionManager.cs" />
<Compile Include="ContentManagement\MetaData\Models\ContentFieldDefinition.cs" />
<Compile Include="ContentManagement\MetaData\Models\ContentPartDefinition.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\MetaData\Models\ContentTypeDefinition.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\MetaData\Services\SettingsFormatter.cs" />
<Compile Include="ContentManagement\Records\ContentItemAlteration.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Records\ContentItemRecord.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Records\ContentItemVersionRecord.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Records\ContentPartAlteration.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Records\ContentPartRecord.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Records\ContentPartVersionRecord.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Records\ContentTypeRecord.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Records\Utility.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\Utilities\LazyField.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\ViewModels\TemplateViewModel.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Data\SessionLocator.cs" /> <Compile Include="Data\SessionLocator.cs" />
<Compile Include="Data\IRepository.cs" /> <Compile Include="Data\IRepository.cs" />
<Compile Include="Data\ISessionLocator.cs" /> <Compile Include="Data\ISessionLocator.cs" />
@@ -182,10 +388,6 @@
<Compile Include="Caching\DefaultCacheManager.cs" /> <Compile Include="Caching\DefaultCacheManager.cs" />
<Compile Include="Caching\ICacheHolder.cs" /> <Compile Include="Caching\ICacheHolder.cs" />
<Compile Include="Caching\Weak.cs" /> <Compile Include="Caching\Weak.cs" />
<Compile Include="ContentManagement\DefaultContentManagerSession.cs" />
<Compile Include="ContentManagement\IContentManagerSession.cs" />
<Compile Include="ContentManagement\MetaData\Records\ContentTypePartNameRecord.cs" />
<Compile Include="ContentManagement\Utilities\LazyField.cs" />
<Compile Include="Environment\State\Models\ShellState.cs" /> <Compile Include="Environment\State\Models\ShellState.cs" />
<Compile Include="FileSystems\WebSite\WebSiteFolder.cs" /> <Compile Include="FileSystems\WebSite\WebSiteFolder.cs" />
<Compile Include="FileSystems\AppData\IAppDataFolder.cs" /> <Compile Include="FileSystems\AppData\IAppDataFolder.cs" />
@@ -209,18 +411,6 @@
<Compile Include="Commands\ICommandHandler.cs" /> <Compile Include="Commands\ICommandHandler.cs" />
<Compile Include="Commands\OrchardSwitchAttribute.cs" /> <Compile Include="Commands\OrchardSwitchAttribute.cs" />
<Compile Include="Commands\OrchardSwitchesAttribute.cs" /> <Compile Include="Commands\OrchardSwitchesAttribute.cs" />
<Compile Include="ContentManagement\Aspects\ICommonAspect.cs" />
<Compile Include="ContentManagement\Drivers\IContentItemDriver.cs" />
<Compile Include="ContentManagement\Extenstions\UrlHelperExtensions.cs" />
<Compile Include="ContentManagement\Handlers\ContentContextBase.cs" />
<Compile Include="ContentManagement\Handlers\PublishContentContext.cs" />
<Compile Include="ContentManagement\Handlers\RemoveContentContext.cs" />
<Compile Include="ContentManagement\Handlers\VersionContentContext.cs" />
<Compile Include="ContentManagement\MetaData\ContentPartHandler.cs" />
<Compile Include="ContentManagement\MetaData\ContentPartInfo.cs" />
<Compile Include="ContentManagement\MetaData\Services\ContentTypeService.cs" />
<Compile Include="ContentManagement\MetaData\Services\IContentTypeService.cs" />
<Compile Include="ContentManagement\MetaData\Records\ContentTypePartRecord.cs" />
<Compile Include="Data\Conventions\RecordTableNameConvention.cs" /> <Compile Include="Data\Conventions\RecordTableNameConvention.cs" />
<Compile Include="Data\Builders\AbstractBuilder.cs" /> <Compile Include="Data\Builders\AbstractBuilder.cs" />
<Compile Include="Data\Builders\SessionFactoryBuilder.cs" /> <Compile Include="Data\Builders\SessionFactoryBuilder.cs" />
@@ -290,60 +480,8 @@
<Compile Include="Services\IHomePageProvider.cs" /> <Compile Include="Services\IHomePageProvider.cs" />
<Compile Include="Tasks\Scheduling\IPublishingTaskManager.cs" /> <Compile Include="Tasks\Scheduling\IPublishingTaskManager.cs" />
<Compile Include="Tasks\Scheduling\IScheduledTask.cs" /> <Compile Include="Tasks\Scheduling\IScheduledTask.cs" />
<Compile Include="ContentManagement\ContentExtensions.cs" />
<Compile Include="ContentManagement\ContentItem.cs" />
<Compile Include="ContentManagement\ContentItemMetadata.cs" />
<Compile Include="ContentManagement\ContentModule.cs" />
<Compile Include="ContentManagement\ContentPart.cs" />
<Compile Include="ContentManagement\ContentType.cs" />
<Compile Include="ContentManagement\DefaultContentManager.cs" />
<Compile Include="ContentManagement\DefaultContentQuery.cs" />
<Compile Include="ContentManagement\Drivers\AutomaticContentPartDriver.cs" />
<Compile Include="ContentManagement\Drivers\CombinedResult.cs" />
<Compile Include="ContentManagement\Drivers\DriverResult.cs" />
<Compile Include="ContentManagement\Drivers\ContentItemDriver.cs" />
<Compile Include="ContentManagement\Drivers\ContentItemDriverHandler.cs" />
<Compile Include="ContentManagement\Drivers\ContentItemTemplateResult.cs" />
<Compile Include="ContentManagement\Drivers\ContentPartDriverHandler.cs" />
<Compile Include="ContentManagement\Drivers\ContentPartTemplateResult.cs" />
<Compile Include="ContentManagement\Handlers\ActivatedContentContext.cs" />
<Compile Include="ContentManagement\Handlers\ActivatingContentContext.cs" />
<Compile Include="ContentManagement\Handlers\ActivatingFilter.cs" />
<Compile Include="ContentManagement\Handlers\BuildDisplayModelContext.cs" />
<Compile Include="ContentManagement\Handlers\BuildEditorModelContext.cs" />
<Compile Include="ContentManagement\Handlers\ContentHandler.cs" />
<Compile Include="ContentManagement\Handlers\ContentItemBuilder.cs" />
<Compile Include="ContentManagement\Handlers\ContentItemTemplates.cs" />
<Compile Include="ContentManagement\Handlers\CreateContentContext.cs" />
<Compile Include="ContentManagement\Handlers\GetContentItemMetadataContext.cs" />
<Compile Include="ContentManagement\Handlers\IContentActivatingFilter.cs" />
<Compile Include="ContentManagement\Handlers\IContentFilter.cs" />
<Compile Include="ContentManagement\Handlers\IContentHandler.cs" />
<Compile Include="ContentManagement\Handlers\IContentStorageFilter.cs" />
<Compile Include="ContentManagement\Handlers\IContentTemplateFilter.cs" />
<Compile Include="ContentManagement\Handlers\LoadContentContext.cs" />
<Compile Include="ContentManagement\Handlers\StorageFilter.cs" />
<Compile Include="ContentManagement\Handlers\StorageFilterBase.cs" />
<Compile Include="ContentManagement\Handlers\StorageVersionFilter.cs" />
<Compile Include="ContentManagement\Handlers\TemplateFilterBase.cs" />
<Compile Include="ContentManagement\Handlers\TemplateFilterForRecord.cs" />
<Compile Include="ContentManagement\Handlers\UpdateEditorModelContext.cs" />
<Compile Include="ContentManagement\IContent.cs" />
<Compile Include="ContentManagement\IContentManager.cs" />
<Compile Include="ContentManagement\IContentQuery.cs" />
<Compile Include="ContentManagement\Drivers\ContentPartDriver.cs" />
<Compile Include="ContentManagement\IUpdateModel.cs" />
<Compile Include="ContentManagement\Records\ContentItemRecord.cs" />
<Compile Include="ContentManagement\Records\ContentItemAlteration.cs" />
<Compile Include="ContentManagement\Records\ContentItemVersionRecord.cs" />
<Compile Include="ContentManagement\Records\ContentPartRecord.cs" />
<Compile Include="ContentManagement\Records\ContentPartAlteration.cs" />
<Compile Include="ContentManagement\Records\ContentPartVersionRecord.cs" />
<Compile Include="ContentManagement\Records\ContentTypeRecord.cs" />
<Compile Include="ContentManagement\Records\Utility.cs" />
<Compile Include="Localization\Text.cs" /> <Compile Include="Localization\Text.cs" />
<Compile Include="Mvc\ViewModels\ContentItemViewModel.cs" /> <Compile Include="Mvc\ViewModels\ContentItemViewModel.cs" />
<Compile Include="ContentManagement\ViewModels\TemplateViewModel.cs" />
<Compile Include="Data\Conventions\AttributeCollectionConvention.cs" /> <Compile Include="Data\Conventions\AttributeCollectionConvention.cs" />
<Compile Include="Data\Conventions\CascadeAllDeleteOrphanAttribute.cs" /> <Compile Include="Data\Conventions\CascadeAllDeleteOrphanAttribute.cs" />
<Compile Include="Data\TransactionManager.cs" /> <Compile Include="Data\TransactionManager.cs" />
@@ -513,9 +651,7 @@
<Install>true</Install> <Install>true</Install>
</BootstrapperPackage> </BootstrapperPackage>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="ContentManagement\MetaData\Models\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.