Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8916647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:17:29+00:00 2026-06-15T05:17:29+00:00

My requirement is to create a version converter design that is efficient. Let us

  • 0

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.

  1. PatientV1ToV2Converter to convert from version 1 to version 2
  2. PatientV1ToV3Converter to convert from version 1 to version 3
  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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:17:31+00:00Added an answer on June 15, 2026 at 5:17 am

    I have done something similar in my project

    I have set

    serializerSettings.Converters = new List<JsonConverter>() { new MyAppVersionConverter() };
    

    In this MyAppVersionConverter, I have overriden ReadJson and written the following code

    JObject jObjectV = JObject.Load( reader );
    //Get the type information from JObject by getting the "$type" property and strip it to get the version
    string objectVersion = GetVersion(jObjectV.GetValue("$type"));
    

    Now either modify the existing jObjectV by adding or removing the property to translate to the desired version then

    e.g. from my code

    JProperty firstNameProp = new JProperty( "FirstName", firstName );
    JProperty lastNameProp = new JProperty( "LastName", lastName );
    JProperty typeProperty = new JProperty( "$type", "MyDetailV2.EmployeeDetail, MyDetailV2, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" );
    
    JObject jObjectV2 = new JObject();
    jObjectV2.Add( typeProperty );
    jObjectV2.Add( firstNameProp );
    jObjectV2.Add( lastNameProp );
    
    return jObjectV2.ToObject<EmployeeDetail>();
    

    I am still refining things. I shall post once i have done the complete change.

    Let me know if you have any problem in this regard

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a requirement to create a data structure that has the following
I have a requirement to create a background processor that works only when the
I have a requirement to create a simple windows forms application that allows an
For a project we have a requirement to create an interfacedefinition that will return
I want to create a table Person using JPA, it is a requirement that
We have following requirement : Table1 : composite primary key version, id ------------------------------------ version
Let's assume I am in charge of developing a Scrabble game, being that one
I have a requirement to create a xaml page with Semantic Zoom where the
I have a requirement to create a windows form control which has to detect
I have a requirement to create two different maps in C++. The Key is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.