Exemplo n.º 1
0
 void IContentPartHandler.Activating(ActivatingContentContext context, ContentPart part)
 {
     if (part is TPart)
     {
         Activating(context, (TPart)part);
     }
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
 public void Activating(ActivatingContentContext context)
 {
     if (_predicate(context.ContentType))
     {
         context.Builder.Weld <TPart>();
     }
 }
Exemplo n.º 4
0
 void IContentHandler.Activating(ActivatingContentContext context)
 {
     foreach (var filter in Filters.OfType <IContentActivatingFilter>())
     {
         filter.Activating(context);
     }
     Activating(context);
 }
Exemplo n.º 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>();
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 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>();
            }
        }
Exemplo n.º 9
0
        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());
            }
        }
Exemplo n.º 12
0
 protected override void Activating(ActivatingContentContext context) {
     if (ContentTypeWithACommonPart(context.ContentType))
         context.Builder.Weld<ContentPart<CommonPartVersionRecord>>();
 }
Exemplo n.º 13
0
 protected virtual void Activating(ActivatingContentContext context)
 {
 }
Exemplo n.º 14
0
 public virtual void Activating(ActivatingContentContext context, TPart instance)
 {
 }
Exemplo n.º 15
0
 protected override void Activating(ActivatingContentContext context) {
     if (context.ContentType == "beta") {
         context.Builder.Weld<Beta>();
     }
 }
 public void Activating(ActivatingContentContext context)
 {
 }
Exemplo n.º 17
0
 public override void Activating(ActivatingContentContext context)
 {
     context.Builder.Weld<TestContentPartA>();
 }
Exemplo n.º 18
0
 public virtual void Activating(ActivatingContentContext context)
 {
 }
Exemplo n.º 19
0
 protected override void Activating(ActivatingContentContext context) {
     if (context.ContentType == "alpha") {
         context.Builder.Weld<StyledPart>();
     }
 }
Exemplo n.º 20
0
 public override void Activating(ActivatingContentContext context) {
     context.Builder.Weld<InfosetPart>();
 }
 void IContentHandler.Activating(ActivatingContentContext context)
 {
 }
Exemplo n.º 22
0
 protected override void Activating(ActivatingContentContext context) {
     if (context.ContentType == "beta" || context.ContentType == "alpha") {
         context.Builder.Weld<Flavored>();
     }
 }