/// <summary> /// Sets parent ID for content type inheritance /// </summary> /// <param name="itemType"></param> /// <param name="ct"></param> protected void SetParent(IContentTypeComposition ct, Type itemType) { var parentAttr = itemType.BaseType.GetCustomAttributes().FirstOrDefault(x => x is BaseContentTypeAttribute) as BaseContentTypeAttribute; if (parentAttr != null) { ct.SetLazyParentId(new Lazy <int>(() => GetByAlias(itemType.BaseType.Name).Id)); ct.AddContentType(GetByAlias(itemType.BaseType.Name)); } }
private static void MapComposition(ContentTypeSave source, IContentTypeComposition target, Func <string, IContentTypeComposition> getContentType) { var current = target.CompositionAliases().ToArray(); var proposed = source.CompositeContentTypes; var remove = current.Where(x => !proposed.Contains(x)); var add = proposed.Where(x => !current.Contains(x)); foreach (var alias in remove) { target.RemoveContentType(alias); } foreach (var alias in add) { // TODO: Remove N+1 lookup var contentType = getContentType(alias); if (contentType != null) { target.AddContentType(contentType); } } }