public static KKeyMetadata of(String columnName, Type dataType, int length, bool saveToDb) { IKKeyValueConverter converter; if (typeof(string) == dataType || typeof(Guid) == dataType) { converter = new StringKKeyValueConverter(); } else if (typeof(int?) == dataType) { converter = new IntegerKKeyValueConverter(); } else if (typeof(decimal) == dataType) { converter = new BigDecimalKKeyValueConverter(); } else if (typeof(DateTime) == dataType) { converter = new DateKKeyValueConverter(); } else { throw new ArgumentException("There is no converter defined for data type: " + dataType.Name); } return(new KKeyMetadata(columnName, dataType, length, converter, saveToDb)); }
private KKeyMetadata([NotNull] string columnName, [NotNull] Type dataType, int length, [NotNull] IKKeyValueConverter converter, bool saveToDb) { if (string.IsNullOrEmpty(columnName)) { throw new ArgumentNullException(nameof(columnName)); } this.columnName = columnName; this.dataType = dataType; this.length = length; this.converter = converter; this.saveToDb = saveToDb; }
public static KKeyMetadata of <T>(String columnName, Type dataType, int length, IKKeyValueConverter <T> converter) where T : IConvertible { return(new KKeyMetadata(columnName, dataType, length, converter, true)); }
public static KKeyMetadata of <T>(String columnName, Type dataType, IKKeyValueConverter <T> converter, bool saveToDb) where T : IConvertible { return(new KKeyMetadata(columnName, dataType, 0, converter, saveToDb)); }