private static string FormatDateTime(DateTimeOffset data, string format, Configuration config) { return !String.IsNullOrWhiteSpace(format) ? data.ToString(format, config.Culture.DateTimeFormat) : data.ToString(config.Culture.DateTimeFormat); }
private static string FormatBoolean(bool input, string format, Configuration config) { return BindingUtils.ParseBooleanFormat(format, input) ?? input.ToString(config.Culture); }
internal static string GetConfigFormat(this DataType type, Configuration config) { string result; switch (type) { case DataType.Boolean: result = config.BooleanFormat; break; case DataType.Integer: case DataType.BigInteger: result = config.IntegerFormat; break; case DataType.Decimal: case DataType.BigDecimal: result = config.DecimalFormat; break; case DataType.DateTime: result = config.DateTimeFormat; break; case DataType.Guid: result = config.GuidFormat; break; case DataType.List: result = config.ListFormat; break; default: result = null; break; } return result; }
private static string FormatNumber(dynamic input, string format, Configuration config) { return !String.IsNullOrWhiteSpace(format) ? input.ToString(format, config.Culture.NumberFormat) : input.ToString(config.Culture.NumberFormat); }
/// <summary> /// Gets the default validation message. /// </summary> /// <param name="type">The type.</param> /// <param name="config">The config.</param> /// <returns></returns> internal static string GetDefaultValidationMessage(this string type, Configuration config) { //TODO: base on config, get the messages from the resource file corresponding to the user's current culture string result; switch (type) { case ValidationType.Exist: result = "value must not be empty"; break; case ValidationType.MaxSize: result = "value size must be less than {0}"; break; case ValidationType.MinSize: result = "value size must be no less than {0}"; break; case ValidationType.Regex: result = "value must match the pattern {0}"; break; case ValidationType.Positive: result = "value must be positive"; break; case ValidationType.Different: result = "value must be different from {0}"; break; case ValidationType.Same: result = "value must be same as {0}"; break; case ValidationType.Min: result = "value must be more than {0}"; break; case ValidationType.Max: result = "value must be less than {0}"; break; case ValidationType.Allow: result = "value must be in this list: {0}"; break; case ValidationType.DisAllow: result = "value must not be in this list: {0}"; break; case ValidationType.Unique: result = "value must not be duplicated: {0}"; break; case ValidationType.Expression: result = "value must satisfy the condition: {0}"; break; default: result = MissingErrorMessage; break; } return result; }