Below, we show how attributes are used to associate a content data class with its summary class:
[SummaryType(typeof(ArticleSummary))] public class ArticleContent : PageContent, IRelatable, IHasCode { [Summary] public string Code { get; set; } [Summary] public string Title { get; set; } [Summary] public string Category { get; set; } [Summary, UIHint("Multiline")] public string Intro { get; set; } public Video Video { get; set; } public ArticleContent() { BaseContent.InitialiseProperties(this); } }
ArticleSummary looks like this:
[Serializable] public class ArticleSummary : Summary { public string Code { get; set; } public string Category { get; set; } public string Intro { get; set; } }
Notice that the ArticleSummary contains all the fields marked with the SummaryAttribute in the full content class, except for Title, which exists in the base Summary class already.
0 Comments