c# - Inconsistent DataContractAttribute behavior -
Based on my understanding, WCF's data contract model is opted in from the old opt-out approach of the AMX web services. I went. You must explicitly include all the fields and types you need to use using DataContractAttribute
and DataMemberAttribute
. My experience is different though.
Take a look at the following examples,
/// Case: 1 /// remains as unconscious bull value but string value is emitted [DataCentrett] Public Class Composite Type {[Database] Public Bull Boulevavil {Received; Set; } Public String StringValue {get; Set; }}
/// Case: 2 /// contains all the elements, as if everything was marked. Public class composite type {public; Set; } Public String StringValue {get; Set; }}
/// case: 3 /// MyEnum type is included even if MyEnum is not marked. [DataContract] Public Class Composite Type {{Datamembr} Public Balls Bowel Value {Receive; Set; } [Datamember] public string string value {received; Set; } [Datamember] Public MENEM ENVALUUE {Received; Set; }} Public enum MyEnum {Hello = 0, by = 1}
/// Case: 4 /// MyEnum type is no longer included. EnumValue has been serialized as a string [Data Contracts] Public class composite type {[Datamember] Public Child Boole Value {Received; Set; } [Datamember] public string string value {received; Set; } [Datamember] Public MENEM ENVALUUE {Received; Set; }} [Data Contract] Public Enum Myanm {Hello = 0, Bye = 1}
/// Case: 5 // Hello and goodbye both public NRI MyName {{EnumMember} Hello = 0, Bye = 1}
/// Case: 6 // Only hello series has been [Data Contracts] Public Enum MyName {EnumMember} Hello = 0, by = 1}
Can I just say WCF WTF?
Enumeration is always serialized by definition when you define a new enum, data on it There is no need to apply the contract attribute, and you can use it independently in the data contract. If you want to exclude certain value values from the data contract, then you need to decorate the Avenue first with the Data Contribute feature, then apply EnumMemberAttribute to all enum values, which you want to include in the enum data contract . ContactType {[EnumMember] customer for [DataContract], [EnumMember] Seller, // data will not be part of contract contract
As a result Wires will be represented:
enum ContactType {customer, vendor}
which is not correct for classes, which is explaining the case first, see
Comments
Post a Comment