PrepAway - Latest Free Exam Questions & Answers

Which attributes should you include in Target 1, Target 2 and Target 3 to complete the code?

DRAG DROP
An application serializes and deserializes XML from streams. The XML streams are in the following
format:

The application reads the XML streams by using a DataContractSerializer object that is declared by
the following code segment:

You need to ensure that the application preserves the element ordering as provided in the XML
stream.
You have the following code:

Which attributes should you include in Target 1, Target 2 and Target 3 to complete the code? (To
answer, drag the appropriate attributes to the correct targets in the answer are
a) Each attribute may be used once, more than once, or not at all. You may need to drag the split bar
between panes or scroll to view content.)

PrepAway - Latest Free Exam Questions & Answers

Answer: See the explanation

Explanation:
DataContractSerializer DataContract DataMember
Target 1: [DataContract(NameSpace=http://contoso.com/2012/06)]
Target 2: [DataMember(Order=10)]
Target 3: [DataMember]

Target 1: The DataContractAttribute.Namespace Property gets or sets the namespace for the data
contract for the type. Use this property to specify a particular namespace if your type must return
data that complies with a specific data contract.
Target2, target3: We put Order=10 on FirstName to ensure that LastName is ordered first.
Note:
The basic rules for data ordering include:
* If a data contract type is a part of an inheritance hierarchy, data members of its base types are
always first in the order.
* Next in order are the current type’s data members that do not have the Order property of the
DataMemberAttribute attribute set, in alphabetical order.
* Next are any data members that have the Order property of the DataMemberAttribute attribute
set. These are ordered by the value of the Order property first and then alphabetically if there is
more than one member of a certain Order value. Order values may be skipped.

Data Member Order
https://msdn.microsoft.com/en-us/library/ms729813(v=vs.110).aspx

DataContractAttribute.Namespace Property
https://msdn.microsoft.com/enus/library/system.runtime.serialization.datacontractattribute.namespace(v=vs.110).aspx

3 Comments on “Which attributes should you include in Target 1, Target 2 and Target 3 to complete the code?


Leave a Reply