Table of Contents

Class InheritanceAttribute

Namespace
Dynamicweb.Content.Items.Annotations
Assembly
Dynamicweb.dll

Provides information about the item inheritance.

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class InheritanceAttribute : Attribute
Inheritance
InheritanceAttribute
Inherited Members

Examples

using System.Collections.Generic;
using Dynamicweb.Content.Items;
using Dynamicweb.Content.Items.Activation;
using Dynamicweb.Content.Items.Annotations;
using Dynamicweb.Content.Items.Editors;
using Dynamicweb.Core.UI.Icons;

namespace Dynamicweb.Examples.Items;

[Inheritance]
[Item("Product news item", "The example of code-first item with inheritance")]
[AreaRule,
 StructureRule(StructureContextType.Pages),
 ParentRule(ParentRestrictionRule.ParentType.RootOfWebsite, ParentRestrictionRule.ParentType.RegularPage)]
[Category("Example")]
[Icon(KnownIcon.Message)]
[TitlePattern("Product news {{Title}}")]
public class ExampleProductNewsItem : ExampleNewsItem
{
    [Group("Product")]
    [File("Product Image", "/Images/Products", "gif,jpg,png")]
    public string ProductImage { get; set; } = "";

    [Group("Product")]
    [EditableList("Comments")]
    public string Comments { get; set; } = "";

    [Group("Product")]
    [Field("Related products", typeof(CheckboxListEditor<string>))]
    [OptionSql("SELECT TOP 10 ProductId, ProductName FROM EcomProducts WHERE ProductPrice > 1000", "ProductName", "ProductId")]
    public IEnumerable<string> RelatedProducts { get; set; } = [];

    [Group("Special")]
    [Checkbox]
    public bool RunExamples { get; set; }

    public override void Save(ItemContext? context)
    {
        if (RunExamples)
        {
            Title = "Item is saved";
        }

        base.Save(context);
    }
}

Constructors

InheritanceAttribute()

Initializes a new instance of an object.

public InheritanceAttribute()
To top