private static ParseResult <int> GetIntColumnValue(OperatorPair operatorPair, Feature feature)
        {
            int  currentValue = 0;
            bool isFailed     = true;

            if (feature.ColumnValues.ContainsKey(operatorPair.ColumnName))
            {
                isFailed = !Int32.TryParse(feature.ColumnValues[operatorPair.ColumnName], out currentValue);
            }
            return(new ParseResult <int>(currentValue, isFailed));
        }
 private static void DissolveNumbers(IEnumerable <Feature> groupFeature
                                     , Dictionary <string, string> newColumnValues
                                     , OperatorPair operatorPair
                                     , Func <IEnumerable <double>, double> processDouble
                                     , Func <IEnumerable <int>, int> processInt = null)
 {
     if (operatorPair.ColumnType.Equals("Integer", StringComparison.OrdinalIgnoreCase))
     {
         var parseResults = groupFeature.Select(f => GetIntColumnValue(operatorPair, f)).ToArray();
         if (parseResults.All(r => r.IsFailed))
         {
             newColumnValues.Add(operatorPair.ColumnName, string.Empty);
         }
         else
         {
             if (processInt != null)
             {
                 int intSum = processInt(parseResults.Where(r => !r.IsFailed).Select(r => r.Result));
                 newColumnValues.Add(operatorPair.ColumnName, intSum.ToString());
             }
             else
             {
                 double doubleSum = processDouble(parseResults.Where(r => !r.IsFailed)
                                                  .Select(r => (double)r.Result));
                 newColumnValues.Add(operatorPair.ColumnName, doubleSum.ToString());
             }
         }
     }
     else if (operatorPair.ColumnType.Equals("Double", StringComparison.OrdinalIgnoreCase) ||
              operatorPair.ColumnType.Equals("String", StringComparison.OrdinalIgnoreCase))
     {
         var parseResults = groupFeature.Select(f => GetDoubleColumnValue(operatorPair, f)).ToArray();
         if (parseResults.All(r => r.IsFailed))
         {
             newColumnValues.Add(operatorPair.ColumnName, string.Empty);
         }
         else
         {
             double doubleSum = processDouble(parseResults.Where(r => !r.IsFailed).Select(r => r.Result));
             newColumnValues.Add(operatorPair.ColumnName, doubleSum.ToString());
         }
     }
 }
        private static Feature CollectNewColumnValues(IGrouping <string, Feature> groupFeature, Dictionary <string, string> newColumnValues, OperatorPair operatorPair)
        {
            Feature feature = new Feature();

            switch (operatorPair.Operator)
            {
            case DissolveOperatorMode.First:
                feature = groupFeature.FirstOrDefault();
                if (feature.GetShape() != null)
                {
                    newColumnValues.Add(operatorPair.ColumnName, feature.ColumnValues[operatorPair.ColumnName]);
                }
                break;

            case DissolveOperatorMode.Last:
                feature = groupFeature.LastOrDefault();
                if (feature.GetShape() != null)
                {
                    newColumnValues.Add(operatorPair.ColumnName, feature.ColumnValues[operatorPair.ColumnName]);
                }
                break;

            case DissolveOperatorMode.Count:
                newColumnValues.Add(operatorPair.ColumnName, groupFeature.Count().ToString());
                break;

            case DissolveOperatorMode.Sum:
                DissolveNumbers(groupFeature
                                , newColumnValues
                                , operatorPair
                                , rs => rs.Sum()
                                , rs => rs.Sum());
                break;

            case DissolveOperatorMode.Average:
                DissolveNumbers(groupFeature
                                , newColumnValues
                                , operatorPair
                                , rs => rs.Average());
                break;

            case DissolveOperatorMode.Min:
                DissolveNumbers(groupFeature
                                , newColumnValues
                                , operatorPair
                                , rs => rs.Min()
                                , rs => rs.Min());
                break;

            case DissolveOperatorMode.Max:
                DissolveNumbers(groupFeature
                                , newColumnValues
                                , operatorPair
                                , rs => rs.Max()
                                , rs => rs.Max());
                break;
            }
            return(feature);
        }