serialization

Is it possible to Serialize a LINQ object?

I'd like to serialize some LINQ generated objects and store them in a table as a binary field (Never you mind why). I'd like to be able to write some code that looks something like this: SerialTestDataContext db = new SerialTestDataContext(); relation_table row = db.relation_tables.First(); MemoryStream memStream = new MemoryStream();...

Write XML file (using XStream) to filesystem in Java

I need to be able to serialize a string and then have it save in a .txt or .xml file. I've never used the implementation to read/write files, just remember I am a relative beginner. Also, I need to know how to deserialize the string to be printed out in terminal as a normal string. ...

How do I serialize an anonymous object for sending over a SOAP web service?

I am trying to send an anonymous object over a web service. Is there anyway I can do this without manually creating a class and casting it to that class? Currently its throwing an exception saying Anonymous object could not be serialized. // Some code has been removed here to simplify the example. [WebMethod(EnableSession = true)] publi...

Should any domain object, not be serializable?

Is there a way to just tell the compiler, that I want my objects to be serializable by default? ...

Is it possible to serialize a c# code block?

Hey, I'm using C# with .Net 3.5. Is it possible to serialize a block of code, transmit it somewhere, deserialize it, then execute it? An example usage of this would be: Action<object> pauxPublish = delegate(object o) { if (!(o is string)) { return; } Console.WriteLine(o.ToString()); }; Transmitter.Send(pauxPublish); With ...

DataContractSerializer: Handling objects whose type you don't know and don't have access to.

I have a class (call it Container) which is serialized and deserialized using the DataContractSerializer. The class contains a collection of other classes, all of which inherit the same base class (call it ContentsBase), but which have distinct derived classes. The application may be passed a serialized Container object which contains Co...

How does Java's serialization work and when it should be used instead of some other persistence technique?

I've been lately trying to learn more and generally test Java's serialization for both work and personal projects and I must say that the more I know about it, the less I like it. This may be caused by misinformation though so that's why I'm asking these two things from you all: 1: On byte level, how does serialization know how to match...

MFC carchive to xml

We have a legacy app that uses MFC's CArchive. I am researching saving the data in XML vs. binary. I have looked several libraries such as: Boost http://www.codeproject.com/KB/XML/xmlize.aspx http://www.ucancode.net/faq/Visual-C-MFC-XML-Example.htm http://www.codeguru.com/cpp/data/data-misc/xml/article.php/c4567 They are nice, and of...

Create pointer to parent object in deserialization process in C#

I have a classes like: [Serializable] public class child { public Parent parent; } [Serializable] public class Parent { public List<child> children; } When I deserialize Parent, I want each of each children to have a reference to it's parent. Question is, where in the deserialization process can I set the child's "parent" poi...

The best way to store class instances to a file/database

What is the best way to store instances of a class to file/database? We have a base class called Command and loads of derived classes. Users create instances of these classes by adding commands to a graphical designer where they can configure them. (Set the properties). We then need a way to store these "commands" to a file without los...

Reading an XML File using FileInputStream (for Java)?

Hi everyone, here's the deal. For my project I have to serialize and deserialize a random tree using Java and XStream. My teacher made the Tree/RandomTree algorithms, so I don't have to worry about that. What I don't know how to do is this: I am using FileInputStream to read/write the xml file that I serialized and deserialized, but ...

Serializing a Python object to/from a S60 phone

I'm looking for a way to serialize generic Python objects between a CherryPy-based server and a Python client running on a Symbian phone.. Since pyS60 doesn't implement the pickle module, how would you do it? I know about Cerealizer but it requires you to register classes before use (which I'd like to avoid) and doesn't look very mature...

Using java.io.Serializable when implementing a tree?

Hey everyone, I have ANOTHER serialization question, but this time it is in regards to Java's native serialization import when serializing to binary. I have to serialize a random tree that is generated in another java file. I know how serialization and deserialization works, but the example I followed when using binary serialization wi...

How to Deserialize XML document

Hi, How do I Deserialize this XML document: <?xml version="1.0" encoding="utf-8"?> <Cars> <Car> <StockNumber>1020</StockNumber> <Make>Nissan</Make> <Model>Sentra</Model> </Car> <Car> <StockNumber>1010</StockNumber> <Make>Toyota</Make> <Model>Corolla</Model> </Car> <Car> <StockNumber>1111</StockNumbe...

Fastest way to share data objects between a Java server and a C# client

What is the fastest way to share data structures between Java and C#? I want something where I can literally send a "car" object or a "foo" object and have it serialized and deserialized on both server and client. ...

XML serialization of a Dictionary with a custom IEqualityComparer

Hi, I want to serialize a Dictionary that has a custom IEqualityComparer. I've tried using DataContractSerializer but I can't get the Comparer to be serialized. I can't use BinaryFormatter because of this. I can always do something like: var myDictionary = new MyDictionary(deserializedDictionary, myComparer); But that means I'd need...

XmlTextAttribute and CDATA

We have a part of our application where our users can create objects containing html, javascript and css through custom made Wysiwyg components. Those objects are at some point serialized and later deserialized. However, since our users/clients are located all over the globe, they sometimes input characters that cause grievance during de...

What's a good way to serialize Delphi object tree to XML--using RTTI and not custom code?

What's a good way to serialize a Delphi object tree to XML--using RTTI and not custom code? I would have loved to find that this feature is already built into Delphi, but it doesn't seem to be. I've found a few components (posted, below) that seem like they might perform this function. Have you used any of them or some other offering?...

What is the best way to serialize a ModelForm object in Django?

I am using Django and the Google Web Toolkit (GWT) for my current project. I would like to pass a ModelForm instance to GWT via an Http response so that I can "chop" it up and render it as I please. My goal is to keep the form in sync with changes to my models.py file, yet increase control I have over the look of the form. However, the d...

How to deserialize only part of an XML document in C#

Hi everyone, Here's a fictitious example of the problem I'm trying to solve. If I'm working in C#, and have XML like this: <?xml version="1.0" encoding="utf-8"?> <Cars> <Car> <StockNumber>1020</StockNumber> <Make>Nissan</Make> <Model>Sentra</Model> </Car> <Car> <StockNumber>1010</StockNumber> <Make>Toyota</Ma...