public static void Convert <T>(ref object src, out T value)
 {
     if ((src as string) != null)
     {
         var dv = new DvText((string)src);
         value = (T)(object)dv;
     }
     else
     {
         value = (T)src;
     }
 }
Пример #2
0
        public static Func <DvText[], DvText> GetAggFunction(AggregatedFunction func, DvText defaultValue)
        {
            switch (func)
            {
            case AggregatedFunction.Mean:
            case AggregatedFunction.Count:
                return((DvText[] arr) => { return DvText.NA; });

            case AggregatedFunction.Sum:
                return((DvText[] arr) => { return arr.Aggregate((a, b) => new DvText(a.ToString() + b.ToString())); });

            case AggregatedFunction.Min:
                return((DvText[] arr) => { return arr.Aggregate((a, b) => a.CompareTo(b) <= 0 ? a : b); });

            case AggregatedFunction.Max:
                return((DvText[] arr) => { return arr.Aggregate((a, b) => a.CompareTo(b) >= 0 ? a : b); });

            default:
                throw new NotImplementedException($"Unkown aggregated function '{func}'.");
            }
        }