Exemple #1
0
 private void GuardAgainstDuplicatePropertyInInheritingContentTypes(ContentTypeProperty property)
 {
     if (InheritingContentTypes.Any(t => t.Name.Equals(property.Name)))
     {
         throw new ArgumentException(String.Format("The content type {0} has inheriting content types that already contains a property named {1}", Name, property.Name));
     }
 }
Exemple #2
0
        private ContentTypeProperty AddProperty(ContentTypeProperty property)
        {
            GuardAgainstDuplicateProperty(property);
            GuardAgainstDuplicatePropertyInInheritingContentTypes(property);

            _properties.Add(property.Name, property);

            //Tous les type enfants doivent avoir une InheritedContentTypeProperty
            //Il se peut qu'un type enfant ait déjà une propriété du même nom

            var inheritingContentTypes = InheritingContentTypes.ToList();

            while (inheritingContentTypes.Any())
            {
                inheritingContentTypes.ForEach(c => c.AddInheritedProperty(c.BaseContentType[property.Name]));
                inheritingContentTypes = inheritingContentTypes.SelectMany(t => t.InheritingContentTypes).ToList();
            }

            return(property);
        }