Exemple #1
0
        public void Run()
        {
            foreach (Element el in engine1.Table.DisplayElements)
            {
                Console.WriteLine(el.ToString());
                if (el is Syncfusion.Grouping.SummarySection)
                {
                    // Cast summary to correct type before accessing idividual summary properties
                    Console.WriteLine("Summaries:");
                    ITreeTableSummary[] summaries = el.ParentGroup.GetSummaries(el.ParentTable);

                    DoubleAggregateSummary d0 = (DoubleAggregateSummary)summaries[el.ParentTableDescriptor.Summaries.IndexOf(sd0)];
                    Console.WriteLine("QuantityAverage = {0}", d0.Average);

                    TotalSummary d1 = (TotalSummary)summaries[el.ParentTableDescriptor.Summaries.IndexOf(sd1)];
                    Console.WriteLine("QuantityDistinctCount = {0}", d1.Total);

                    DistinctInt32CountSummary d2 = (DistinctInt32CountSummary)summaries[el.ParentTableDescriptor.Summaries.IndexOf(sd2)];
                    Console.WriteLine("QuantityTotal = {0}", d2.Count);

                    StatisticsSummary d3 = (StatisticsSummary)summaries[el.ParentTableDescriptor.Summaries.IndexOf(sd3)];
                    Console.WriteLine("QuantityMedian = {0}", d3.Median);

                    Console.WriteLine("QuantityAverage = {0}", GetAverageSummary(sd0, el.ParentGroup));
                }
            }
        }
 /// <summary>
 /// Combines this summary information with another objects summary and returns a new object.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 /// <remarks>
 /// This method must honor the immutable characteristics of summary objects and return
 /// a new summary object instead of modifying an existing summary object.
 /// </remarks>
 public TotalSummary Combine(TotalSummary other)
 {
     // Summary objects are immutable. That means properties cannot be modified for an
     // existing object. Instead every time a change is made a new object must be created (just like
     // System.String).
     //
     // This allows following optimization: return existing summary object if either one of the values is 0. -->
     if (other.Total == 0)
     {
         return(this);
     }
     else if (Total == 0)
     {
         return(other);
     }
     // <-- end of optimization
     else
     {
         return(new TotalSummary(this.Total + other.Total));
     }
 }