Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

Its possible to have a Summary contain a property computed from a property or properties on the main Content type.  For instance, a count of items in a list, or a flag saying whether a value is empty.  This is done simply by adding the computed property with an empty Set method on the Content type, then adding a normal default property with the same name on the Summary type, like this:

[Serializable]
public class TestSummary : Summary
{
  public int SubTestsCount { get; set; }
}

[Serializable, SummaryType(typeof(TestSummary))]
public class TestContent : BaseContent
{
  public List<SubTest> SubTests { get; set; }

  public int SubTestsCount
  {
    get { return SubTests == null ? 0 : SubTests.Count; }
    set { }
  }

  public TestContent()
  {
    SubTests = new List<SubTest>();
  }
}
  • No labels