serialization

Convert in memory POCO objects to c# code to initialize

Is there a library or code sample for converting an in memory POCO c# object to a .cs code file that creates that object. An example: object of type car in memory becomes: Car c = new Car { Name = "mazda", Id = 5, Passengers = new List<string> { "Bob", "Sally" } // etc... recursing to the bottom }; I could assum...

Architecture decision for client-server communication protocol

This question is pretty generic actually, but I'm really having trouble finding a good answer or example of how it should be done. We are writing a simple multi-user collaborative web browsing application and we are having some issues deciding what to use for a communication protocol. We are developing in C# under Mono, hoping to event...

C#: Determine Type for (De-)Serialization

Hi, i have a little problem implementing some serialization/deserialization logic. I have several classes that each take a different type of Request object, all implementing a common interface and inheriting from a default implementation: This is how i think it should be: Requests interface IRequest { public String Action {get;set;...

rails xml to active record object

I've been googling for a while to try and convert and incoming XML request into an active record object. I've tried using the ActiveRecordObject.new.from_xml method but it doesn't seem to handle relationships. For example, say I have the following xml: <blog> <title></title> <blog-pages> <blog-page> <page-number></page-nu...

What is the proper way to use a Logger in a Serializable Java class?

I have the following (doctored) class in a system I'm working on and Findbugs is generating a SE_BAD_FIELD warning and I'm trying to understand why it would say that before I fix it in the way that I thought I would. The reason I'm confused is because the description would seem to indicate that I had used no other non-serializable insta...

XStream serializable objects

I am currently using XStream to serialize some of my objects that don't implement Serializable. Is there a way to tell XStream to use Java's default serialization if the object does implement Serializable and to fall back on XML serialization if it does not? Or would I need to implement a simple layer on top of it to check? thanks, Jeff...

Java serialization testing

Does anyone know if there is a library that exists to help test if an object graph is fully serializable? It would probably be as simple as writing it out and reading it back in, but I figured someone must have abstracted this already - I just can't find it. ...

JSon.NET DeserializeObject<List<T>> not returning list nor giving error

Hi there, I got stuck with Json.NET library and its DeserializeObject method. The Documentation is not quite clear with what could be happening here, so I would appreciate if somebody could explain how to acheive to deserialize JSON into list of User objects. I'm trying to deserialize this JSON [ {"userid":"0", "listid":1, ...

C# How can I return my base class in a webservice

I have a class Car and a derived SportsCar: Car Something like this: public class Car { public int TopSpeed{ get; set; } } public class SportsCar : Car { public string GirlFriend { get; set; } } I have a webservice with methods returning Cars i.e: [WebMethod] public Car GetCar() { return new Car() { TopSpeed = 100 }...

Is it possible to De-Serialize a new Derived class using Old Binary?

In my project I have a class which I Serialize in Binary format to the disk. Due to some new requirement I need to create a new class which is derived from the original class. eg [Serializable] public class Sample { String someString; int someInt; public Sample() { } public Sample(String _someString, int _som...

OutOfMemoryError calling XmlSerializer.Deserialize() - not related to XML size!

This is a really crazy bug. The following is throwing an OutOfMemoryException, for XML snippits that are very short and simple (e.g., <ABC def='123'/>): public static T DeserializeXmlNode<T>(XmlNode node) { try { return (T)new XmlSerializer(typeof(T)) .Deserialize(new XmlNodeReader(node)); } catch (Ex...

How can I share Perl data structures through a socket?

In sockets I have written the client server program. First I tried to send the normal string among them it sends fine. After that I tried to send the hash and array values from client to server and server to client. When I print the values using Dumper, it gives me only the reference value. What should I do to get the actual values in c...

Serialize a generic collection specifying element names for items in the collection

I have a simple class derived from a generic list of string as follows: [Serializable] [System.Xml.Serialization.XmlRoot("TestItems")] public class TemplateRoleCollection : List<string> { } when I serialize this, I get the following XML: <TestItems> <string>cat</string> <string>dog</string> <string>wolf</string> </TestItems> ...

Different return XML in a WCF Operation

I am writing a service to a international HTTP standard, and there is one method that can return three different XML results, call them Single, Multiple and Error. Now I've written an IXmlSerializable class that can consume each of these results and generate them. However, WCF seems to insist that I can only have a single return XML root...

deserialize Json using JavaScriptSerializer Custom Types

I have a RESTFUL WCF service returning a .NET custom type as json string. I am using .NET 3.5 framework and I am using JavaScriptSerializer for deserializing it in to my custom type. Serialization to json is handled by WCF. using (WebResponse resp = req.GetResponse()) { using (System.IO.StreamReader sreader ...

How to Serialize a WPF Drawing?

Hi, maybe I'm missing something. I believed that WPF vector-based Drawings (like DrawingGroup, DrawingGeometry, etc.) were ready to be serialized. But they are not. So, should I navigate all these drawing childrens, and store they points, lines, brushes (that also are not serializable) and so on, and then made my custom serialization? ...

Deserializing JSON in WCF throws xml errors in .Net 4.0

Hi there. I'm going slidely mad over here, maybe someone can help me figure out what's going on. I have a WCF service exposing a function using webinvoke, like so: [OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, RequestFormat = WebMessageFormat.Json, Respo...

XML deserializer (Iserialzable)

Hey everybody, I have a class in c# that implements Iserialzable. I'm using a XMLSerializer that produces a XML from instance of that class. I get the following XML: <?xml version="1.0"?> <Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <SessionConfiguration> ...

Control XML serialization of Dictionary<K, T>

I'm investigating about XML serialization, and since I use lot of dictionary, I would like to serialize them as well. I found the following solution for that (I'm quite proud of it! :) ). [XmlInclude(typeof(Foo))] public class XmlDictionary<TKey, TValue> { /// <summary> /// Key/value pair. /// </summary> public struct Di...

ASP.NET *.resx Serialization

I'm contributing on an I18N project and there's a call to serialize our *.resx files as JSON objects (for whatever reason). What I'm wondering is: Is there a way to get a list of all of the valid keys for a given *.resx file so that we could use HttpContext.GetGlobalResourceObject to grab the tokens? If that won't work, has anyone com...