datacontractserializer

DataContractSerializer - change namespace and deserialize file bound to old namespace

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-31 10:33:12
问题 I have a data class that is serialized with the DataContractSerializer . The class uses the [DataContract] attribute with no explicit Namespace declaration. As such, the namespace in the resulting xml file is generated based on the namespace of the class. The class basically looks like this: namespace XYZ { [DataContract] public class Data { [DataMember(Order = 1)] public string Prop1 { get; set; } [DataMember(Order = 2)] public int Prop2 { get; set; } } } ...and the resulting xml: <?xml

How to Deserialize XML using DataContractSerializer

杀马特。学长 韩版系。学妹 提交于 2019-12-29 05:46:25
问题 I'm trying to deserialize an xml document: <?xml version="1.0"?> <games xmlns = "http://serialize"> <game> <name>TEST1</name> <code>TESTGAME1</code> <ugn>1111111</ugn> <bets> <bet>5,00</bet> </bets> </game> <game> <name>TEST2</name> <code>TESTGAME2</code> <ugn>222222</ugn> <bets> <bet>0,30</bet> <bet>0,90</bet> </bets> </game> </games> .cs class: namespace XmlParse { using System.Collections.Generic; using System.Runtime.Serialization; [DataContract(Namespace = "http://serialize")] public

WCF Datacontract, some fields do not deserialize

£可爱£侵袭症+ 提交于 2019-12-27 12:04:26
问题 Problem: I have a WCF service setup to be an endpoint for a call from an external system. The call is sending plain xml. I am testing the system by sending calls into the service from Fiddler using the RequestBuilder. The issue is that all of my fields are being deserialized with the exception of two fields. price_retail and price_wholesale . What am I missing? All of the other fields deserialize without an issue - the service responds. It is just these fields. XML Message: <widget_conclusion

Custom DataContractSerializer

别来无恙 提交于 2019-12-25 08:38:52
问题 I want to serialize an object with DataMember attribute to be ignored on some properties. Say I have custom attribute MyIgnoreDataMember. I want properties marked with it to be invisible for my custom DataContractSerializer, but visible for the normal DataContractSerializer. And I have to use DataContractSerializer and nothing else. The code is a Silverlight app. Anyone have done subclassing DataContractSerializer successfully? 回答1: An answer to your question is complicated by the following

partial or full object serialization

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 06:05:23
问题 Consider the following Student defintion: public class Student { public Guid Id {get; set;} public String FirstName {get; set;} public String LastName { get; set; } } Using C# serialization attributes, how can you apply two different serialization configurations? When the object is passed to the DataContractSerializer , the user could specify "idOnly" (partial) or "full" serialization. I have a two runtime use cases: Only serialize the Guid Full serialization of the Object. 回答1: I don't know

partial or full object serialization

孤者浪人 提交于 2019-12-25 06:04:30
问题 Consider the following Student defintion: public class Student { public Guid Id {get; set;} public String FirstName {get; set;} public String LastName { get; set; } } Using C# serialization attributes, how can you apply two different serialization configurations? When the object is passed to the DataContractSerializer , the user could specify "idOnly" (partial) or "full" serialization. I have a two runtime use cases: Only serialize the Guid Full serialization of the Object. 回答1: I don't know

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

Is there a reason for the nested generic collection classes in svcutil generated code?

十年热恋 提交于 2019-12-25 01:00:19
问题 I'm generating my data contract with a command line like: svcutil /ct:System.Collections.Generic.List`1 MySchema.xsd In my generated code, I end up with something like this (let's call this "style 1"): partial class A : object, System.Runtime.Serialization.IExtensibleDataObject { private BType collectionB; public BType CollectionOfB { get { return collectionB; } set { collectionB = value } } [System.Runtime.Serialization.CollectionDataContractAttribute(...)] public class BType : System

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

How I can get rid of specified fields while creating proxy for a WCF service?

别来无恙 提交于 2019-12-24 14:27:58
问题 While creating proxy from a WCF service,the each value type members which I declared inside service creating one more bool type specified field in proxy. Is there any way i can get rid of this and continue to transact with service? i have below class described in service as [DataContract] public class Customer { private int customerID; [DataMember] public int CustomerID { get { return customerID; } set { customerID = value; } } } while creating proxy i am having proxy class like this public