27 lines
878 B
C#
27 lines
878 B
C#
using Kbx.Contracts.Generated;
|
|
|
|
namespace Shared.Excel;
|
|
|
|
public static class ImportFieldDefinitionFactory
|
|
{
|
|
public static ImportFieldDefinition FromKbxField(string key, bool? required = null, string? label = null)
|
|
{
|
|
var field = KbxFieldCatalog.Get(key);
|
|
if (!field.Importable)
|
|
throw new InvalidOperationException($"KBX field '{key}' is not importable.");
|
|
|
|
return new ImportFieldDefinition(
|
|
Key: field.Key,
|
|
Label: label ?? field.Label,
|
|
Aliases: field.Aliases,
|
|
DataType: field.DataType,
|
|
Required: required ?? field.Required,
|
|
MaxLength: field.MaxLength,
|
|
Precision: field.Precision,
|
|
Scale: field.Scale,
|
|
LookupEntity: field.LookupEntity,
|
|
Importable: field.Importable,
|
|
Exportable: field.Exportable);
|
|
}
|
|
}
|