- 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:
Suha Can
2010-06-11 11:32:46 -07:00
parent 3aa7683e3a
commit 699987217f
2 changed files with 5 additions and 5 deletions

View File

@@ -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; } }

View File

@@ -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) {