Does Mapster work with Ardalis SmartEnums? #750
Unanswered
jeffreymonroe
asked this question in
Q&A
Replies: 1 comment
-
The following MapWith works:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I see some discussion on #463, but there was no definitive answer. I defined a TypeAdapterConfig, but the below never gets called:
`
public class TypeContext : SmartEnum
{
public static readonly TypeContext None = new("Undefined", -1);
public static readonly TypeContext Device_DeviceType = new("Device.Type", 1);
public static readonly TypeContext Device_StateType = new ("Device.State", 2);
public static readonly TypeContext Site_SiteType = new ("Site.Type", 3);
public static readonly TypeContext Site_State = new ("Site.State", 4);
public static readonly TypeContext Telemetry_State = new ("Telemetry.State", 6);
public static readonly TypeContext Telemetry_DataType = new ("Telemetry.DataType", 7);
public static readonly TypeContext TelemetryNumericData_State = new ("TelemetryNumericData.State", 8);
public static readonly TypeContext TelemetryTextData_State = new ("TelemetryTextData.State", 9);
public static readonly TypeContext IngestLog_SeverityType = new("IngestLog.SeverityType", 10);
}
`
Then I add the TypeAdapterConfig before calling "Adapt":
TypeAdapterConfig<string, TypeContext>.NewConfig() .Map(d => d, s => TypeContext.FromName(s, true));
The TypeAdapterConfig is not called.
Beta Was this translation helpful? Give feedback.
All reactions