Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

Code Block
[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>();
  }
}