mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
- Modifying Has and Get methods of the ContentPart, parts can contain multiple fields of the same type.
--HG-- branch : dev
This commit is contained in:
@@ -5,7 +5,7 @@ using Orchard.ContentManagement.Utilities;
|
||||
namespace Orchard.ContentManagement {
|
||||
public class ContentField : ContentPart {
|
||||
public virtual ContentPart ContentPart { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Name { get { return PartFieldDefinition.Name; } }
|
||||
public IDictionary<string, string> Settings { get; private set; }
|
||||
|
||||
public new ContentPartDefinition PartDefinition { get { return ContentPart.PartDefinition; } }
|
||||
|
@@ -20,14 +20,14 @@ namespace Orchard.ContentManagement {
|
||||
public IEnumerable<ContentField> Fields { get { return _fields; } }
|
||||
|
||||
|
||||
public bool Has(Type fieldType) {
|
||||
return fieldType == typeof(ContentItem) || _fields.Any(field => fieldType.IsAssignableFrom(field.GetType()));
|
||||
public bool Has(Type fieldType, string fieldName) {
|
||||
return fieldType == typeof(ContentItem) || _fields.Any(field => fieldType.IsAssignableFrom(field.GetType()) && field.Name == fieldName);
|
||||
}
|
||||
|
||||
public IContent Get(Type fieldType) {
|
||||
public IContent Get(Type fieldType, string fieldName) {
|
||||
if (fieldType == typeof(ContentItem))
|
||||
return this;
|
||||
return _fields.FirstOrDefault(field => fieldType.IsAssignableFrom(field.GetType()));
|
||||
return _fields.FirstOrDefault(field => fieldType.IsAssignableFrom(field.GetType()) && field.Name == fieldName);
|
||||
}
|
||||
|
||||
public void Weld(ContentField field) {
|
||||
|
Reference in New Issue
Block a user