Beispiel #1
0
        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);
                }
            }
        }