Copy two identical object with different namespaces (recursive reflection)

后端 未结 7 1489
我寻月下人不归
我寻月下人不归 2021-01-06 19:22

I\'m working in c# with several workspaces that have one specific class which his always the same in each workspace. I would like to be able have a copy of this class to be

7条回答
  •  半阙折子戏
    2021-01-06 20:06

    I had the similar problem. I got to use similar classes but different in terms of namespace only. As a quick solution I performed below steps and it works.

    1. Serialize source class into XML.
    2. In SerializedXML replace source namespace with the target one.
    3. DeSerialize with target type.

    I know there is performance overhead with above way but it is quick to implement and error free.

提交回复
热议问题