private static List <IFieldSpec> GetFieldSpecs(List <FieldSpecConfig> fieldSpecConfigs) { List <IFieldSpec> result = new List <IFieldSpec>(); foreach (FieldSpecConfig fieldSpecConfig in fieldSpecConfigs) { IFieldSpec fieldSpec = null; switch (fieldSpecConfig.FieldType) { case ConfigValues.FIELDTYPE_CATEGORICAL: fieldSpec = new FieldSpecCategorical(fieldSpecConfig.Name, fieldSpecConfig.Categories, fieldSpecConfig.EnforceUniqueValues, fieldSpecConfig.FormatString, fieldSpecConfig.FixedWidthLength, GetLocation(fieldSpecConfig.FixedWidthAddPadding), GetLocation(fieldSpecConfig.FixedWidthTruncate), fieldSpecConfig.FixedWidthPaddingChar, fieldSpecConfig.PercentChanceEmpty, fieldSpecConfig.EmptyValue); break; case ConfigValues.FIELDTYPE_CONTINUOUSDATETIME: fieldSpec = new FieldSpecContinuousDateTime(fieldSpecConfig.Name, fieldSpecConfig.DateStart, fieldSpecConfig.DateEnd, fieldSpecConfig.EnforceUniqueValues, fieldSpecConfig.FormatString, fieldSpecConfig.FixedWidthLength, GetLocation(fieldSpecConfig.FixedWidthAddPadding), GetLocation(fieldSpecConfig.FixedWidthTruncate), fieldSpecConfig.FixedWidthPaddingChar, fieldSpecConfig.PercentChanceEmpty, fieldSpecConfig.EmptyValue); break; case ConfigValues.FIELDTYPE_CONTINUOUSNUMERIC: fieldSpec = new FieldSpecContinuousNumeric(fieldSpecConfig.Name, GetDistribution(fieldSpecConfig.NumericDistribution), fieldSpecConfig.MaxDigitsAfterDecimalPoint, fieldSpecConfig.EnforceUniqueValues, fieldSpecConfig.FormatString, fieldSpecConfig.FixedWidthLength, GetLocation(fieldSpecConfig.FixedWidthAddPadding), GetLocation(fieldSpecConfig.FixedWidthTruncate), fieldSpecConfig.FixedWidthPaddingChar, fieldSpecConfig.PercentChanceEmpty, fieldSpecConfig.EmptyValue); break; case ConfigValues.FIELDTYPE_DYNAMIC: fieldSpec = new FieldSpecDynamic(fieldSpecConfig.Name, GetFunky(fieldSpecConfig.DynamicFunc), fieldSpecConfig.EnforceUniqueValues, fieldSpecConfig.FormatString, fieldSpecConfig.FixedWidthLength, GetLocation(fieldSpecConfig.FixedWidthAddPadding), GetLocation(fieldSpecConfig.FixedWidthTruncate), fieldSpecConfig.FixedWidthPaddingChar, fieldSpecConfig.PercentChanceEmpty, fieldSpecConfig.EmptyValue); break; } if (fieldSpec != null) { result.Add(fieldSpec); } } return(result); }
private string GetDataType(IFieldSpec fieldSpec) { Type type = fieldSpec.Value.GetType(); if (TypeUtil.IsNumeric(type)) { return(FMT_NUMERIC); } else if (type.Equals(TypeUtil.TypeDateTime) || type.Equals(TypeUtil.TypeDateTimeNullable)) { return(FMT_DATE); } else { return(FMT_STRING); } }