serialization

Xamarin Using DataContractJsonSerializer for Android Blank App

时间秒杀一切 提交于 2019-12-25 01:59:46
问题 I am trying to use DataContractJsonSerializer but I can't seem to get a reference/namespace for it. I created my app on a .NET Framework 4.5. When I click add reference I only get the version 2.0.5.0 for System.ServiceModel 回答1: If you want to get DataContractJsonSerializer working with Android you would need to create a PCL project and then it would be available under namespace System.Runtime.Serialization.Json. This would require a Xamarin business license or higher to work. Better option

How do I change the XmlElement name dynamically?

隐身守侯 提交于 2019-12-25 01:54:08
问题 [XmlRoot("A")] public class Foos { [XmlElement("A1")] public List<Foo> FooList{ get; set; } } var serializer = new XmlSerializer(typeof(Foos)); This code working as well. But its not dynamic. I want [XmlRoot("A")] to [XmlRoot(ConfigurationManager.AppSettings[someValue])] . But is throw to syntax error. Then i try this public class Foos { [XmlElement("A1")] public List<Foo> FooList{ get; set; } } var serializer = new XmlSerializer(typeof(Foos),new XmlRootAttribute(ConfigurationManager

XmlSerialization and interfaces

邮差的信 提交于 2019-12-25 01:49:07
问题 I know that you can't serialize/deserialize using an interface but I'm confused by behaviour I'm seeing. When I deserialize and cast back to the interface, some properties are null. But if I cast back to the concrete type the same property has a value? So, given this XML (shortened for brevity): <Page> <ComponentPresentations> <ComponentPresentation> <Component> <Categories> <Category> <Id>tcm:35-540-512</Id> Deserializing with var serializer = new XmlSerializer(typeof(Page)); page = (IPage

Php curl and serialize problem

人走茶凉 提交于 2019-12-25 01:48:33
问题 In order to pass array variables via my curl script, I am using serialize because curl POST elements must not be arrays. The string that I get after serialization is: a:10:{s:8:"question";s:18:"How are you doing?";s:11:"view_option";s:6:"select";s:10:"txt_answer";a:4:{i:0;s:8:"dsadsdsa";i:1;s:5:"dsads";i:2;s:10:"dsadsdsdsa";i:3;s:0:"";}s:4:"next";s:1:"9";s:7:"bgimage";s:0:"";s:9:"bck_color";s:0:"";s:12:"border_color";s:0:"";s:11:"select_font";s:1:"1";s:9:"font_size";s:4:"12px";s:4:"poll";s:9:

Passing an inherited “Data Contract” through WCF call?

家住魔仙堡 提交于 2019-12-25 01:34:23
问题 One of my WCF endpoints has this method: GetData(DataTable dt) I tried to create a class on the client that inherits from the DataTable class public class ExtendedDataTable : DataTable{ //...implementation } and pass it along with the endpoint call: GetData(new ExtendedDataTable()); Then I got the SerializationException . Accordingly to the error, it suggests that I use either DataContractResolver or the KnownType attribute. I don't want to use the KnownType, because I shouldn't have to

kSoap2 serialisation error

不羁岁月 提交于 2019-12-25 01:14:16
问题 I'm using kSoap2 to connect to a WCF service from an android device but I get an serialisation error: Cannot serialize: CompositeType : StringValue = Test, BoolValue = true Here is the code for the webservice call: public void call() { try { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); CompositeType comp = new CompositeType(); comp.setProperty(CompositeType.STRING_VALUE, "Test"); comp.setProperty(CompositeType.BOOLEAN_VALUE, true); PropertyInfo pi = new PropertyInfo(); pi

Kafka JsonDeserializer fails. What to do?

柔情痞子 提交于 2019-12-25 01:09:02
问题 I just want to know what is the best approach to handle json deserialisation errors while consuming data. Lets say, my producer added below Json to topic: { "name":"John", "age":30 } Later on producer changed the format of Json and now it started to add below message: { "surname":"Smith", "Country":"USA", "car":null } On the other side I have Consumer which has Pojo with the fields name and age. Obviously my consumer(JsonDeserializer) is going to fail while deserialising second message. Here

Error: “missing a mandatory child element”

半世苍凉 提交于 2019-12-25 00:55:18
问题 Following the steps from Lesson 5: Publish the Report Definition to the Report Server for SQL Server 2012, I have the following error: The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: The report definition element 'Report' is empty at line 1878, position 3. It

Deserialize matching types from different assemblies

谁说我不能喝 提交于 2019-12-25 00:46:19
问题 If I have a class/interface pair defined in AssemblyA under namespace AssemblyA.Entities : public IEntity { string Name { get; set; } } [Serializable] public Entity : IEntity { public string Name { get; set; } } And I serialize it to XML using XmlSerializer : var myEntities = new List<IEntity>(); // myEntities is populated somehow var data = XmlSerializationManager.Serialize(myEntities); // 'data' gets saved to disk somewhere as a file Then , if I duplicate the code/namespaces into AssemblyB

Serializing class inherited from List<> using DataContractSerializer does not serialize object properties

匆匆过客 提交于 2019-12-25 00:13:03
问题 Since XmlSerializer can not serialize any other properties when the class is inherited from List <> , I try to solve them with the DataContractSerializer . This should work, as described here: When a class is inherited from List<>, XmlSerializer doesn't serialize other attributes But I get the same results. If the object is inherited from List <> the TestValue property is not serialized. using System.Runtime.Serialization; [Serializable] public class XSerBase { [DataMember] public XSerTest