My requirement is to create a version converter design that is efficient. Let us assume the following classes are evolved in each version.
//Version 1
internal class PatientV1
{
public string FullName { get; set; }
public string PatientNr { get; set; }
public GenderV1 Gender { get; set; }
}
internal enum GenderV1
{
MALE,
FEMALE
}
//Version 2
internal class PatientV2
{
public Name FullName { get; set; }
public string PatientNr { get; set; }
public GenderV2 Gender { get; set; }
}
internal class Name
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Title { get; set; }
}
internal enum GenderV2
{
MALE,
FEMALE,
UNKNOWN
}
//Version 3
internal class PatientV3
{
public IPerson Person { get; set; }
public string PatientNr { get; set; }
}
internal interface IPerson
{
Name Name { get; set; }
GenderV3 Gender { get; set; }
}
internal class Person : IPerson
{
public Name Name { get; set; }
public GenderV3 Gender { get; set; }
}
internal enum GenderV3
{
MALE,
FEMALE,
MALE_TO_FEMALE_CONVERSION_INPROGRESS,
FEMALE_TO_CONVERSION_INPROGRESS,
UNKNOWN
}
I have created JsonConverter to deserialise one version to another version. This has increased many combinations of converters ((n-1)!) such as.
- PatientV1ToV2Converter to convert from version 1 to version 2
- PatientV1ToV3Converter to convert from version 1 to version 3
- PatientV2ToV3Converter to convert from version 2 to version 3
So instead of this I would like PatientV1ToV3Converter calls PatientV1ToV2Converter to bring the Patient from PatientV1 to PatientV2 and then PatientV1ToV3Converter to work on PatientV2 to make it PatientV3.
All these I would like to do without having any of the older version of Patient (PatientV1 and PatientV2) being present in the application directory.
Any design, with or without the older dll restriction is fine with me.