serialization

XmlSerializer. Keep null string properties? [duplicate]

被刻印的时光 ゝ 提交于 2019-12-23 08:52:58
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: XML Serialization and null value - C# change how XmlSerializer serializes empty elements How to make XmlSerializer store empty tags for string properties having null values, instead of skipping this property? 回答1: You mean you want this: <parent> <child1>Hello World</child1> <child2 /> </parent> instead of <parent> <child1>Hello World</child1> </parent> your class should look like this: The serializer calls a

XmlSerializer. Keep null string properties? [duplicate]

喜你入骨 提交于 2019-12-23 08:52:22
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: XML Serialization and null value - C# change how XmlSerializer serializes empty elements How to make XmlSerializer store empty tags for string properties having null values, instead of skipping this property? 回答1: You mean you want this: <parent> <child1>Hello World</child1> <child2 /> </parent> instead of <parent> <child1>Hello World</child1> </parent> your class should look like this: The serializer calls a

boost::iostream zlib compressing multiple files into one archive

空扰寡人 提交于 2019-12-23 08:38:11
问题 i'm having trouble packing a bunch of files into one archive. the boost docs are very limited on this topic and i've searched the web for several hours now, but i can't find a solution. What i have so far: boost::filesystem::ofstream ofsArchive("some.zip"); boost::iostreams::filtering_ostreambuf outFilter; boost::iostreams::zlib_params zparam(boost::iostreams::zlib::default_compression); try { // set up the filter outFilter.strict_sync(); outFilter.push(boost::iostreams::zlib_compressor

SerializationException on 'CustomIdentity' when user is denied in ASP.NET

主宰稳场 提交于 2019-12-23 08:30:11
问题 I try to implement ASP.NET Authentication and Authorization on top of our existing database. We have a website calling a webservice to fetch its data. To use the webservice, i need to provide the username and password. Knowing that, I decided to implement IIdentity and IPrincipal to store the encrypted password and be able to provide it when performing webservice calls. In the future, we might want to use more of the built-in security of asp.net, so I implement membership and role provider

Null values for object properties de-serialized by WCF

空扰寡人 提交于 2019-12-23 08:07:31
问题 I have a WCF web service that used to work fine. Somewhere down the line it stopped and I cant tell why. The code and the interface never changed nor did the web.config (at least not in relation to the web services section). I have a class: [DataContract] public class QuizServiceArgs { [DataMember(IsRequired = true, Order = 1)] public int Category1 { get; set; } [DataMember(IsRequired = true, Order = 2)] public int Category2 { get; set; } [DataMember(IsRequired = true, Order = 3)] public int

How do I serialize a .NET object into Azure Blob Storage without using a temporary file?

怎甘沉沦 提交于 2019-12-23 08:03:25
问题 I want to store a .NET object into Azure Blob Storage. Currently I serialize it into an XML file using TextWriter ( episodeList is the object I want serialized): XmlAttributeOverrides overrides = new XmlAttributeOverrides(); XmlAttributes Xmlattr = new XmlAttributes(); Xmlattr.XmlRoot = new XmlRootAttribute("EPISODES"); overrides.Add(typeof(List<EpisodeData>), Xmlattr); XmlSerializer serializer = new XmlSerializer(typeof(List<EpisodeData>), overrides); TextWriter textWriter = new StreamWriter

In C#, How can I serialize Queue<>? (.Net 2.0)

十年热恋 提交于 2019-12-23 07:58:35
问题 At the XmlSerializer constructor line the below causes an InvalidOperationException which also complains about not having a default accesor implemented for the generic type. Queue<MyData> myDataQueue = new Queue<MyData>(); // Populate the queue here XmlSerializer mySerializer = new XmlSerializer(myDataQueue.GetType()); StreamWriter myWriter = new StreamWriter("myData.xml"); mySerializer.Serialize(myWriter, myDataQueue); myWriter.Close(); 回答1: It would be easier (and more appropriate IMO) to

How to serialize a generic JavaScript object to XML

ぃ、小莉子 提交于 2019-12-23 07:57:15
问题 Does one of the mainstream JavaScript libraries (YUI, jQuery, Dojo) provide a way to serialize a JavaScript object to XML (as text)? 回答1: There is no native API for native object to XML serializing; however, there are 3rd party libraries such as this one which will output XML: http://code.google.com/p/x2js/ See other threads on the subject. 来源: https://stackoverflow.com/questions/837577/how-to-serialize-a-generic-javascript-object-to-xml

Is it possible to use Protobuf-Net with a class without a parameterless constructor?

巧了我就是萌 提交于 2019-12-23 07:48:43
问题 Using Protobuf-Net, I see that it does not seem possible to deserialize a class without having a parameterless constructor or I may be missing something? I don't want some of the classes with a parameterless constructor. Is there some kind of attributes that I could use or some other technique? 回答1: protobuf-net depends currently on having a parameterless constructor to work. However that constructor need not be public (it will use reflection if need be to invoke it) so you may be able to

When sending XML to JMS should I use TextMessage or BytesMessage

依然范特西╮ 提交于 2019-12-23 07:42:42
问题 I have found some quite conflicting information on the web and I think that each different JMS provider may also alter the answer too. I'm trying to understand when sending XML into a JMS system (e.g. ActiveMQ) whether I should use a BytesMessage : I can guarantee that the XML is serialized correctly and the preamble will match the actual encoding. Furthermore I can be sure that the client will be able to get the raw representation correctly. TextMessage : There are APIs in many of the queue