msgpack-cli icon indicating copy to clipboard operation
msgpack-cli copied to clipboard

Custom objects creation

Open kovman opened this issue 9 years ago • 2 comments

Hi,

I have read, that private constructors are not available because of speed (reflection etc.). In my case, I have private constructors and factory, that can create any available object. Is there any way, how can I use my factory to create new object and work around missing default public constructor (or any public constructor at all)?

thanks Lubomir

kovman avatar Oct 27 '16 09:10 kovman

There are no straight forward way to it. You should write custom serializer or implementing IPackable and IUnpackable. Why do you want to serialize such class? I will allow private constructor if there are reasonable reason (private setters are already allowed, and performance penalty is not very high now).

yfakariya avatar Oct 27 '16 13:10 yfakariya

Hi,

sorry for delay, I got stuck with some other issues...

Anyway. I'm trying to use [DataContract] attributes with MsgPack serialization as implementing IPackable and IUnpackable would be implementation over hundreds (not kidding) of existing objects. We have project based over CSLA framework and I'm not able (I'm, source codes are available, but I don't want) to implement it over all framework.

Serialization with such classes is driven by framework and it's created by framework and access rights to business object are check immediately (even after deserialization).

thanks Lubomir

kovman avatar Nov 02 '16 10:11 kovman