0

I am working on a WCF service and our team wants to be able to serialize a valueless attribute form the contract. for example the xml would look like this:

<Payload>
  <Options all></Options>
</Payload>

as you can see all is passed as an attribute, only when the user wants all the options. the value all will not be provided if all is not provided.

This would be how the request for all options would be sumitted, vs a request for specific options

<Payload>
  <OptionList>
    <Option>option 1</Option>
    <Option>option 2</Option>
  </OptionList>
</Payload>

I currently have a Option data contract as follows:

[CollectionDataContract(ItemName="Option", Name="OptionList", Namespace="")]
public class OptionListV1:List<string>, IExtensibleDataObject
{
    public ExtensionDataObject ExtensionData { get; set; }
}

I know there is the XmlSerializerFormat attribute, but I am having a hard time determining if I can serialize a valueless attribute with the XmlSerializer.

Any ideas?

TL;DR: I want to serialize/deserialize a boolean property as a valueless attribute.

update if you believe this is a duplicate question, please answer the question with a link to the existing question.

Nathan Tregillus
  • 6,006
  • 3
  • 52
  • 91

0 Answers0