public static void AlterTypeDefinition(this IContentDefinitionManager manager, string name, Action<ContentTypeDefinitionBuilder> alteration) { var typeDefinition = manager.GetTypeDefinition(name) ?? new ContentTypeDefinition(name, name.CamelFriendly()); var builder = new ContentTypeDefinitionBuilder(typeDefinition); alteration(builder); manager.StoreTypeDefinition(builder.Build()); }
public virtual ContentItem New(string contentType) { var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentType); if (contentTypeDefinition == null) { contentTypeDefinition = new ContentTypeDefinitionBuilder().Named(contentType).Build(); } // create a new kernel for the model instance var context = new ActivatingContentContext { ContentType = contentTypeDefinition.Name, Definition = contentTypeDefinition, Builder = new ContentItemBuilder(contentTypeDefinition) }; // invoke handlers to weld aspects onto kernel Handlers.Invoke(handler => handler.Activating(context), _logger); var context2 = new ActivatedContentContext { ContentType = contentType, ContentItem = context.Builder.Build() }; context2.ContentItem.ContentItemId = (int)_idGenerator.GetNextId(); Handlers.Invoke(handler => handler.Activated(context2), _logger); var context3 = new InitializingContentContext { ContentType = context2.ContentType, ContentItem = context2.ContentItem, }; Handlers.Invoke(handler => handler.Initializing(context3), _logger); Handlers.Invoke(handler => handler.Initialized(context3), _logger); // composite result is returned return context3.ContentItem; }