void IContentPartHandler.Activating(ActivatingContentContext context, ContentPart part)
 {
     if (part is TPart)
     {
         Activating(context, (TPart)part);
     }
 }
        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()
            };

            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;
        }
Example #3
0
 public void Activating(ActivatingContentContext context)
 {
     if (_predicate(context.ContentType))
     {
         context.Builder.Weld <TPart>();
     }
 }
Example #4
0
 void IContentHandler.Activating(ActivatingContentContext context)
 {
     foreach (var filter in Filters.OfType <IContentActivatingFilter>())
     {
         filter.Activating(context);
     }
     Activating(context);
 }
Example #5
0
        protected override void Activating(ActivatingContentContext context) {
            base.Activating(context);

            // weld the FieldIndexPart dynamically, if a field has been assigned to one of its parts
            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentType);
            if (contentTypeDefinition == null)
                return;
            if (contentTypeDefinition.Parts.Any(p => p.PartDefinition.Fields.Any())) {
                context.Builder.Weld<FieldIndexPart>();
            }
        }
        protected override void Activating(ActivatingContentContext context)
        {
            base.Activating(context);

            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentType);
            if (contentTypeDefinition == null)
                return;

            // If has part SchedulingPart, weld the NotificationsPart
            if (contentTypeDefinition.Parts.Any(p => p.PartDefinition.Name == typeof(SchedulingPart).Name)) {
                context.Builder.Weld<NotificationsPart>();
            }
        }
        public override void Activating(ActivatingContentContext context) {
            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentType);
            if (contentTypeDefinition == null)
                return;

            var partInfos = _drivers.SelectMany(cpp => cpp.GetPartInfo()).ToList();

            foreach (var typePartDefinition in contentTypeDefinition.Parts) {
                var partName = typePartDefinition.PartDefinition.Name;
                var partInfo = partInfos.FirstOrDefault(pi => pi.PartName == partName);
                var part = partInfo != null 
                    ? partInfo.Factory(typePartDefinition) 
                    : new ContentPart { TypePartDefinition = typePartDefinition };
                context.Builder.Weld(part);
            }
        }
Example #8
0
        protected override void Activating(ActivatingContentContext context) {
            base.Activating(context);

            // weld the TermsPart dynamically, if a field has been assigned to one of its parts
            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentType);
            if (contentTypeDefinition == null) {
                return;
            }

            if (contentTypeDefinition.Parts.Any(
                    part => part.PartDefinition.Fields.Any(
                        field => field.FieldDefinition.Name == typeof(TaxonomyField).Name))) {
                
                context.Builder.Weld<TermsPart>();
            }
        }
        protected override void Activating(ActivatingContentContext context)
        {
            var contentTypeRecord = _contentTypeService.GetContentTypeRecord(context.ContentType);
            if (contentTypeRecord == null)
                return;

            var contentPartInfos = _contentPartDrivers.SelectMany(cpp => cpp.GetPartInfo()).ToList();

            foreach (var contentTypePartRecord in contentTypeRecord.ContentParts) {
                // We might have a part in the database, but the corresponding feature might not
                // be enabled anymore, so we need to be resilient to that situation.
                var contentPartInfo = contentPartInfos.SingleOrDefault(x => x.PartName == contentTypePartRecord.PartName.PartName);
                if (contentPartInfo != null) {
                    context.Builder.Weld(contentPartInfo.Factory());
                }
            }
        }
        public override void Activating(ActivatingContentContext context)
        {
            // This method is called on New()
            // Adds all the parts to a content item based on the content type definition.

            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(context.ContentType);
            if (contentTypeDefinition == null)
                return;

            var partInfos = _partDrivers.Select(cpp => cpp.GetPartInfo()).ToArray();

            foreach (var typePartDefinition in contentTypeDefinition.Parts)
            {
                var partName = typePartDefinition.PartDefinition.Name;
                var partInfo = partInfos.FirstOrDefault(pi => pi.PartName == partName);
                var part = partInfo != null
                    ? partInfo.Factory(typePartDefinition)
                    : new ContentPart();

                context.Builder.Weld(partName, part);
            }
        }
        protected override void Activating(ActivatingContentContext context)
        {
            if (!HasMenuItemStereotype(context.ContentType)) return;

            // Menu items have to be draftable
            var definition = _contentDefinitionManager.GetTypeDefinition(context.ContentType);

            // Need to auto-weld those parts as menu items may get created after installing the module...
            if (definition.Parts.All(p => p.PartDefinition.Name != "ExtendedMenuItemPart")) {
                context.Builder.Weld<ExtendedMenuItemPart>();
            }
            if (definition.Parts.All(p => p.PartDefinition.Name != "MenuPart")) {
                context.Builder.Weld<MenuPart>();
            }
            if (definition.Parts.All(p => p.PartDefinition.Name != "VersionInfoPart")) {
                context.Builder.Weld<VersionInfoPart>();
            }

            string draftable;
            if (!definition.Settings.TryGetValue("ContentTypeSettings.Draftable", out draftable) || draftable.Equals("false", StringComparison.OrdinalIgnoreCase)) {
                _contentDefinitionManager.AlterTypeDefinition(context.ContentType, cfg => cfg.Draftable());
            }
        }
Example #12
0
 protected override void Activating(ActivatingContentContext context) {
     if (ContentTypeWithACommonPart(context.ContentType))
         context.Builder.Weld<ContentPart<CommonPartVersionRecord>>();
 }
Example #13
0
 protected virtual void Activating(ActivatingContentContext context)
 {
 }
Example #14
0
 public virtual void Activating(ActivatingContentContext context, TPart instance)
 {
 }
Example #15
0
 protected override void Activating(ActivatingContentContext context) {
     if (context.ContentType == "beta") {
         context.Builder.Weld<Beta>();
     }
 }
 public void Activating(ActivatingContentContext context)
 {
 }
Example #17
0
 public override void Activating(ActivatingContentContext context)
 {
     context.Builder.Weld<TestContentPartA>();
 }
Example #18
0
 public virtual void Activating(ActivatingContentContext context)
 {
 }
Example #19
0
 protected override void Activating(ActivatingContentContext context) {
     if (context.ContentType == "alpha") {
         context.Builder.Weld<StyledPart>();
     }
 }
Example #20
0
 public override void Activating(ActivatingContentContext context) {
     context.Builder.Weld<InfosetPart>();
 }
 void IContentHandler.Activating(ActivatingContentContext context)
 {
 }
Example #22
0
 protected override void Activating(ActivatingContentContext context) {
     if (context.ContentType == "beta" || context.ContentType == "alpha") {
         context.Builder.Weld<Flavored>();
     }
 }