/// <summary> /// Assign this CreateSummaryDelegate handler method to SummaryDescriptor.CreateSummaryMethod /// </summary> /// <param name="sd"></param> /// <param name="record"></param> /// <returns></returns> public static ISummary CreateSummaryMethod(SummaryDescriptor sd, Record record) { object obj = sd.GetValue(record); bool isNull = (obj == null || obj is DBNull); if (isNull) { return(Empty); } else { int i = sd.Name.LastIndexOf('_') + 1; string weightsCol = sd.Name.Substring(i); object obj1 = record.GetValue(weightsCol); if (obj1 == null) { throw new ArgumentException(string.Format("[{0}] not a column.", weightsCol)); } double wgt = Convert.ToDouble(obj1); double val = Convert.ToDouble(obj) * wgt; return(new WeightedSummary(val, wgt)); } }
/// <summary> /// Assign this CreateSummaryDelegate handler method to SummaryDescriptor.CreateSummaryMethod /// </summary> /// <param name="sd"></param> /// <param name="record"></param> /// <returns></returns> public static ISummary CreateSummaryMethod(SummaryDescriptor sd, Record record) { object obj = sd.GetValue(record); bool isNull = (obj == null || obj is DBNull); if (isNull) { return(Empty); } else { double val = Convert.ToDouble(obj); return(new TotalSummary(val)); } }
public static ISummary CreateSummaryMethod(SummaryDescriptor sd, Record record) { object obj = sd.GetValue(record); bool isNull = (obj == null || obj is DBNull); if (isNull) { return(new DistinctInt32CountSummary(new Int32[0])); } else { Int32 val = Convert.ToInt32(obj); return(new DistinctInt32CountSummary(new Int32[] { val })); } }
public static ISummary CreateSummaryMethod(SummaryDescriptor sd, Record record) { object obj = sd.GetValue(record); bool isNull = (obj == null || obj is DBNull) || (obj is double) && double.IsNaN((double)obj); // could also be double.NaN... which is also treated as null if (isNull) { return(new StatisticsSummary(new double[0], 0)); // { double.NaN }, 1); } else { double val = Convert.ToDouble(obj); return(new StatisticsSummary(new double[] { val }, 1)); } }