serialization

WCF - serializing inherited types

与世无争的帅哥 提交于 2020-01-03 06:49:11
问题 I have these classes: [DataContract] public class ErrorBase {} [DataContract] public class FileMissingError: ErrorBase {} [DataContract] public class ResponseFileInquiry { [DataMember] public List<ErrorBase> errors {get;set;}; } An instance of the class ResponseFileInquiry is what my service method returns to the client. Now, if I fill ResponseFileInquiry.errors with instances of ErrorBase, everything works fine, but if I add an instance of inherited type FileMissingError, I get a service

Convert Expression Tree to String and vice versa for WCF

Deadly 提交于 2020-01-03 05:33:09
问题 I want to Convert Expression Tree to String and Visa versa for using in WCF client and server query expression convert expression tree to string for send to server and convert string to expression tree in server so need this converter seems System.Linq.Dynamic is good library for this purpose so if yes please show me an example for this converting if no please any one show me a way for solve this problem i dont know how System.Linq.Dynamic works for this goal (example please) ******* of

How to serialize ArrayList 2x and dont over write the already present ArrayList JAVA

ぃ、小莉子 提交于 2020-01-03 05:11:28
问题 I'm stuck with making an admin panel for my program to serialize more objects, what it does is , it saves object(String,String) into arraylist and the arraylist is saved into file through serialization. When trying to add another object into the arraylist, The program first deserialize the file stuff into the arraylist, because by not doing this how would i access the objects that are already present in the file.? but instead something like this happens while adding object 3 (console) Index 0

ASP.NET MVC - Serializable

谁说我不能喝 提交于 2020-01-03 04:54:07
问题 I'm trying to use the new Html helper extension Serialize() from the furthure assembly.. If you take a look at: View <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<List<MvcApplication2.Models.ProductViewBinding>>" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ Import Namespace="Microsoft.Web.Mvc" %>> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Index</title> <

serialize form to json and store in the cookie

烈酒焚心 提交于 2020-01-03 04:53:10
问题 i want to store form on clientside, in json in cookie, after that deserialize it back to form. what i'm doing: serialization to JSON: function formToJSON(selector) { var form = {}; $(selector).find(':input[name]:enabled').each(function () { var self = $(this); var name = self.attr('name'); if (name.indexOf('TextBox', 0) == 0) { if (form[name]) { form[name] = form[name] + ',' + self.val(); } else { form[name] = self.val(); } } }); return form; } then on form change, i'm trying to save form to

Compile errors while read/write size of multiple structs to file

一曲冷凌霜 提交于 2020-01-03 04:37:02
问题 I've already asked 2 questions kind of related to this project, and i've reached this conclusion. Writing the size of the Struct to the file , and then reading it back is the best way to do this. I'm creating a program for a homework assignment that will allow me to maintain inventory. I need to read / write multiple structs of the same type to a file. The problem is... this is really complicated and i'm having trouble wrapping my head around the whole process. I've seen a bunch of examples

Serialize FacesContext or How to get properties-values after Server Restart

怎甘沉沦 提交于 2020-01-03 04:32:38
问题 The problem is the following: I need to serialize the user session, so, it will still be present after a server restarts. Using JavaEE and Tomcat 7 works fine with implements Serializable , but the problem is the FacesContext . Indeed, after restarting the server, FacesContext.getCurrentInstance() returns null , and therefore I cannot access the message bundle (and therefore my message.properties cannot be found anymore). So, how do I keep the FacesContext when restarting Tomcat? 回答1: Your

Validating JSON before deserializing into C# object

我的梦境 提交于 2020-01-03 03:59:06
问题 If a JavaScript object in JSON is not going to deserialize into the C# object I want, how can I interrogate it to provide an error message explaining what is wrong with the input? (Assuming the JSON format is correct, just the data is not valid.) My C# class: (simplified) public class Dependent { public Dependent() { } public string FirstName { get; set; } public DateTime DateOfBirth { get; set; } } Test code to deserialize: string dependents = @"[ { ""FirstName"": ""Kenneth"", ""DateOfBirth"

InvalidClassException error while deserializing session data

偶尔善良 提交于 2020-01-03 03:14:08
问题 Here is the calling code: Object attribute = session.getAttribute(name, scope); and this throws the following eror: Could not deserialize session data. java.io.InvalidClassException: org.apache.commons.lang.time.FastDateFormat; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = -7186497712641044641 The environment is Weblogic. The Web application is a spring portlet. I'm trying to understand how to fix this issue. 回答1: Had to add the commons-lang

JSON deserialization of derived types

空扰寡人 提交于 2020-01-03 01:58:20
问题 class Attribute1 { } class Attribute2 : Attribute1 { } class class1 { Attribute1 attr1; } class class2 : class1 { Attribute2 attr2; } var serializerSettings = new JsonSerializerSettings(){TypeNameHandling = TypeNameHandling.Objects}; class2 a = SomeValidObjectoftype Class2; string serializedClass2 = JsonConvert.SerializeObject(a, serializerSettings); var am = JsonConvert.DeserializeObject<Class2>(serializedClass1); All the above are JSON properties and objects. What I am trying to do is