Removing ContentType

--HG--
branch : theming
This commit is contained in:
Sébastien Ros
2010-09-03 14:02:37 -07:00
parent 30fb9660a4
commit 0d91cf30ac
13 changed files with 18 additions and 67 deletions

View File

@@ -41,7 +41,7 @@ namespace Orchard.Core.Tests.Body {
public void BodyCanHandleLongText() {
var contentManager = _container.Resolve<IContentManager>();
contentManager.Create<Thing>(ThingDriver.ContentType.Name, t => {
contentManager.Create<Thing>(ThingDriver.ContentTypeName, t => {
t.As<BodyPart>().Record = new BodyPartRecord();
t.Text = new String('x', 10000);
});
@@ -69,10 +69,10 @@ namespace Orchard.Core.Tests.Body {
[UsedImplicitly]
public class ThingHandler : ContentHandler {
public ThingHandler() {
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonPart>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<BodyPart>(ThingDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentTypeName));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>(ThingDriver.ContentTypeName));
Filters.Add(new ActivatingFilter<CommonPart>(ThingDriver.ContentTypeName));
Filters.Add(new ActivatingFilter<BodyPart>(ThingDriver.ContentTypeName));
}
}
@@ -87,10 +87,7 @@ namespace Orchard.Core.Tests.Body {
}
public class ThingDriver : ContentPartDriver<Thing> {
public readonly static ContentType ContentType = new ContentType {
Name = "thing",
DisplayName = "Thing"
};
public static readonly string ContentTypeName = "thing";
}
}

View File

@@ -165,7 +165,7 @@ namespace Orchard.Tests.ContentManagement {
[Test]
public void GetContentTypesShouldReturnAllTypes() {
var types = _manager.GetContentTypes();
var types = _manager.GetContentTypeDefinitions();
Assert.That(types.Count(), Is.EqualTo(4));
Assert.That(types, Has.Some.With.Property("Name").EqualTo("alpha"));
Assert.That(types, Has.Some.With.Property("Name").EqualTo("beta"));

View File

@@ -1,6 +1,4 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.ViewModels;
namespace Orchard.Tests.ContentManagement.Models {
@@ -8,9 +6,7 @@ namespace Orchard.Tests.ContentManagement.Models {
public AlphaHandler() {
OnGetDisplayShape<Alpha>((ctx, part) => ctx.AddDisplay(new TemplateViewModel(part) { Position = "3" }));
}
public override IEnumerable<ContentType> GetContentTypes() {
return new[] { new ContentType { Name = "alpha" } };
}
protected override void Activating(ActivatingContentContext context) {
if (context.ContentType == "alpha") {
context.Builder.Weld<Alpha>();

View File

@@ -1,16 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Tests.ContentManagement.Models {
public class BetaHandler : ContentHandler {
public override System.Collections.Generic.IEnumerable<Orchard.ContentManagement.ContentType> GetContentTypes() {
return new[] { new ContentType { Name = "beta" } };
}
protected override void Activating(ActivatingContentContext context) {
if (context.ContentType == "beta") {
context.Builder.Weld<Beta>();

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.Data;
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Tests.ContentManagement.Records;
@@ -13,9 +9,6 @@ namespace Orchard.Tests.ContentManagement.Models {
public class DeltaHandler : ContentHandler {
public override System.Collections.Generic.IEnumerable<Orchard.ContentManagement.ContentType> GetContentTypes() {
return new[] { new ContentType { Name = "delta" } };
}
public DeltaHandler(IRepository<DeltaRecord> repository) {
Filters.Add(new ActivatingFilter<Delta>(x => x == "delta"));

View File

@@ -9,10 +9,6 @@ namespace Orchard.Tests.ContentManagement.Models {
public class GammaHandler : ContentHandler {
public override System.Collections.Generic.IEnumerable<ContentType> GetContentTypes() {
return new[] { new ContentType { Name = "gamma" } };
}
public GammaHandler(IRepository<GammaRecord> repository) {
Filters.Add(new ActivatingFilter<Gamma>(x => x == "gamma"));
Filters.Add(StorageFilter.For(repository));

View File

@@ -3,7 +3,6 @@ using Orchard.Settings;
namespace Orchard.Core.Settings.Models {
public sealed class SiteSettingsPart : ContentPart<SiteSettingsPartRecord>, ISite {
public static readonly ContentType ContentType = new ContentType { Name = "Site", DisplayName = "Site Settings" };
public string PageTitleSeparator {
get { return Record.PageTitleSeparator; }

View File

@@ -1,6 +0,0 @@
namespace Orchard.ContentManagement {
public class ContentType {
public string Name { get; set; }
public string DisplayName { get; set; }
}
}

View File

@@ -5,6 +5,7 @@ using Autofac;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Records;
using Orchard.Data;
using Orchard.Indexing;
@@ -43,10 +44,8 @@ namespace Orchard.ContentManagement {
}
}
public IEnumerable<ContentType> GetContentTypes() {
return Handlers.Aggregate(
Enumerable.Empty<ContentType>(),
(types, handler) => types.Concat(handler.GetContentTypes()));
public IEnumerable<ContentTypeDefinition> GetContentTypeDefinitions() {
return _contentDefinitionManager.ListTypeDefinitions();
}
public virtual ContentItem New(string contentType) {

View File

@@ -181,10 +181,6 @@ namespace Orchard.ContentManagement.Handlers {
}
}
public virtual IEnumerable<ContentType> GetContentTypes() {
return Enumerable.Empty<ContentType>();
}
void IContentHandler.Activating(ActivatingContentContext context) {
foreach (var filter in Filters.OfType<IContentActivatingFilter>())
filter.Activating(context);

View File

@@ -1,12 +1,5 @@
using System.Collections.Generic;
using System.Linq;
namespace Orchard.ContentManagement.Handlers {
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 Initializing(InitializingContentContext context) {}

View File

@@ -1,9 +1,5 @@
using System.Collections.Generic;
namespace Orchard.ContentManagement.Handlers {
namespace Orchard.ContentManagement.Handlers {
public interface IContentHandler : IEvents {
IEnumerable<ContentType> GetContentTypes();
void Activating(ActivatingContentContext context);
void Activated(ActivatedContentContext context);
void Initializing(InitializingContentContext context);

View File

@@ -1,10 +1,11 @@
using System.Collections.Generic;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.Indexing;
using Orchard.Mvc.ViewModels;
namespace Orchard.ContentManagement {
public interface IContentManager : IDependency {
IEnumerable<ContentType> GetContentTypes();
IEnumerable<ContentTypeDefinition> GetContentTypeDefinitions();
ContentItem New(string contentType);