mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:36:18 +08:00
Moving nested definition/builder classes to outer scope
--HG-- branch : dev
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Orchard.Tests.ContentManagement.Drivers.FieldStorage {
|
||||
get { return "TestProvName"; }
|
||||
}
|
||||
|
||||
public IFieldStorage BindStorage(ContentPart contentPart, ContentPartDefinition.Field partFieldDefinition) {
|
||||
public IFieldStorage BindStorage(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ using Orchard.ContentManagement.MetaData.Models;
|
||||
namespace Orchard.Tests.ContentManagement.Models {
|
||||
public class Phi : ContentField {
|
||||
public Phi() {
|
||||
PartFieldDefinition = new ContentPartDefinition.Field(new ContentFieldDefinition("Phi"), "Phi", new SettingsDictionary());
|
||||
PartFieldDefinition = new ContentPartFieldDefinition(new ContentFieldDefinition("Phi"), "Phi", new SettingsDictionary());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ namespace Orchard.Core.Common.Settings {
|
||||
}
|
||||
|
||||
public class BodySettingsHooks : ContentDefinitionEditorEventsBase {
|
||||
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition) {
|
||||
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypePartDefinition definition) {
|
||||
if (definition.PartDefinition.Name != "BodyAspect")
|
||||
yield break;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Orchard.Core.Common.Settings {
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
|
||||
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel) {
|
||||
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||
if (builder.Name != "BodyAspect")
|
||||
yield break;
|
||||
|
||||
|
@@ -63,7 +63,7 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
||||
#endregion
|
||||
|
||||
#region Part in the context of a content type
|
||||
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition) {
|
||||
public override IEnumerable<TemplateViewModel> TypePartEditor(ContentTypePartDefinition definition) {
|
||||
// Look for the setting in the most specific settings first (part definition in type)
|
||||
// then in the global part definition.
|
||||
var partSettings = definition.Settings.GetModel<LocationSettings>();
|
||||
@@ -80,7 +80,7 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel) {
|
||||
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||
var settings = new LocationSettings();
|
||||
foreach (var location in GetPredefinedLocations()) {
|
||||
var viewModel = new LocationSettingsViewModel();
|
||||
@@ -93,7 +93,7 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
||||
#endregion
|
||||
|
||||
#region Field within a content part
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartDefinition.Field definition) {
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
|
||||
var settings = definition.Settings.GetModel<LocationSettings>();
|
||||
foreach (var location in GetPredefinedLocations()) {
|
||||
var viewModel = new LocationSettingsViewModel {
|
||||
@@ -105,7 +105,7 @@ namespace Orchard.Core.ContentsLocation.Settings {
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartDefinitionBuilder.FieldConfigurer builder, IUpdateModel updateModel) {
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||
var settings = new LocationSettings();
|
||||
foreach (var location in GetPredefinedLocations()) {
|
||||
var viewModel = new LocationSettingsViewModel();
|
||||
|
@@ -108,7 +108,7 @@ namespace Orchard.Core.Settings.Metadata {
|
||||
}
|
||||
}
|
||||
|
||||
private void Apply(ContentTypeDefinition.Part model, ContentTypePartDefinitionRecord record) {
|
||||
private void Apply(ContentTypePartDefinition model, ContentTypePartDefinitionRecord record) {
|
||||
record.Settings = Compose(_settingsWriter.Map(model.Settings));
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace Orchard.Core.Settings.Metadata {
|
||||
}
|
||||
}
|
||||
|
||||
private void Apply(ContentPartDefinition.Field model, ContentPartFieldDefinitionRecord record) {
|
||||
private void Apply(ContentPartFieldDefinition model, ContentPartFieldDefinitionRecord record) {
|
||||
record.Settings = Compose(_settingsWriter.Map(model.Settings));
|
||||
}
|
||||
|
||||
@@ -149,8 +149,8 @@ namespace Orchard.Core.Settings.Metadata {
|
||||
_settingsReader.Map(Parse(source.Settings)));
|
||||
}
|
||||
|
||||
ContentTypeDefinition.Part Build(ContentTypePartDefinitionRecord source) {
|
||||
return new ContentTypeDefinition.Part(
|
||||
ContentTypePartDefinition Build(ContentTypePartDefinitionRecord source) {
|
||||
return new ContentTypePartDefinition(
|
||||
Build(source.ContentPartDefinitionRecord),
|
||||
_settingsReader.Map(Parse(source.Settings)));
|
||||
}
|
||||
@@ -162,8 +162,8 @@ namespace Orchard.Core.Settings.Metadata {
|
||||
_settingsReader.Map(Parse(source.Settings)));
|
||||
}
|
||||
|
||||
ContentPartDefinition.Field Build(ContentPartFieldDefinitionRecord source) {
|
||||
return new ContentPartDefinition.Field(
|
||||
ContentPartFieldDefinition Build(ContentPartFieldDefinitionRecord source) {
|
||||
return new ContentPartFieldDefinition(
|
||||
Build(source.ContentFieldDefinitionRecord),
|
||||
source.Name,
|
||||
_settingsReader.Map(Parse(source.Settings)));
|
||||
|
@@ -49,7 +49,7 @@ namespace Orchard.ContentTypes.ViewModels {
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public EditTypePartViewModel(int index, ContentTypeDefinition.Part part) {
|
||||
public EditTypePartViewModel(int index, ContentTypePartDefinition part) {
|
||||
Index = index;
|
||||
PartDefinition = new EditPartViewModel(part.PartDefinition);
|
||||
Settings = part.Settings;
|
||||
@@ -62,7 +62,7 @@ namespace Orchard.ContentTypes.ViewModels {
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
public EditTypeViewModel Type { get; set; }
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public ContentTypeDefinition.Part _Definition { get; private set; }
|
||||
public ContentTypePartDefinition _Definition { get; private set; }
|
||||
}
|
||||
|
||||
public class EditPartViewModel : BaseViewModel {
|
||||
@@ -92,7 +92,7 @@ namespace Orchard.ContentTypes.ViewModels {
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public EditPartFieldViewModel(int index, ContentPartDefinition.Field field) {
|
||||
public EditPartFieldViewModel(int index, ContentPartFieldDefinition field) {
|
||||
Index = index;
|
||||
Name = field.Name;
|
||||
FieldDefinition = new EditFieldViewModel(field.FieldDefinition);
|
||||
@@ -108,7 +108,7 @@ namespace Orchard.ContentTypes.ViewModels {
|
||||
public IEnumerable<TemplateViewModel> Templates { get; set; }
|
||||
public EditFieldViewModel FieldDefinition { get; set; }
|
||||
public SettingsDictionary Settings { get; set; }
|
||||
public ContentPartDefinition.Field _Definition { get; private set; }
|
||||
public ContentPartFieldDefinition _Definition { get; private set; }
|
||||
}
|
||||
|
||||
public class EditFieldViewModel {
|
||||
|
@@ -19,12 +19,12 @@ namespace Orchard.Indexing.Settings {
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartDefinition.Field definition) {
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
|
||||
var model = definition.Settings.GetModel<FieldIndexing>();
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartDefinitionBuilder.FieldConfigurer builder, IUpdateModel updateModel) {
|
||||
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||
var model = new FieldIndexing();
|
||||
updateModel.TryUpdateModel(model, "FieldIndexing", null, null);
|
||||
builder.WithSetting("FieldIndexing.Included", model.Included ? true.ToString() : null);
|
||||
|
@@ -6,7 +6,7 @@ namespace Orchard.ContentManagement {
|
||||
public class ContentField {
|
||||
public string Name { get { return PartFieldDefinition.Name; } }
|
||||
|
||||
public ContentPartDefinition.Field PartFieldDefinition { get; set; }
|
||||
public ContentPartFieldDefinition PartFieldDefinition { get; set; }
|
||||
public ContentFieldDefinition FieldDefinition { get { return PartFieldDefinition.FieldDefinition; } }
|
||||
|
||||
public IFieldStorage Storage { get; set; }
|
||||
|
@@ -14,7 +14,7 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
public virtual ContentItem ContentItem { get; set; }
|
||||
public ContentTypeDefinition TypeDefinition { get { return ContentItem.TypeDefinition; } }
|
||||
public ContentTypeDefinition.Part TypePartDefinition { get; set; }
|
||||
public ContentTypePartDefinition TypePartDefinition { get; set; }
|
||||
public ContentPartDefinition PartDefinition { get { return TypePartDefinition.PartDefinition; } }
|
||||
public SettingsDictionary Settings { get { return TypePartDefinition.Settings; } }
|
||||
|
||||
|
@@ -13,7 +13,7 @@ namespace Orchard.ContentManagement.FieldStorage {
|
||||
_storageProviders = storageProviders;
|
||||
}
|
||||
|
||||
public IFieldStorageProvider GetProvider(ContentPartDefinition.Field partFieldDefinition) {
|
||||
public IFieldStorageProvider GetProvider(ContentPartFieldDefinition partFieldDefinition) {
|
||||
|
||||
IFieldStorageProvider provider = null;
|
||||
|
||||
|
@@ -6,6 +6,6 @@ namespace Orchard.ContentManagement.FieldStorage {
|
||||
|
||||
IFieldStorage BindStorage(
|
||||
ContentPart contentPart,
|
||||
ContentPartDefinition.Field partFieldDefinition);
|
||||
ContentPartFieldDefinition partFieldDefinition);
|
||||
}
|
||||
}
|
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace Orchard.ContentManagement.FieldStorage {
|
||||
public interface IFieldStorageProviderSelector : IDependency {
|
||||
IFieldStorageProvider GetProvider(ContentPartDefinition.Field partFieldDefinition);
|
||||
IFieldStorageProvider GetProvider(ContentPartFieldDefinition partFieldDefinition);
|
||||
}
|
||||
}
|
@@ -8,7 +8,7 @@ namespace Orchard.ContentManagement.FieldStorage.InfosetStorage {
|
||||
get { return FieldStorageProviderSelector.DefaultProviderName; }
|
||||
}
|
||||
|
||||
public IFieldStorage BindStorage(ContentPart contentPart, ContentPartDefinition.Field partFieldDefinition) {
|
||||
public IFieldStorage BindStorage(ContentPart contentPart, ContentPartFieldDefinition partFieldDefinition) {
|
||||
var partName = XmlConvert.EncodeLocalName(contentPart.PartDefinition.Name);
|
||||
var fieldName = XmlConvert.EncodeLocalName(partFieldDefinition.Name);
|
||||
var infosetPart = contentPart.As<InfosetPart>();
|
||||
|
@@ -23,7 +23,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
|
||||
var typePartDefinition = _definition.Parts.FirstOrDefault(p => p.PartDefinition.Name == partName);
|
||||
if (typePartDefinition == null) {
|
||||
typePartDefinition = new ContentTypeDefinition.Part(
|
||||
typePartDefinition = new ContentTypePartDefinition(
|
||||
new ContentPartDefinition(partName),
|
||||
new SettingsDictionary());
|
||||
|
||||
|
@@ -7,7 +7,7 @@ using Orchard.ContentManagement.MetaData.Models;
|
||||
namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
public class ContentPartDefinitionBuilder {
|
||||
private string _name;
|
||||
private readonly IList<ContentPartDefinition.Field> _fields;
|
||||
private readonly IList<ContentPartFieldDefinition> _fields;
|
||||
private readonly SettingsDictionary _settings;
|
||||
|
||||
public ContentPartDefinitionBuilder()
|
||||
@@ -16,7 +16,7 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
|
||||
public ContentPartDefinitionBuilder(ContentPartDefinition existing) {
|
||||
if (existing == null) {
|
||||
_fields = new List<ContentPartDefinition.Field>();
|
||||
_fields = new List<ContentPartFieldDefinition>();
|
||||
_settings = new SettingsDictionary();
|
||||
}
|
||||
else {
|
||||
@@ -54,7 +54,7 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
return WithField(fieldName, configuration => { });
|
||||
}
|
||||
|
||||
public ContentPartDefinitionBuilder WithField(string fieldName, Action<FieldConfigurer> configuration) {
|
||||
public ContentPartDefinitionBuilder WithField(string fieldName, Action<ContentPartFieldDefinitionBuilder> configuration) {
|
||||
|
||||
var existingField = _fields.FirstOrDefault(x => x.Name == fieldName);
|
||||
if (existingField != null) {
|
||||
@@ -64,7 +64,7 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
}
|
||||
}
|
||||
else {
|
||||
existingField = new ContentPartDefinition.Field(fieldName);
|
||||
existingField = new ContentPartFieldDefinition(fieldName);
|
||||
}
|
||||
var configurer = new FieldConfigurerImpl(existingField);
|
||||
configuration(configurer);
|
||||
@@ -72,42 +72,26 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract class FieldConfigurer {
|
||||
protected readonly SettingsDictionary _settings;
|
||||
|
||||
protected FieldConfigurer(ContentPartDefinition.Field field) {
|
||||
_settings = new SettingsDictionary(field.Settings.ToDictionary(kv => kv.Key, kv => kv.Value));
|
||||
}
|
||||
|
||||
public FieldConfigurer WithSetting(string name, string value) {
|
||||
_settings[name] = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract FieldConfigurer OfType(ContentFieldDefinition fieldDefinition);
|
||||
public abstract FieldConfigurer OfType(string fieldType);
|
||||
}
|
||||
|
||||
class FieldConfigurerImpl : FieldConfigurer {
|
||||
class FieldConfigurerImpl : ContentPartFieldDefinitionBuilder {
|
||||
private ContentFieldDefinition _fieldDefinition;
|
||||
private readonly string _fieldName;
|
||||
|
||||
public FieldConfigurerImpl(ContentPartDefinition.Field field)
|
||||
public FieldConfigurerImpl(ContentPartFieldDefinition field)
|
||||
: base(field) {
|
||||
_fieldDefinition = field.FieldDefinition;
|
||||
_fieldName = field.Name;
|
||||
}
|
||||
|
||||
public ContentPartDefinition.Field Build() {
|
||||
return new ContentPartDefinition.Field(_fieldDefinition, _fieldName, _settings);
|
||||
public ContentPartFieldDefinition Build() {
|
||||
return new ContentPartFieldDefinition(_fieldDefinition, _fieldName, _settings);
|
||||
}
|
||||
|
||||
public override FieldConfigurer OfType(ContentFieldDefinition fieldDefinition) {
|
||||
public override ContentPartFieldDefinitionBuilder OfType(ContentFieldDefinition fieldDefinition) {
|
||||
_fieldDefinition = fieldDefinition;
|
||||
return this;
|
||||
}
|
||||
|
||||
public override FieldConfigurer OfType(string fieldType) {
|
||||
public override ContentPartFieldDefinitionBuilder OfType(string fieldType) {
|
||||
_fieldDefinition = new ContentFieldDefinition(fieldType);
|
||||
return this;
|
||||
}
|
||||
@@ -147,13 +131,13 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static ContentTypeDefinitionBuilder.PartConfigurer WithLocation(this ContentTypeDefinitionBuilder.PartConfigurer obj, IDictionary<string, ContentLocation> settings) {
|
||||
public static ContentTypePartDefinitionBuilder WithLocation(this ContentTypePartDefinitionBuilder obj, IDictionary<string, ContentLocation> settings) {
|
||||
foreach (var entry in GetSettingEntries(settings))
|
||||
obj = obj.WithSetting(entry.Key, entry.Value);
|
||||
return obj;
|
||||
}
|
||||
|
||||
public static ContentPartDefinitionBuilder.FieldConfigurer WithLocation(this ContentPartDefinitionBuilder.FieldConfigurer obj, IDictionary<string, ContentLocation> settings) {
|
||||
public static ContentPartFieldDefinitionBuilder WithLocation(this ContentPartFieldDefinitionBuilder obj, IDictionary<string, ContentLocation> settings) {
|
||||
foreach (var entry in GetSettingEntries(settings))
|
||||
obj = obj.WithSetting(entry.Key, entry.Value);
|
||||
return obj;
|
||||
|
@@ -0,0 +1,20 @@
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
public abstract class ContentPartFieldDefinitionBuilder {
|
||||
protected readonly SettingsDictionary _settings;
|
||||
|
||||
protected ContentPartFieldDefinitionBuilder(ContentPartFieldDefinition field) {
|
||||
_settings = new SettingsDictionary(field.Settings.ToDictionary(kv => kv.Key, kv => kv.Value));
|
||||
}
|
||||
|
||||
public ContentPartFieldDefinitionBuilder WithSetting(string name, string value) {
|
||||
_settings[name] = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract ContentPartFieldDefinitionBuilder OfType(ContentFieldDefinition fieldDefinition);
|
||||
public abstract ContentPartFieldDefinitionBuilder OfType(string fieldType);
|
||||
}
|
||||
}
|
@@ -7,7 +7,7 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
public class ContentTypeDefinitionBuilder {
|
||||
private string _name;
|
||||
private string _displayName;
|
||||
private readonly IList<ContentTypeDefinition.Part> _parts;
|
||||
private readonly IList<ContentTypePartDefinition> _parts;
|
||||
private readonly SettingsDictionary _settings;
|
||||
|
||||
public ContentTypeDefinitionBuilder()
|
||||
@@ -16,7 +16,7 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
|
||||
public ContentTypeDefinitionBuilder(ContentTypeDefinition existing) {
|
||||
if (existing == null) {
|
||||
_parts = new List<ContentTypeDefinition.Part>();
|
||||
_parts = new List<ContentTypePartDefinition>();
|
||||
_settings = new SettingsDictionary();
|
||||
}
|
||||
else {
|
||||
@@ -62,17 +62,17 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
return WithPart(partName, configuration => { });
|
||||
}
|
||||
|
||||
public ContentTypeDefinitionBuilder WithPart(string partName, Action<PartConfigurer> configuration) {
|
||||
public ContentTypeDefinitionBuilder WithPart(string partName, Action<ContentTypePartDefinitionBuilder> configuration) {
|
||||
return WithPart(new ContentPartDefinition(partName), configuration);
|
||||
}
|
||||
|
||||
public ContentTypeDefinitionBuilder WithPart(ContentPartDefinition partDefinition, Action<PartConfigurer> configuration) {
|
||||
public ContentTypeDefinitionBuilder WithPart(ContentPartDefinition partDefinition, Action<ContentTypePartDefinitionBuilder> configuration) {
|
||||
var existingPart = _parts.SingleOrDefault(x => x.PartDefinition.Name == partDefinition.Name);
|
||||
if (existingPart != null) {
|
||||
_parts.Remove(existingPart);
|
||||
}
|
||||
else {
|
||||
existingPart = new ContentTypeDefinition.Part(partDefinition, new SettingsDictionary());
|
||||
existingPart = new ContentTypePartDefinition(partDefinition, new SettingsDictionary());
|
||||
}
|
||||
var configurer = new PartConfigurerImpl(existingPart);
|
||||
configuration(configurer);
|
||||
@@ -80,32 +80,16 @@ namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract class PartConfigurer {
|
||||
protected readonly SettingsDictionary _settings;
|
||||
|
||||
protected PartConfigurer(ContentTypeDefinition.Part part) {
|
||||
Name = part.PartDefinition.Name;
|
||||
_settings = new SettingsDictionary(part.Settings.ToDictionary(kv => kv.Key, kv => kv.Value));
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public PartConfigurer WithSetting(string name, string value) {
|
||||
_settings[name] = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class PartConfigurerImpl : PartConfigurer {
|
||||
class PartConfigurerImpl : ContentTypePartDefinitionBuilder {
|
||||
private readonly ContentPartDefinition _partDefinition;
|
||||
|
||||
public PartConfigurerImpl(ContentTypeDefinition.Part part)
|
||||
public PartConfigurerImpl(ContentTypePartDefinition part)
|
||||
: base(part) {
|
||||
_partDefinition = part.PartDefinition;
|
||||
}
|
||||
|
||||
public ContentTypeDefinition.Part Build() {
|
||||
return new ContentTypeDefinition.Part(_partDefinition, _settings);
|
||||
public ContentTypePartDefinition Build() {
|
||||
return new ContentTypePartDefinition(_partDefinition, _settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,20 @@
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData.Builders {
|
||||
public abstract class ContentTypePartDefinitionBuilder {
|
||||
protected readonly SettingsDictionary _settings;
|
||||
|
||||
protected ContentTypePartDefinitionBuilder(ContentTypePartDefinition part) {
|
||||
Name = part.PartDefinition.Name;
|
||||
_settings = new SettingsDictionary(part.Settings.ToDictionary(kv => kv.Key, kv => kv.Value));
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public ContentTypePartDefinitionBuilder WithSetting(string name, string value) {
|
||||
_settings[name] = value;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,6 +5,6 @@ using Orchard.ContentManagement.MetaData.Models;
|
||||
namespace Orchard.ContentManagement.MetaData {
|
||||
public class ContentFieldInfo {
|
||||
public string FieldTypeName { get; set; }
|
||||
public Func<ContentPartDefinition.Field, IFieldStorage, ContentField> Factory { get; set; }
|
||||
public Func<ContentPartFieldDefinition, IFieldStorage, ContentField> Factory { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,6 @@ using Orchard.ContentManagement.MetaData.Models;
|
||||
namespace Orchard.ContentManagement.MetaData {
|
||||
public class ContentPartInfo {
|
||||
public string PartName { get; set; }
|
||||
public Func<ContentTypeDefinition.Part, ContentPart> Factory { get; set; }
|
||||
public Func<ContentTypePartDefinition, ContentPart> Factory { get; set; }
|
||||
}
|
||||
}
|
||||
|
@@ -8,14 +8,14 @@ using Orchard.Events;
|
||||
namespace Orchard.ContentManagement.MetaData {
|
||||
public interface IContentDefinitionEditorEvents : IEventHandler {
|
||||
IEnumerable<TemplateViewModel> TypeEditor(ContentTypeDefinition definition);
|
||||
IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition);
|
||||
IEnumerable<TemplateViewModel> TypePartEditor(ContentTypePartDefinition definition);
|
||||
IEnumerable<TemplateViewModel> PartEditor(ContentPartDefinition definition);
|
||||
IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartDefinition.Field definition);
|
||||
IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition);
|
||||
|
||||
IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel);
|
||||
IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel);
|
||||
IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel);
|
||||
IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel);
|
||||
IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartDefinitionBuilder.FieldConfigurer builder, IUpdateModel updateModel);
|
||||
IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel);
|
||||
}
|
||||
|
||||
public abstract class ContentDefinitionEditorEventsBase : IContentDefinitionEditorEvents {
|
||||
@@ -23,7 +23,7 @@ namespace Orchard.ContentManagement.MetaData {
|
||||
return Enumerable.Empty<TemplateViewModel>();
|
||||
}
|
||||
|
||||
public virtual IEnumerable<TemplateViewModel> TypePartEditor(ContentTypeDefinition.Part definition) {
|
||||
public virtual IEnumerable<TemplateViewModel> TypePartEditor(ContentTypePartDefinition definition) {
|
||||
return Enumerable.Empty<TemplateViewModel>();
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.ContentManagement.MetaData {
|
||||
return Enumerable.Empty<TemplateViewModel>();
|
||||
}
|
||||
|
||||
public virtual IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartDefinition.Field definition) {
|
||||
public virtual IEnumerable<TemplateViewModel> PartFieldEditor(ContentPartFieldDefinition definition) {
|
||||
return Enumerable.Empty<TemplateViewModel>();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Orchard.ContentManagement.MetaData {
|
||||
return Enumerable.Empty<TemplateViewModel>();
|
||||
}
|
||||
|
||||
public virtual IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypeDefinitionBuilder.PartConfigurer builder, IUpdateModel updateModel) {
|
||||
public virtual IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||
return Enumerable.Empty<TemplateViewModel>();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Orchard.ContentManagement.MetaData {
|
||||
return Enumerable.Empty<TemplateViewModel>();
|
||||
}
|
||||
|
||||
public virtual IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartDefinitionBuilder.FieldConfigurer builder, IUpdateModel updateModel) {
|
||||
public virtual IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
|
||||
return Enumerable.Empty<TemplateViewModel>();
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@ using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData.Models {
|
||||
public class ContentPartDefinition {
|
||||
public ContentPartDefinition(string name, IEnumerable<Field> fields, SettingsDictionary settings) {
|
||||
public ContentPartDefinition(string name, IEnumerable<ContentPartFieldDefinition> fields, SettingsDictionary settings) {
|
||||
Name = name;
|
||||
Fields = fields.ToReadOnlyCollection();
|
||||
Settings = settings;
|
||||
@@ -12,29 +12,12 @@ namespace Orchard.ContentManagement.MetaData.Models {
|
||||
|
||||
public ContentPartDefinition(string name) {
|
||||
Name = name;
|
||||
Fields = Enumerable.Empty<Field>();
|
||||
Fields = Enumerable.Empty<ContentPartFieldDefinition>();
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public IEnumerable<Field> Fields { get; private set; }
|
||||
public IEnumerable<ContentPartFieldDefinition> Fields { get; private set; }
|
||||
public SettingsDictionary Settings { get; private set; }
|
||||
|
||||
public class Field {
|
||||
public Field(string name) {
|
||||
Name = name;
|
||||
FieldDefinition = new ContentFieldDefinition(null);
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
public Field( ContentFieldDefinition contentFieldDefinition, string name, SettingsDictionary settings) {
|
||||
Name = name;
|
||||
FieldDefinition = contentFieldDefinition;
|
||||
Settings = settings;
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public ContentFieldDefinition FieldDefinition { get; private set; }
|
||||
public SettingsDictionary Settings { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,18 @@
|
||||
namespace Orchard.ContentManagement.MetaData.Models {
|
||||
public class ContentPartFieldDefinition {
|
||||
public ContentPartFieldDefinition(string name) {
|
||||
Name = name;
|
||||
FieldDefinition = new ContentFieldDefinition(null);
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
public ContentPartFieldDefinition( ContentFieldDefinition contentFieldDefinition, string name, SettingsDictionary settings) {
|
||||
Name = name;
|
||||
FieldDefinition = contentFieldDefinition;
|
||||
Settings = settings;
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public ContentFieldDefinition FieldDefinition { get; private set; }
|
||||
public SettingsDictionary Settings { get; private set; }
|
||||
}
|
||||
}
|
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
|
||||
namespace Orchard.ContentManagement.MetaData.Models {
|
||||
public class ContentTypeDefinition {
|
||||
public ContentTypeDefinition(string name, string displayName, IEnumerable<Part> parts, SettingsDictionary settings) {
|
||||
public ContentTypeDefinition(string name, string displayName, IEnumerable<ContentTypePartDefinition> parts, SettingsDictionary settings) {
|
||||
Name = name;
|
||||
DisplayName = displayName;
|
||||
Parts = parts;
|
||||
@@ -14,7 +14,7 @@ namespace Orchard.ContentManagement.MetaData.Models {
|
||||
public ContentTypeDefinition(string name, string displayName) {
|
||||
Name = name;
|
||||
DisplayName = displayName;
|
||||
Parts = Enumerable.Empty<Part>();
|
||||
Parts = Enumerable.Empty<ContentTypePartDefinition>();
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
@@ -22,22 +22,7 @@ namespace Orchard.ContentManagement.MetaData.Models {
|
||||
public string Name { get; private set; }
|
||||
[Required, StringLength(1024)]
|
||||
public string DisplayName { get; private set; }
|
||||
public IEnumerable<Part> Parts { get; private set; }
|
||||
public IEnumerable<ContentTypePartDefinition> Parts { get; private set; }
|
||||
public SettingsDictionary Settings { get; private set; }
|
||||
|
||||
public class Part {
|
||||
|
||||
public Part(ContentPartDefinition contentPartDefinition, SettingsDictionary settings) {
|
||||
PartDefinition = contentPartDefinition;
|
||||
Settings = settings;
|
||||
}
|
||||
|
||||
public Part() {
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public ContentPartDefinition PartDefinition { get; private set; }
|
||||
public SettingsDictionary Settings { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,16 @@
|
||||
namespace Orchard.ContentManagement.MetaData.Models {
|
||||
public class ContentTypePartDefinition {
|
||||
|
||||
public ContentTypePartDefinition(ContentPartDefinition contentPartDefinition, SettingsDictionary settings) {
|
||||
PartDefinition = contentPartDefinition;
|
||||
Settings = settings;
|
||||
}
|
||||
|
||||
public ContentTypePartDefinition() {
|
||||
Settings = new SettingsDictionary();
|
||||
}
|
||||
|
||||
public ContentPartDefinition PartDefinition { get; private set; }
|
||||
public SettingsDictionary Settings { get; private set; }
|
||||
}
|
||||
}
|
@@ -312,12 +312,16 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ContentManagement\MetaData\Builders\ContentPartDefinitionBuilder.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Builders\ContentPartFieldDefinitionBuilder.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Builders\ContentTypeDefinitionBuilder.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Builders\ContentTypePartDefinitionBuilder.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\ContentFieldInfo.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\ContentPartInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ContentManagement\MetaData\IContentDefinitionEditorEvents.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Models\ContentPartFieldDefinition.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Models\ContentTypePartDefinition.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Models\SettingsDictionary.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\Services\ContentDefinitionWriter.cs" />
|
||||
<Compile Include="ContentManagement\MetaData\IContentDefinitionManager.cs" />
|
||||
|
Reference in New Issue
Block a user