Supposing I have this immutable struct:
public struct LogGroup
{
public Log<LowResolutionLogData> LowResolutionLog { get; }
public IEnumerable<Log<MediumResolutionLogData>> MediumResolutionLogs { get; }
public IEnumerable<Log<HighResolutionLogData>> HighResolutionLogs { get; }
public LogGroup
(
Log<LowResolutionLogData> lowResolutionLog,
IEnumerable<Log<MediumResolutionLogData>> mediumResolutionLogs,
IEnumerable<Log<HighResolutionLogData>> highResolutionLogs
)
{
LowResolutionLog = lowResolutionLog;
MediumResolutionLogs = mediumResolutionLogs;
HighResolutionLogs = highResolutionLogs;
}
}
How do I serialize it without having to making the IEnumerable<>
properties some concrete type (e.g. an Array or List)?
How do I deserialize into it without having to make the properties all settable (I want it to call the assignment constructor I've created)?
The complex types on the object may also have their own complex types and IEnumerable<>
s as immutable properties. Log<>
is a class
whilst the types it takes are all structs
so deserialization using assignment constructors needs to work for both. One of these types has a large number of properties so I want to avoid boilerplate code and have the serialization/deserialization handled dynamically if possible.