C# serialize a class without a parameterless constructor

后端 未结 5 1918
予麋鹿
予麋鹿 2020-12-18 21:08

I\'m implementing a factory pattern for 3 different cryptography classes. The factory will determine which one to create and then get a serialized instance of the correct cl

5条回答
  •  太阳男子
    2020-12-18 21:48

    Are PgpPublicKey and PgpPrivateKey classes defined by you? Simply add parameterless constructors to them.

    They can be private if you don't want to make them accessible from outside. The deserializer can still access them.

提交回复
热议问题