Exemplo n.º 1
0
        public static double[] ConvertToVector(string text, SOMFieldStats stats, SOMConvertToVectorProps convertProps)
        {
            switch (stats.FieldType)
            {
            case SOMFieldType.Integer:
            case SOMFieldType.FloatingPoint:
                #region numeric

                double castDbl1 = string.IsNullOrWhiteSpace(text) ? 0d : double.Parse(text.Trim());

                return(ConvertToVector_LeftSignificant(castDbl1, convertProps));

                #endregion

            case SOMFieldType.DateTime:
                #region date

                DateTime castDt;
                if (!DateTime.TryParse(text, out castDt))
                {
                    castDt = stats.Date_Min.Value;
                }

                double castDbl2 = (castDt - stats.Date_Min.Value).TotalDays;            // convertProps was built from "(stats.Date_Max - stats.Date_Min).TotalDays"

                return(ConvertToVector_LeftSignificant(castDbl2, convertProps));

                #endregion

            case SOMFieldType.AlphaNumeric:
            case SOMFieldType.AnyText:
                #region text

                return(ConvertToVector_Text(text, convertProps, stats.UniqueChars_NonWhitespace));

                #endregion

            default:
                throw new ApplicationException("finish this: " + stats.FieldType.ToString());
            }
        }
        public static double[] ConvertToVector(string text, SOMFieldStats stats, SOMConvertToVectorProps convertProps)
        {
            switch (stats.FieldType)
            {
                case SOMFieldType.Integer:
                case SOMFieldType.FloatingPoint:
                    #region numeric

                    double castDbl1 = string.IsNullOrWhiteSpace(text) ? 0d : double.Parse(text.Trim());

                    return ConvertToVector_LeftSignificant(castDbl1, convertProps);

                    #endregion

                case SOMFieldType.DateTime:
                    #region date

                    DateTime castDt;
                    if (!DateTime.TryParse(text, out castDt))
                    {
                        castDt = stats.Date_Min.Value;
                    }

                    double castDbl2 = (castDt - stats.Date_Min.Value).TotalDays;        // convertProps was built from "(stats.Date_Max - stats.Date_Min).TotalDays"

                    return ConvertToVector_LeftSignificant(castDbl2, convertProps);

                    #endregion

                case SOMFieldType.AlphaNumeric:
                case SOMFieldType.AnyText:
                    #region text

                    return ConvertToVector_Text(text, convertProps, stats.UniqueChars_NonWhitespace);

                    #endregion

                default:
                    throw new ApplicationException("finish this: " + stats.FieldType.ToString());
            }
        }
            public ColumnStats(string name, int index, SOMFieldStats fieldStats, SOMFieldStats fieldStatsText)
            {
                this.Name = name;
                this.Index = index;
                this.FieldStats = fieldStats;
                this.FieldStatsText = fieldStatsText;

                this.Width = 5;
                this.ForceText = false;
            }
 private static void ShowUsedColumnStats_Number(Grid grid, SOMFieldStats stats, Style stylePrompt, Style styleValue)
 {
     AddDescriptionRow(grid, "min", stats.Numeric_Min.Value.ToStringSignificantDigits(3), stylePrompt, styleValue);
     AddDescriptionRow(grid, "max", stats.Numeric_Max.Value.ToStringSignificantDigits(3), stylePrompt, styleValue);
     AddDescriptionRow(grid, "average", stats.Numeric_Avg.Value.ToStringSignificantDigits(3), stylePrompt, styleValue);
     AddDescriptionRow(grid, "std deviation", stats.Numeric_StandDev.Value.ToStringSignificantDigits(3), stylePrompt, styleValue);
 }
 private static void ShowUsedColumnStats_Datetime(Grid grid, SOMFieldStats stats, Style stylePrompt, Style styleValue)
 {
     AddDescriptionRow(grid, "min", GetDateTimeText(stats.Date_Min.Value), stylePrompt, styleValue);
     AddDescriptionRow(grid, "max", GetDateTimeText(stats.Date_Max.Value), stylePrompt, styleValue);
     AddDescriptionRow(grid, "average", GetDateTimeText(stats.Date_Avg.Value), stylePrompt, styleValue);
     AddDescriptionRow(grid, "std deviation", stats.Date_StandDev.Value.ToString(), stylePrompt, styleValue);
 }
        private static void ShowUsedColumnStats_Text(Grid grid, SOMFieldStats stats, Style stylePrompt, Style styleValue)
        {
            AddDescriptionRow(grid, "min length", stats.MinLength.ToString("N0"), stylePrompt, styleValue);
            AddDescriptionRow(grid, "max length", stats.MaxLength.ToString("N0"), stylePrompt, styleValue);

            //UniqueChars
            //UniqueChars_NonWhitespace
        }