private static object Map(string value, K type) { return(type switch { K.String => string.IsNullOrEmpty(value) ? "" : value, K.Boolean => value != "0" && value != "false", K.Timestamp => string.IsNullOrEmpty(value) ? default : DateTime.Parse(value), K.Long => string.IsNullOrEmpty(value) ? default : long.Parse(value), K.Short => string.IsNullOrEmpty(value) ? default : short.Parse(value), K.Double => string.IsNullOrEmpty(value) ? default : decimal.Parse(value, CultureInfo.GetCultureInfo("en-US")), K.Int => string.IsNullOrEmpty(value) ? default : int.Parse(value), _ => throw new ArgumentException($"Unsupported type: {type}") });
public Type(string value) { FieldTypes.AssertString(value); Value = value switch { "string" => K.String, "timestamp" => K.Timestamp, "boolean" => K.Boolean, "long" => K.Long, "short" => K.Short, "double" => K.Double, "int" => K.Int, _ => throw new ArgumentException($"Unsupported kind: '{value}"), }; }