Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have to make all object that I would use in caching serializable by decorating each class with the serialize attribute[serialize]. The problem is that there are potentially 100s of object in my project that I could use during caching and I do not want to decorate all of them with the serializable property. All of these classes derive from a single base class but property do not transfer in inheritance. I am using c#.
Posted
Comments
Maciej Los 17-Jun-15 13:52pm    
How to serialize without serialization? Your question has no sense...
Femi Osibote 17-Jun-15 18:06pm    
you can only say things like that hiding behind a pc. I think my question is quite clear. I want to accomplish serialization without having to decorate my object with the attribute as required by .net
CodeElnino 23-May-17 14:47pm    
For folks still interested in a solution to this problem. One option is to use Protocol Buffer but this might not necessarily work for you depending on the scenario. I wanted to serialize for caching purposes after hydration. You can also use SharpSerializer or Automapper if you are trying to clone the object. There are some gotchas that you would need to be aware of.
Ralf Meier 18-Jun-15 0:46am    
I think like Maciej - at which point is the need for serialisation of your class.
For example : if you use the class as a Property of a Control it will automaticly serialized by the Designer.
Do you think about something like this ?

1 solution

This can't be done using the serializers that are built into .NET; however on this site you will find many people's serializers [^] that they have developed themselves.
 
Share this answer
 
Comments
Maciej Los 17-Jun-15 14:58pm    
Seems you didn't understand the question... OP wants to serialize classes without serialization decoration. All serializers need to to define serialization atrributes.
Yvan Rodrigues 17-Jun-15 15:01pm    
Many do, but many don't. For example I wrote an XML serializer that can serialize pretty much anything you throw at it. You can use attribute decoration, but you don't have to. If you don't it just serializes all public properties like <property name="CustomerID">842</property> etc. I haven't written an article for it yet, but there have to be others.
Maciej Los 17-Jun-15 15:19pm    
First of all, Yvan, i'm not an inquirer. Secondly, as i mentioned in the comment to your answer, It's almost impossible to serialize class with decorating it!
Yvan Rodrigues 17-Jun-15 15:46pm    
Challenge accepted. ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900